-
Notifications
You must be signed in to change notification settings - Fork 2.4k
/
Copy pathmeta.go
39 lines (30 loc) · 988 Bytes
/
meta.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
package meta
import (
"context"
"os"
"path/filepath"
"regexp"
"github.com/aquasecurity/go-dep-parser/pkg/conda/meta"
"github.com/aquasecurity/trivy/pkg/fanal/analyzer"
"github.com/aquasecurity/trivy/pkg/fanal/analyzer/language"
"github.com/aquasecurity/trivy/pkg/fanal/types"
)
func init() {
analyzer.RegisterAnalyzer(&metaAnalyzer{})
}
const version = 1
var fileRegex = regexp.MustCompile(`.*/envs/.+/conda-meta/.+-.+-.+\.json`)
type metaAnalyzer struct{}
func (a metaAnalyzer) Analyze(_ context.Context, input analyzer.AnalysisInput) (*analyzer.AnalysisResult, error) {
p := meta.NewParser()
return language.AnalyzePackage(types.CondaPkg, input.FilePath, input.Content, p, input.Options.FileChecksum)
}
func (a metaAnalyzer) Required(filePath string, _ os.FileInfo) bool {
return fileRegex.MatchString(filepath.ToSlash(filePath))
}
func (a metaAnalyzer) Type() analyzer.Type {
return analyzer.TypeCondaPkg
}
func (a metaAnalyzer) Version() int {
return version
}