Skip to content
Open
Show file tree
Hide file tree
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: 5 additions & 4 deletions infrastructure/oss/unified_converter.go
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@ func buildRemediationAdvice(
upgradePath[1] == dependencyPath[1]

// Match Legacy logic: check IsUpgradable
// IsUpgradable = len(vuln.InitiallyFixedInVersions) > 0
// IsUpgradable = len(problem.InitiallyFixedInVersions) > 0
// Note: IsPatchable is always false in unified workflow (patches not supported)
isUpgradable := len(problem.InitiallyFixedInVersions) > 0

Expand All @@ -315,8 +315,9 @@ func buildRemediationAdvice(
return buildOutdatedDependencyMessage(problem.PackageName, actualVersion, ecosystemStr)
}
// Return upgrade message when available
// Note: if isUpgradable but upgradeMessage is empty, we return empty string
// but that case should be rare since upgradePath is built from InitiallyFixedInVersions
// Note: if isUpgradable but upgradeMessage is empty (fix exists but no upgrade path available),
// we return empty string. This is common for deep transitive dependencies where intermediate
// packages haven't consumed the fixed version yet.
return upgradeMessage
}

Expand Down Expand Up @@ -382,7 +383,7 @@ func extractUpgradePackage(dependencyPath []string, finding *testapi.FindingData
return nil
}

if len(dependencyPath) == 0 {
if len(dependencyPath) < 2 {
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.

high

The change from len(dependencyPath) == 0 to len(dependencyPath) < 2 is a critical improvement. Accessing dependencyPath[1] when the slice has fewer than two elements would lead to a runtime panic. This fix correctly handles cases where the dependency path is empty or contains only a single element, preventing potential crashes.

return nil
}
depPathPackageName := strings.Split(dependencyPath[1], "@")[0]
Expand Down
Loading
Loading