mirror of
https://github.com/aquasecurity/trivy.git
synced 2025-12-20 14:22:50 -08:00
Signed-off-by: nikpivkin <nikita.pivkin@smartforce.io> Co-authored-by: Simar <simar@linux.com> Co-authored-by: simar7 <1254783+simar7@users.noreply.github.com>
38 lines
930 B
Go
38 lines
930 B
Go
package ansible
|
|
|
|
import (
|
|
"os"
|
|
"path/filepath"
|
|
"slices"
|
|
|
|
"github.com/aquasecurity/trivy/pkg/fanal/analyzer"
|
|
"github.com/aquasecurity/trivy/pkg/fanal/analyzer/config"
|
|
"github.com/aquasecurity/trivy/pkg/iac/detection"
|
|
)
|
|
|
|
const (
|
|
version = 1
|
|
analyzerType = analyzer.TypeAnsible
|
|
)
|
|
|
|
func init() {
|
|
analyzer.RegisterPostAnalyzer(analyzerType, newAnsibleConfigAnalyzer)
|
|
}
|
|
|
|
type ansibleConfigAnalyzer struct {
|
|
*config.Analyzer
|
|
}
|
|
|
|
func newAnsibleConfigAnalyzer(opts analyzer.AnalyzerOptions) (analyzer.PostAnalyzer, error) {
|
|
a, err := config.NewAnalyzer(analyzerType, version, detection.FileTypeAnsible, opts)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return &ansibleConfigAnalyzer{Analyzer: a}, nil
|
|
}
|
|
|
|
func (a *ansibleConfigAnalyzer) Required(filePath string, _ os.FileInfo) bool {
|
|
return filepath.Base(filePath) == "ansible.cfg" ||
|
|
slices.Contains([]string{"", ".yml", ".yaml", ".json", ".ini"}, filepath.Ext(filePath))
|
|
}
|