mirror of
https://github.com/gocsaf/csaf.git
synced 2025-12-22 11:55:40 +01:00
Only report bad directories in listing check only once.
This commit is contained in:
parent
324de3abca
commit
332f0b2711
2 changed files with 14 additions and 2 deletions
|
|
@ -25,7 +25,11 @@ type (
|
||||||
pages map[string]*pageContent
|
pages map[string]*pageContent
|
||||||
)
|
)
|
||||||
|
|
||||||
func (pgs pages) listed(path string, pro *processor) (bool, error) {
|
func (pgs pages) listed(
|
||||||
|
path string,
|
||||||
|
pro *processor,
|
||||||
|
badDirs map[string]struct{},
|
||||||
|
) (bool, error) {
|
||||||
pathURL, err := url.Parse(path)
|
pathURL, err := url.Parse(path)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, err
|
return false, err
|
||||||
|
|
@ -50,6 +54,10 @@ func (pgs pages) listed(path string, pro *processor) (bool, error) {
|
||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if _, ok := badDirs[base]; ok {
|
||||||
|
return false, errContinue
|
||||||
|
}
|
||||||
|
|
||||||
// load page
|
// load page
|
||||||
client := pro.httpClient()
|
client := pro.httpClient()
|
||||||
pro.checkTLS(base)
|
pro.checkTLS(base)
|
||||||
|
|
@ -59,11 +67,13 @@ func (pgs pages) listed(path string, pro *processor) (bool, error) {
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
pro.badDirListings.error("Fetching %s failed: %v", base, err)
|
pro.badDirListings.error("Fetching %s failed: %v", base, err)
|
||||||
|
badDirs[base] = struct{}{}
|
||||||
return false, errContinue
|
return false, errContinue
|
||||||
}
|
}
|
||||||
if res.StatusCode != http.StatusOK {
|
if res.StatusCode != http.StatusOK {
|
||||||
pro.badDirListings.error("Fetching %s failed. Status code %d (%s)",
|
pro.badDirListings.error("Fetching %s failed. Status code %d (%s)",
|
||||||
base, res.StatusCode, res.Status)
|
base, res.StatusCode, res.Status)
|
||||||
|
badDirs[base] = struct{}{}
|
||||||
return false, errContinue
|
return false, errContinue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -873,8 +873,10 @@ func (p *processor) checkListing(string) error {
|
||||||
|
|
||||||
var unlisted []string
|
var unlisted []string
|
||||||
|
|
||||||
|
badDirs := map[string]struct{}{}
|
||||||
|
|
||||||
for f := range p.alreadyChecked {
|
for f := range p.alreadyChecked {
|
||||||
found, err := pgs.listed(f, p)
|
found, err := pgs.listed(f, p, badDirs)
|
||||||
if err != nil && err != errContinue {
|
if err != nil && err != errContinue {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue