Skip to content

Commit

Permalink
fix(SpdxDocumentFile): Ensure to collect issues from external doc refs
Browse files Browse the repository at this point in the history
Before, issues from external document refs, which could not be mapped to
a `packageId`, failed to be added as issue in the ORT result.
Add these missing transitive issues, by explicitly check for any issues
that are not related to known packages.

Signed-off-by: Marcel Bochtler <[email protected]>
  • Loading branch information
MarcelBochtler committed Jul 9, 2024
1 parent 534bd17 commit 2a46c29
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -525,7 +525,7 @@ class SpdxDocumentFile(
scopeDependencies = scopes
)

return listOf(ProjectAnalyzerResult(project, packages))
return listOf(ProjectAnalyzerResult(project, packages, transitiveDocument.getIssuesWithoutSpdxPackage()))
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,18 @@ internal data class SpdxResolvedDocument(
return pkg
}

/**
* Retrieve the issues from [issuesByReferenceId] that are not associated with any package [packagesById]. These
* issues can be related to general issues with the SPDX document.
*/
fun getIssuesWithoutSpdxPackage(): List<Issue> {
return issuesByReferenceId.filterKeys { referenceId ->
packagesById.keys.none { packageId ->
packageId.startsWith("$referenceId:")

Check warning on line 143 in plugins/package-managers/spdx/src/main/kotlin/utils/SpdxResolvedDocument.kt

View check run for this annotation

Codecov / codecov/patch

plugins/package-managers/spdx/src/main/kotlin/utils/SpdxResolvedDocument.kt#L141-L143

Added lines #L141 - L143 were not covered by tests
}
}.values.toList()

Check warning on line 145 in plugins/package-managers/spdx/src/main/kotlin/utils/SpdxResolvedDocument.kt

View check run for this annotation

Codecov / codecov/patch

plugins/package-managers/spdx/src/main/kotlin/utils/SpdxResolvedDocument.kt#L145

Added line #L145 was not covered by tests
}

/**
* Return the local definition file in which the package with the given [identifier] is declared. If the package
* cannot be resolved or if it has not been declared in a local file, return *null*.
Expand Down

0 comments on commit 2a46c29

Please sign in to comment.