Skip to content

chore: fix transitive dependencies being marked as directly upgradable#582

Merged
PeterSchafer merged 5 commits intomainfrom
chore/CLI-1375_ufm_remediation_for_direct_dependencies
Apr 17, 2026
Merged

chore: fix transitive dependencies being marked as directly upgradable#582
PeterSchafer merged 5 commits intomainfrom
chore/CLI-1375_ufm_remediation_for_direct_dependencies

Conversation

@CatalinSnyk
Copy link
Copy Markdown
Contributor

@CatalinSnyk CatalinSnyk commented Apr 8, 2026

Description

In certain cases the Remediation Summary would count transitive dependency upgrades as directly upgradable. This would results in incorrect upgrade advice (e.g. Upgrade from x@1.2.3 to x@1.2.3 - since the actual upgrade would be inside for a nested dependency).

The changes should allign the remediation summary building with the legacy implementation that can be found here. In terms of tests, I added a few more cases to the remedation testing logic to get the coverage to 85%, but I also slightly updated the testresults_cli.json to the newer TestAPI structure in order to add it as a test case for the human readable output.

Checklist

  • Tests added and all succeed (make test)
  • Regenerated mocks, etc. (make generate)
  • Linted (make lint)
  • Test your changes work for the CLI

@snyk-io
Copy link
Copy Markdown

snyk-io bot commented Apr 8, 2026

Snyk checks have passed. No issues have been found so far.

Status Scan Engine Critical High Medium Low Total (0)
Open Source Security 0 0 0 0 0 issues
Licenses 0 0 0 0 0 issues
Code Security 0 0 0 0 0 issues

💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse.

@snyk-io
Copy link
Copy Markdown

snyk-io bot commented Apr 8, 2026

Snyk checks have passed. No issues have been found so far.

Status Scan Engine Critical High Medium Low Total (0)
Open Source Security 0 0 0 0 0 issues
Licenses 0 0 0 0 0 issues
Code Security 0 0 0 0 0 issues

💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse.

@CatalinSnyk CatalinSnyk force-pushed the chore/CLI-1375_ufm_remediation_for_direct_dependencies branch from 7675487 to 91c0e0c Compare April 9, 2026 09:54
@CatalinSnyk CatalinSnyk changed the title chore: ensure transitive dependencies are not presented as directly upgradable in the remediation summary chore: ensure transitive dependencies are not directly upgradable in the remediation summary Apr 9, 2026
@CatalinSnyk CatalinSnyk changed the title chore: ensure transitive dependencies are not directly upgradable in the remediation summary chore: fix transitive dependencies being marked as directly upgradable Apr 9, 2026
matchedPaths++
fromPkg := depPath[1]
toPkg := upgradePath.DependencyPath[1]

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This is the main fix to ensure transitive dependency upgrades are not reported as directly upgradable.

@CatalinSnyk CatalinSnyk marked this pull request as ready for review April 9, 2026 12:45
@CatalinSnyk CatalinSnyk requested review from a team as code owners April 9, 2026 12:45
@snyk-pr-review-bot

This comment has been minimized.

}

// Filter out unresolved issues that are already covered by a pin.
summary.Unresolved = filterUnresolvedCoveredByPins(summary.Unresolved, summary.Pins)
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Added this to match the logic in the legacy implementation. I didn't add another fixture file in this PR, but I left an action items for adding a Python project one in CLI-1349, and settled for just a unit test case for now.

@CatalinSnyk CatalinSnyk force-pushed the chore/CLI-1375_ufm_remediation_for_direct_dependencies branch from 91c0e0c to b713ca0 Compare April 17, 2026 11:21
@CatalinSnyk CatalinSnyk requested review from a team as code owners April 17, 2026 11:21
@snyk-pr-review-bot

This comment has been minimized.

@snyk-pr-review-bot

This comment has been minimized.

if pinnedIssueIDs[issue.GetID()] {
continue
}
filtered = append(filtered, issue)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggestion: It seems that none of the test cases covers the case that something isn't filtered. Let's add this, maybe to one of the existing cases.

@snyk-pr-review-bot
Copy link
Copy Markdown

PR Reviewer Guide 🔍

🧪 PR contains tests
🔒 No security concerns identified
⚡ Recommended focus areas for review

Partial Remediations Possibly Lost 🟡 [minor]

In processUpgradeAdvice, when an upgrade is skipped because it is transitive-only (line 187), the matchedPaths counter is not incremented. If an issue has multiple paths where some are direct upgrades and some are transitive-only, the logic on lines 205-206 might incorrectly categorize the overall remediation status as partially resolved or unresolved based on the outcome field, even if the primary direct upgrades were successful.

if fromPkg.Name == toPkg.Name && fromPkg.Version == toPkg.Version {
	continue
}

matchedPaths++
📚 Repository Context Analyzed

This review considered 11 relevant code sections from 7 files (average relevance: 0.89)

@PeterSchafer PeterSchafer merged commit 00def3e into main Apr 17, 2026
13 checks passed
@PeterSchafer PeterSchafer deleted the chore/CLI-1375_ufm_remediation_for_direct_dependencies branch April 17, 2026 13:37
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