1
0
Fork 0
mirror of https://github.com/gocsaf/csaf.git synced 2025-12-22 18:15:42 +01:00

Mark files as already checked.

This commit is contained in:
Sascha L. Teichmann 2021-12-15 11:29:22 +01:00
parent 86c6b425b5
commit d9ab244918

View file

@ -35,15 +35,16 @@ import (
) )
type processor struct { type processor struct {
opts *options opts *options
redirects map[string]string redirects map[string]string
noneTLS map[string]struct{} noneTLS map[string]struct{}
pmd256 []byte alreadyChecked map[string]struct{}
pmd interface{} pmd256 []byte
builder gval.Language pmd interface{}
keys []*crypto.KeyRing builder gval.Language
badHashes []string keys []*crypto.KeyRing
badSignatures []string badHashes []string
badSignatures []string
} }
type check interface { type check interface {
@ -54,10 +55,11 @@ type check interface {
func newProcessor(opts *options) *processor { func newProcessor(opts *options) *processor {
return &processor{ return &processor{
opts: opts, opts: opts,
redirects: map[string]string{}, redirects: map[string]string{},
noneTLS: map[string]struct{}{}, noneTLS: map[string]struct{}{},
builder: gval.Full(jsonpath.Language()), alreadyChecked: map[string]struct{}{},
builder: gval.Full(jsonpath.Language()),
} }
} }
@ -68,6 +70,9 @@ func (p *processor) clean() {
for k := range p.noneTLS { for k := range p.noneTLS {
delete(p.noneTLS, k) delete(p.noneTLS, k)
} }
for k := range p.alreadyChecked {
delete(p.alreadyChecked, k)
}
p.pmd256 = nil p.pmd256 = nil
p.pmd = nil p.pmd = nil
p.keys = nil p.keys = nil
@ -119,6 +124,14 @@ func (p *processor) checkTLS(u string) {
} }
} }
func (p *processor) markChecked(s string) bool {
if _, ok := p.alreadyChecked[s]; ok {
return true
}
p.alreadyChecked[s] = struct{}{}
return false
}
func (p *processor) checkRedirect(r *http.Request, via []*http.Request) error { func (p *processor) checkRedirect(r *http.Request, via []*http.Request) error {
var path strings.Builder var path strings.Builder
@ -178,6 +191,9 @@ func (p *processor) integrity(
return err return err
} }
u := b.ResolveReference(fp).String() u := b.ResolveReference(fp).String()
if p.markChecked(u) {
continue
}
p.checkTLS(u) p.checkTLS(u)
res, err := client.Get(u) res, err := client.Get(u)
if err != nil { if err != nil {