Skip to content

Commit c228307

Browse files
authored
fix(fs): check postAnalyzers for StaticPaths (#8543)
1 parent 126d6cd commit c228307

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

pkg/fanal/analyzer/analyzer.go

+8
Original file line numberDiff line numberDiff line change
@@ -556,6 +556,14 @@ func (ag AnalyzerGroup) StaticPaths(disabled []Type) ([]string, bool) {
556556
paths = append(paths, staticPathAnalyzer.StaticPaths()...)
557557
}
558558

559+
// PostAnalyzers don't implement StaticPathAnalyzer.
560+
// So if at least one postAnalyzer is enabled - we should not use StaticPath.
561+
if allPostAnalyzersDisabled := lo.EveryBy(ag.postAnalyzers, func(a PostAnalyzer) bool {
562+
return slices.Contains(disabled, a.Type())
563+
}); !allPostAnalyzersDisabled {
564+
return nil, false
565+
}
566+
559567
// Remove duplicates
560568
return lo.Uniq(paths), true
561569
}

pkg/fanal/artifact/local/fs_test.go

+9
Original file line numberDiff line numberDiff line change
@@ -2485,6 +2485,15 @@ func TestAnalyzerGroup_StaticPaths(t *testing.T) {
24852485
want: []string{},
24862486
wantAllStatic: false,
24872487
},
2488+
{
2489+
name: "only PostAnalyzers are enabled",
2490+
disabledAnalyzers: []analyzer.Type{
2491+
analyzer.TypePip,
2492+
analyzer.TypeSecret,
2493+
},
2494+
want: []string{},
2495+
wantAllStatic: false,
2496+
},
24882497
{
24892498
name: "disable all analyzers",
24902499
disabledAnalyzers: append(analyzer.TypeConfigFiles, analyzer.TypePip, analyzer.TypeApk, analyzer.TypeAlpine, analyzer.TypeSecret),

0 commit comments

Comments
 (0)