Skip to content
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

🧹 apply runtime env labels for discovered assets #794

Merged
merged 2 commits into from
Oct 4, 2023
Merged
Changes from 1 commit
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
12 changes: 12 additions & 0 deletions policy/scan/local_scanner.go
Original file line number Diff line number Diff line change
Expand Up @@ -301,9 +301,21 @@ func (s *LocalScanner) distributeJob(job *Job, ctx context.Context, upstream *up
return nil, false, nil
}

runtimeEnv := execruntime.Detect()
var runtimeLabels map[string]string
if runtimeEnv != nil {
runtimeLabels = runtimeEnv.Labels()
}

justAssets := []*inventory.Asset{}
for _, asset := range assets {
asset.asset.KindString = asset.asset.GetPlatform().Kind
for k, v := range runtimeLabels {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we not wanna check if its an automated env before applying all these? (saw that we have that check in v8)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if opts.AutoDetectCICDCategory && runtimeEnv.IsAutomatedEnv() || opts.Category == "cicd" {

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we cannot check this in the same way in this part of the code. I am now checking if the root asset is ci/cd. This should indicate that we are doing a ci/cd scan

if asset.asset.Labels == nil {
asset.asset.Labels = map[string]string{}
}
asset.asset.Labels[k] = v
}
justAssets = append(justAssets, asset.asset)
}

Expand Down