mirror of
https://github.com/anchore/syft.git
synced 2026-11-05 00:46:38 +01:00
fix: return empty string if dereferncing pom var fails (#2797)
Previously, Syft would attempt to dereference pom variables, but if it
detected a cycle or failed to get back to a non-variable value, it would
return the last variable. Instead, return an empty string. Otherwise,
certain jars will have versions like "${project.version}" in the SBOM,
which is not helpful.
Signed-off-by: Will Murphy <will.murphy@anchore.com>
This commit is contained in:
@@ -236,7 +236,11 @@ func resolveProperty(pom gopom.Project, property *string, propertyName string) s
|
||||
seenBeforePropertyNames := map[string]struct{}{
|
||||
propertyName: {},
|
||||
}
|
||||
return recursiveResolveProperty(pom, propertyCase, seenBeforePropertyNames)
|
||||
result := recursiveResolveProperty(pom, propertyCase, seenBeforePropertyNames)
|
||||
if propertyMatcher.MatchString(result) {
|
||||
return "" // dereferencing variable failed; fall back to empty string
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
//nolint:gocognit
|
||||
|
||||
Reference in New Issue
Block a user