Skip to content

fix: use correct identity of replaced Go modules#6489

Draft
mcombuechen wants to merge 1 commit intomainfrom
fix/OSM-3510-go-replace-modules
Draft

fix: use correct identity of replaced Go modules#6489
mcombuechen wants to merge 1 commit intomainfrom
fix/OSM-3510-go-replace-modules

Conversation

@mcombuechen
Copy link
Contributor

When using the replace directive in go.mod projects and replacing a dependency with a fork (i.e. module name differs), Snyk would still use the original module's name during analysis. This changes the dependencies name to that of the replaced module.

The actual fix was done in snyk/snyk-go-plugin@3c75e60.
Also, this change re-introduces purl generation on the plugin level. For added safety, tests in the Go plugin as well as in this repo were added.

@mcombuechen mcombuechen requested review from a team as code owners January 29, 2026 16:52
@mcombuechen mcombuechen force-pushed the fix/OSM-3510-go-replace-modules branch 2 times, most recently from a1fc639 to a419ddf Compare February 3, 2026 10:28
When using the `replace` directive in go.mod projects and replacing a dependency with a fork (i.e. module name differs), Snyk would still use the original module's name during analysis. This changes the dependencies name to that of the replaced module.
@mcombuechen mcombuechen force-pushed the fix/OSM-3510-go-replace-modules branch from a419ddf to cf2b094 Compare February 3, 2026 10:28
@mcombuechen mcombuechen marked this pull request as draft February 4, 2026 08:55
@mcombuechen
Copy link
Contributor Author

Temporarily converting to draft, as I am making another change (putting purl generation behind feature flag).

// Used only with the Go plugin. When enabled, includes PackageURL information in dep-graphs.
includePackageUrls?: boolean;
// Used only with the Go plugin and temporary. When enabled, fixes misidentification of replaced modules.
useReplaceName?: boolean;
Copy link
Contributor

Choose a reason for hiding this comment

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

question: Used only with the Go plugin and temporary., what's meant by temporary? Do we intend to remove this at some point? If so, how are we going to ensure/track that this will be removed?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We mainly put this behind a flag for the time of the rollout. We introduced a fix to our Golang dependency discovery, which is fine to be rolled out in the CLI asap, but we need to throttle it for SCM (imported repos) which are subject to nightly recurring tests. We have tickets for the rollout and a task to clean this up once the rollout is complete.

I was hoping to add more information and context through this comment, but it seems like it caused more confusion. 😅

Copy link
Contributor

Choose a reason for hiding this comment

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

suggestion: I think a simple TODO: remove once <ticket-ID> is done and a reference to the TODO in the relevant ticket should suffice. WDYT?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants