mirror of
https://github.com/gocsaf/csaf.git
synced 2025-12-22 11:55:40 +01:00
parent
be3dfcd542
commit
8032d47b50
8 changed files with 40 additions and 40 deletions
|
|
@ -20,7 +20,7 @@ import (
|
|||
type (
|
||||
pageContent struct {
|
||||
err error
|
||||
links map[string]struct{}
|
||||
links util.Set[string]
|
||||
}
|
||||
pages map[string]*pageContent
|
||||
)
|
||||
|
|
@ -28,7 +28,7 @@ type (
|
|||
func (pgs pages) listed(
|
||||
path string,
|
||||
pro *processor,
|
||||
badDirs map[string]struct{},
|
||||
badDirs util.Set[string],
|
||||
) (bool, error) {
|
||||
pathURL, err := url.Parse(path)
|
||||
if err != nil {
|
||||
|
|
@ -45,8 +45,7 @@ func (pgs pages) listed(
|
|||
if content.err != nil {
|
||||
return false, nil
|
||||
}
|
||||
_, ok := content.links[path]
|
||||
return ok, nil
|
||||
return content.links.Contains(path), nil
|
||||
}
|
||||
|
||||
baseURL, err := url.Parse(base)
|
||||
|
|
@ -54,7 +53,7 @@ func (pgs pages) listed(
|
|||
return false, err
|
||||
}
|
||||
|
||||
if _, ok := badDirs[base]; ok {
|
||||
if badDirs.Contains(base) {
|
||||
return false, errContinue
|
||||
}
|
||||
|
||||
|
|
@ -67,18 +66,18 @@ func (pgs pages) listed(
|
|||
|
||||
if err != nil {
|
||||
pro.badDirListings.error("Fetching %s failed: %v", base, err)
|
||||
badDirs[base] = struct{}{}
|
||||
badDirs.Add(base)
|
||||
return false, errContinue
|
||||
}
|
||||
if res.StatusCode != http.StatusOK {
|
||||
pro.badDirListings.error("Fetching %s failed. Status code %d (%s)",
|
||||
base, res.StatusCode, res.Status)
|
||||
badDirs[base] = struct{}{}
|
||||
badDirs.Add(base)
|
||||
return false, errContinue
|
||||
}
|
||||
|
||||
content = &pageContent{
|
||||
links: map[string]struct{}{},
|
||||
links: util.Set[string]{},
|
||||
}
|
||||
|
||||
pgs[base] = content
|
||||
|
|
@ -94,15 +93,14 @@ func (pgs pages) listed(
|
|||
}
|
||||
// Links may be relative
|
||||
abs := baseURL.ResolveReference(u).String()
|
||||
content.links[abs] = struct{}{}
|
||||
content.links.Add(abs)
|
||||
return nil
|
||||
})
|
||||
}(); err != nil {
|
||||
return false, errContinue
|
||||
}
|
||||
|
||||
_, ok := content.links[path]
|
||||
return ok, nil
|
||||
return content.links.Contains(path), nil
|
||||
}
|
||||
|
||||
func linksOnPage(r io.Reader, visit func(string) error) error {
|
||||
|
|
|
|||
|
|
@ -46,7 +46,7 @@ type processor struct {
|
|||
ageAccept func(time.Time) bool
|
||||
|
||||
redirects map[string][]string
|
||||
noneTLS map[string]struct{}
|
||||
noneTLS util.Set[string]
|
||||
alreadyChecked map[string]whereType
|
||||
pmdURL string
|
||||
pmd256 []byte
|
||||
|
|
@ -369,10 +369,10 @@ func (p *processor) checkDomain(domain string) error {
|
|||
// the value of "noneTLS" field if it is not HTTPS.
|
||||
func (p *processor) checkTLS(u string) {
|
||||
if p.noneTLS == nil {
|
||||
p.noneTLS = map[string]struct{}{}
|
||||
p.noneTLS = util.Set[string]{}
|
||||
}
|
||||
if x, err := url.Parse(u); err == nil && x.Scheme != "https" {
|
||||
p.noneTLS[u] = struct{}{}
|
||||
p.noneTLS.Add(u)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1163,7 +1163,7 @@ func (p *processor) checkListing(string) error {
|
|||
|
||||
var unlisted []string
|
||||
|
||||
badDirs := map[string]struct{}{}
|
||||
badDirs := util.Set[string]{}
|
||||
|
||||
if len(p.alreadyChecked) == 0 {
|
||||
p.badDirListings.info("No directory listings found.")
|
||||
|
|
|
|||
|
|
@ -12,6 +12,8 @@ import (
|
|||
"fmt"
|
||||
"sort"
|
||||
"strings"
|
||||
|
||||
"github.com/csaf-poc/csaf_distribution/v2/util"
|
||||
)
|
||||
|
||||
type (
|
||||
|
|
@ -211,15 +213,15 @@ func (r *redirectsReporter) report(p *processor, domain *Domain) {
|
|||
// keysNotInValues returns a slice of keys which are not in the values
|
||||
// of the given map.
|
||||
func keysNotInValues(m map[string][]string) []string {
|
||||
values := map[string]bool{}
|
||||
values := util.Set[string]{}
|
||||
for _, vs := range m {
|
||||
for _, v := range vs {
|
||||
values[v] = true
|
||||
values.Add(v)
|
||||
}
|
||||
}
|
||||
keys := make([]string, 0, len(m))
|
||||
for k := range m {
|
||||
if !values[k] {
|
||||
if !values.Contains(k) {
|
||||
keys = append(keys, k)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -284,7 +284,7 @@ func (p *processor) processROLIEFeeds(feeds [][]csaf.Feed) error {
|
|||
"Invalid URL %s in feed: %v.", *feed.URL, err)
|
||||
continue
|
||||
}
|
||||
advisories[makeAbs(u).String()] = struct{}{}
|
||||
advisories.Add(makeAbs(u).String())
|
||||
}
|
||||
if advisories.ContainsAll(reference) {
|
||||
hasSummary.Add(label)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue