mirror of
https://github.com/gocsaf/csaf.git
synced 2025-12-22 18:15:42 +01:00
Replace 'confirming filename' with 'conforming filename'
This commit is contained in:
parent
b80163c35f
commit
ffb29f5ba4
10 changed files with 22 additions and 22 deletions
|
|
@ -501,10 +501,10 @@ func (w *worker) mirrorFiles(tlpLabel csaf.TLPLabel, files []csaf.AdvisoryFile)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
// Ignore not confirming filenames.
|
// Ignore not conforming filenames.
|
||||||
filename := filepath.Base(u.Path)
|
filename := filepath.Base(u.Path)
|
||||||
if !util.ConfirmingFileName(filename) {
|
if !util.ConformingFileName(filename) {
|
||||||
log.Printf("Not confirming filename %q. Ignoring.\n", filename)
|
log.Printf("Not conforming filename %q. Ignoring.\n", filename)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -445,10 +445,10 @@ func (p *processor) integrity(
|
||||||
}
|
}
|
||||||
p.checkTLS(u)
|
p.checkTLS(u)
|
||||||
|
|
||||||
// Check if the filename is confirming.
|
// Check if the filename is conforming.
|
||||||
p.badFilenames.use()
|
p.badFilenames.use()
|
||||||
if !util.ConfirmingFileName(filepath.Base(u)) {
|
if !util.ConformingFileName(filepath.Base(u)) {
|
||||||
p.badFilenames.error("%s has not a confirming filename.", u)
|
p.badFilenames.error("%s has not a conforming filename.", u)
|
||||||
}
|
}
|
||||||
|
|
||||||
var folderYear *int
|
var folderYear *int
|
||||||
|
|
@ -1054,14 +1054,14 @@ func (p *processor) checkMissing(string) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
// checkInvalid goes over all found adivisories URLs and checks
|
// checkInvalid goes over all found adivisories URLs and checks
|
||||||
// if file name confirms to standard.
|
// if file name conforms to standard.
|
||||||
func (p *processor) checkInvalid(string) error {
|
func (p *processor) checkInvalid(string) error {
|
||||||
|
|
||||||
p.badDirListings.use()
|
p.badDirListings.use()
|
||||||
var invalids []string
|
var invalids []string
|
||||||
|
|
||||||
for f := range p.alreadyChecked {
|
for f := range p.alreadyChecked {
|
||||||
if !util.ConfirmingFileName(filepath.Base(f)) {
|
if !util.ConformingFileName(filepath.Base(f)) {
|
||||||
invalids = append(invalids, f)
|
invalids = append(invalids, f)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -66,7 +66,7 @@ func (r *filenameReporter) report(p *processor, domain *Domain) {
|
||||||
if !p.badFilenames.used() {
|
if !p.badFilenames.used() {
|
||||||
req.message(InfoType, "No filenames checked for conformance")
|
req.message(InfoType, "No filenames checked for conformance")
|
||||||
} else if len(p.badFilenames) == 0 {
|
} else if len(p.badFilenames) == 0 {
|
||||||
req.message(InfoType, "All found filenames are confirming.")
|
req.message(InfoType, "All found filenames are conforming.")
|
||||||
} else {
|
} else {
|
||||||
req.Append(p.badFilenames)
|
req.Append(p.badFilenames)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -262,10 +262,10 @@ func (d *downloader) downloadFiles(label csaf.TLPLabel, files []csaf.AdvisoryFil
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
// Ignore not confirming filenames.
|
// Ignore not conforming filenames.
|
||||||
filename := filepath.Base(u.Path)
|
filename := filepath.Base(u.Path)
|
||||||
if !util.ConfirmingFileName(filename) {
|
if !util.ConformingFileName(filename) {
|
||||||
log.Printf("Not confirming filename %q. Ignoring.\n", filename)
|
log.Printf("Not conforming filename %q. Ignoring.\n", filename)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -47,8 +47,8 @@ func (c *controller) loadCSAF(r *http.Request) (string, []byte, error) {
|
||||||
return "", nil, errors.New("expected content type 'application/json'")
|
return "", nil, errors.New("expected content type 'application/json'")
|
||||||
}
|
}
|
||||||
|
|
||||||
if !util.ConfirmingFileName(handler.Filename) {
|
if !util.ConformingFileName(handler.Filename) {
|
||||||
return "", nil, errors.New("given csaf filename is not confirming")
|
return "", nil, errors.New("given csaf filename is not conforming")
|
||||||
}
|
}
|
||||||
|
|
||||||
var buf bytes.Buffer
|
var buf bytes.Buffer
|
||||||
|
|
|
||||||
|
|
@ -72,7 +72,7 @@ func (c *controller) bind(pim *pathInfoMux) {
|
||||||
pim.handleFunc("/api/create", c.auth(api(c.create)))
|
pim.handleFunc("/api/create", c.auth(api(c.create)))
|
||||||
}
|
}
|
||||||
|
|
||||||
// authenticate checks if the incoming request confirms with the
|
// authenticate checks if the incoming request conforms with the
|
||||||
// configured authentication mechanism.
|
// configured authentication mechanism.
|
||||||
func (c *controller) authenticate(r *http.Request) bool {
|
func (c *controller) authenticate(r *http.Request) bool {
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -314,8 +314,8 @@ func (p *processor) uploadRequest(filename string) (*http.Request, error) {
|
||||||
// It prints the response messages.
|
// It prints the response messages.
|
||||||
func (p *processor) process(filename string) error {
|
func (p *processor) process(filename string) error {
|
||||||
|
|
||||||
if bn := filepath.Base(filename); !util.ConfirmingFileName(bn) {
|
if bn := filepath.Base(filename); !util.ConformingFileName(bn) {
|
||||||
return fmt.Errorf("%q is not a confirming file name", bn)
|
return fmt.Errorf("%q is not a conforming file name", bn)
|
||||||
}
|
}
|
||||||
|
|
||||||
req, err := p.uploadRequest(filename)
|
req, err := p.uploadRequest(filename)
|
||||||
|
|
|
||||||
|
|
@ -70,7 +70,7 @@ func run(opts *options, files []string) error {
|
||||||
|
|
||||||
for _, file := range files {
|
for _, file := range files {
|
||||||
// Check if the file name is valid.
|
// Check if the file name is valid.
|
||||||
if !util.ConfirmingFileName(filepath.Base(file)) {
|
if !util.ConformingFileName(filepath.Base(file)) {
|
||||||
fmt.Printf("%q is not a valid advisory name.\n", file)
|
fmt.Printf("%q is not a valid advisory name.\n", file)
|
||||||
}
|
}
|
||||||
doc, err := loadJSONFromFile(file)
|
doc, err := loadJSONFromFile(file)
|
||||||
|
|
|
||||||
|
|
@ -33,8 +33,8 @@ func CleanFileName(s string) string {
|
||||||
return invalidRune.ReplaceAllString(s, "_") + ".json"
|
return invalidRune.ReplaceAllString(s, "_") + ".json"
|
||||||
}
|
}
|
||||||
|
|
||||||
// ConfirmingFileName checks if the given filename is confirming the standard.
|
// ConformingFileName checks if the given filename conforms to the standard.
|
||||||
func ConfirmingFileName(fname string) bool {
|
func ConformingFileName(fname string) bool {
|
||||||
return fname == CleanFileName(fname)
|
return fname == CleanFileName(fname)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,7 @@ func TestCleanFileName(t *testing.T) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestConfirmingFileName(t *testing.T) {
|
func TestConformingFileName(t *testing.T) {
|
||||||
for _, x := range []struct {
|
for _, x := range []struct {
|
||||||
s string
|
s string
|
||||||
b bool
|
b bool
|
||||||
|
|
@ -41,7 +41,7 @@ func TestConfirmingFileName(t *testing.T) {
|
||||||
{`abc_.htm__l`, false},
|
{`abc_.htm__l`, false},
|
||||||
{`foo+BAR`, false},
|
{`foo+BAR`, false},
|
||||||
} {
|
} {
|
||||||
if got := ConfirmingFileName(x.s); got != x.b {
|
if got := ConformingFileName(x.s); got != x.b {
|
||||||
t.Errorf("%q: Expected %t but got %t.", x.s, x.b, got)
|
t.Errorf("%q: Expected %t but got %t.", x.s, x.b, got)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue