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

fix(sca): Correctly check for existing Ruby runtime dependency #1387

Merged
merged 1 commit into from
Jul 19, 2024
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
9 changes: 7 additions & 2 deletions pkg/sca/sca.go
Original file line number Diff line number Diff line change
Expand Up @@ -607,7 +607,7 @@ func generateRubyDeps(ctx context.Context, hdl SCAHandle, generated *config.Depe
}

// This takes the X.Y part of the ruby/gems/X.Y.Z directory name as the version to pin against.
// If the X.Y part is not present, then rubyModuleVer will remain an empty string and
// If the X.Y part is not present, then rubyGemVer will remain an empty string and
// no dependency will be generated.
rubyGemVer = basename[:3]
return nil
Expand All @@ -622,10 +622,15 @@ func generateRubyDeps(ctx context.Context, hdl SCAHandle, generated *config.Depe

// Do not add a Ruby dependency if one already exists.
for _, dep := range hdl.BaseDependencies().Runtime {
if strings.HasPrefix(dep, "ruby") {
if strings.HasPrefix(dep, "ruby-") {
log.Warnf("%s: Ruby dependency %q already specified, consider removing it in favor of SCA-generated dependency", hdl.PackageName(), dep)
return nil
}

if dep == "ruby" {
log.Warnf("%s: Ruby dependency already specified", hdl.PackageName())
return nil
}
}

log.Infof(" found ruby gem, generating ruby-%s dependency", rubyGemVer)
Expand Down
Loading