1
0
Fork 0
mirror of https://github.com/gocsaf/csaf.git synced 2025-12-22 11:55:40 +01:00

Implement rule depending error check.

This commit is contained in:
Sascha L. Teichmann 2023-06-13 13:28:01 +02:00
parent c7453a6448
commit 7501c60bf4
3 changed files with 111 additions and 20 deletions

View file

@ -149,6 +149,19 @@ func (m *topicMessages) reset() { *m = nil }
// used returns true if we have used this topic.
func (m *topicMessages) used() bool { return *m != nil }
// hasErrors checks if there are any error messages.
func (m *topicMessages) hasErrors() bool {
if !m.used() {
return false
}
for _, msg := range *m {
if msg.Type == ErrorType {
return true
}
}
return false
}
// newProcessor returns a processor structure after assigning the given options to the opts attribute
// and initializing the "alreadyChecked" and "expr" fields.
func newProcessor(opts *options) (*processor, error) {
@ -263,10 +276,13 @@ func (p *processor) run(domains []string) (*Report, error) {
rules = trustedProviderRules
}
for _, r := range rules.reporters() {
// 18, 19, 20 should always be checked.
for _, r := range rules.reporters([]int{18, 19, 20}) {
r.report(p, domain)
}
domain.Passed = rules.eval(p)
report.Domains = append(report.Domains, domain)
p.clean()
}