mirror of
https://github.com/gocsaf/csaf.git
synced 2025-12-22 18:15:42 +01:00
Find missing (#269)
Solves #160 * Implements check on whether index.txt/changes.csv and directory listings exist. Also fixes minor grammatical mistakes * Adds missing else to prevent defaulting to missing-error handling even if another error was found * Removes comment * test whether changes.csv or index.txt is empty * Fixed type mismatching, undeclared variable * Fixes typo in variable * Fixes another typo in variable * Fixes formatting error * Removed reminder comments * Fixes formatting errors * Added check for missing directories * Moved empty dirlistcheck to the right position * fixes typo * fixes typo * Add info if files are found * Cleans up code * simplified check for empty changes.csv and index.txt Co-authored-by: Jan Höfelmeyer <Jan Höfelmeyer jhoefelmeyer@intevation.de> Co-authored-by: Sascha L. Teichmann <sascha.teichmann@intevation.de>
This commit is contained in:
parent
4c0785c060
commit
141fbe21ca
1 changed files with 24 additions and 3 deletions
|
|
@ -586,6 +586,7 @@ func (p *processor) integrity(
|
|||
func (p *processor) processROLIEFeed(feed string) error {
|
||||
client := p.httpClient()
|
||||
res, err := client.Get(feed)
|
||||
p.badDirListings.use()
|
||||
if err != nil {
|
||||
p.badProviderMetadata.error("Cannot fetch feed %s: %v", feed, err)
|
||||
return errContinue
|
||||
|
|
@ -700,7 +701,6 @@ func (p *processor) processROLIEFeed(feed string) error {
|
|||
|
||||
files = append(files, file)
|
||||
})
|
||||
|
||||
if err := p.integrity(files, base, rolieMask, p.badProviderMetadata.add); err != nil &&
|
||||
err != errContinue {
|
||||
return err
|
||||
|
|
@ -744,9 +744,12 @@ func (p *processor) checkIndex(base string, mask whereType) error {
|
|||
if res.StatusCode != http.StatusNotFound {
|
||||
p.badIndices.error("Fetching %s failed. Status code %d (%s)",
|
||||
index, res.StatusCode, res.Status)
|
||||
} else {
|
||||
p.badIndices.warn("Fetching index.txt failed: %v not found.", index)
|
||||
}
|
||||
return errContinue
|
||||
}
|
||||
p.badIndices.info("Found %v", index)
|
||||
|
||||
files, err := func() ([]csaf.AdvisoryFile, error) {
|
||||
defer res.Body.Close()
|
||||
|
|
@ -766,6 +769,9 @@ func (p *processor) checkIndex(base string, mask whereType) error {
|
|||
p.badIndices.error("Reading %s failed: %v", index, err)
|
||||
return errContinue
|
||||
}
|
||||
if len(files) == 0 {
|
||||
p.badIntegrities.warn("index.txt contains no URLs")
|
||||
}
|
||||
|
||||
return p.integrity(files, base, mask, p.badIndices.add)
|
||||
}
|
||||
|
|
@ -798,9 +804,12 @@ func (p *processor) checkChanges(base string, mask whereType) error {
|
|||
// It's optional
|
||||
p.badChanges.error("Fetching %s failed. Status code %d (%s)",
|
||||
changes, res.StatusCode, res.Status)
|
||||
} else {
|
||||
p.badChanges.warn("Fetching changes.csv failed: %v not found.", changes)
|
||||
}
|
||||
return errContinue
|
||||
}
|
||||
p.badChanges.info("Found %v", changes)
|
||||
|
||||
times, files, err := func() ([]time.Time, []csaf.AdvisoryFile, error) {
|
||||
defer res.Body.Close()
|
||||
|
|
@ -841,6 +850,14 @@ func (p *processor) checkChanges(base string, mask whereType) error {
|
|||
return errContinue
|
||||
}
|
||||
|
||||
if len(files) == 0 {
|
||||
var filtered string
|
||||
if p.ageAccept != nil {
|
||||
filtered = " (maybe filtered out by time interval)"
|
||||
}
|
||||
p.badChanges.warn("no entries in changes.csv found" + filtered)
|
||||
}
|
||||
|
||||
if !sort.SliceIsSorted(times, func(i, j int) bool {
|
||||
return times[j].Before(times[i])
|
||||
}) {
|
||||
|
|
@ -953,7 +970,7 @@ func (p *processor) checkMissing(string) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
// checkInvalid wents over all found adivisories URLs and checks
|
||||
// checkInvalid goes over all found adivisories URLs and checks
|
||||
// if file name confirms to standard.
|
||||
func (p *processor) checkInvalid(string) error {
|
||||
|
||||
|
|
@ -975,7 +992,7 @@ func (p *processor) checkInvalid(string) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
// checkListing wents over all found adivisories URLs and checks
|
||||
// checkListing goes over all found adivisories URLs and checks
|
||||
// if their parent directory is listable.
|
||||
func (p *processor) checkListing(string) error {
|
||||
|
||||
|
|
@ -987,6 +1004,10 @@ func (p *processor) checkListing(string) error {
|
|||
|
||||
badDirs := map[string]struct{}{}
|
||||
|
||||
if len(p.alreadyChecked) == 0 {
|
||||
p.badDirListings.info("No directory listings found.")
|
||||
}
|
||||
|
||||
for f := range p.alreadyChecked {
|
||||
found, err := pgs.listed(f, p, badDirs)
|
||||
if err != nil && err != errContinue {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue