Skip to content

Do not analyze language vulns unless the feature is enabled #924

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 9, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 14 additions & 9 deletions worker.go
Original file line number Diff line number Diff line change
Expand Up @@ -227,13 +227,20 @@ func (m *analyzingMatcher) Match(filePath string, fi os.FileInfo, contents io.Re

// DetectContentFromReader detects scanning content in the given reader.
func DetectContentFromReader(reader io.ReadCloser, format, name string, parent *database.Layer, base *tarutil.LayerFiles, uncertifiedRHEL bool) (*database.Namespace, bool, []database.FeatureVersion, *database.RHELv2Components, []*component.Component, *tarutil.LayerFiles, error) {
// Create a "matcher" that actually calls `ProcessFile` on each analyzer, before delegating
// to the actual matcher for operating system-level feature extraction.
// TODO: this is ugly. A matcher should not have side-effects; but the `analyzingMatcher`s
// sole purpose is to have a side effect. The `ExtractFromReader` should be more explicit
// about the matcher not just being a matcher.
// Get the list of language analyzers if language vulnerability is enabled.
var langAnalyzers []analyzer.Analyzer
if env.LanguageVulns.Enabled() {
langAnalyzers = analyzers.Analyzers()
}
// Create a "matcher" that actually calls `ProcessFile` on each analyzer, before
// delegating to the actual matcher for operating system-level feature
// extraction.
//
// TODO: This is ugly. A matcher should not have side-effects; but the `analyzingMatcher`s
// sole purpose is to have a side effect. The `ExtractFromReader` should be more
// explicit about the matcher not just being a matcher.
m := &analyzingMatcher{
analyzers: analyzers.Analyzers(),
analyzers: langAnalyzers,
delegate: requiredfilenames.SingletonMatcher(),
}

Expand All @@ -249,9 +256,7 @@ func DetectContentFromReader(reader io.ReadCloser, format, name string, parent *

namespace, features, rhelv2Components, languageComponents, err := DetectFromFiles(*files, name, parent, m.components, uncertifiedRHEL)
distroless := isDistroless(*files) || (parent != nil && parent.Distroless)
if !env.LanguageVulns.Enabled() {
languageComponents = nil
}

return namespace, distroless, features, rhelv2Components, languageComponents, files, err
}

Expand Down