-
Notifications
You must be signed in to change notification settings - Fork 82
/
defaults.go
70 lines (61 loc) · 1.56 KB
/
defaults.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
// Importing this package registers default matchers via its init function.
package defaults
import (
"context"
"sync"
"time"
"github.com/quay/claircore/alpine"
"github.com/quay/claircore/aws"
"github.com/quay/claircore/crda"
"github.com/quay/claircore/debian"
"github.com/quay/claircore/gobin"
"github.com/quay/claircore/java"
"github.com/quay/claircore/libvuln/driver"
"github.com/quay/claircore/matchers/registry"
"github.com/quay/claircore/oracle"
"github.com/quay/claircore/photon"
"github.com/quay/claircore/python"
"github.com/quay/claircore/rhel"
"github.com/quay/claircore/rhel/rhcc"
"github.com/quay/claircore/suse"
"github.com/quay/claircore/ubuntu"
)
var (
once sync.Once
regerr error
)
func init() {
ctx, done := context.WithTimeout(context.Background(), 1*time.Minute)
defer done()
once.Do(func() { regerr = inner(ctx) })
}
// Error reports if an error was encountered when initializing the default
// matchers.
func Error() error {
return regerr
}
// defaultMatchers is a variable containing
// all the matchers libvuln will use to match
// index records to vulnerabilities.
var defaultMatchers = []driver.Matcher{
&alpine.Matcher{},
&aws.Matcher{},
&debian.Matcher{},
&gobin.Matcher{},
&java.Matcher{},
&oracle.Matcher{},
&photon.Matcher{},
&python.Matcher{},
rhcc.Matcher,
&rhel.Matcher{},
&suse.Matcher{},
&ubuntu.Matcher{},
}
func inner(ctx context.Context) error {
registry.Register("crda", &crda.Factory{})
for _, m := range defaultMatchers {
mf := driver.MatcherStatic(m)
registry.Register(m.Name(), mf)
}
return nil
}