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 15, 2024
1 parent cd46518 commit 6999b77
Show file tree
Hide file tree
Showing 2 changed files with 11 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,16 @@ 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 ->

Check warning on line 141 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

Added line #L141 was not covered by tests
packagesById[referenceId] == null
}.values.toList()

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#L143

Added line #L143 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 6999b77

Please sign in to comment.