Skip to content

helper-cli: Fix listing licenses for packages with no scan result #7832

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Nov 9, 2023

Conversation

fviernau
Copy link
Member

@fviernau fviernau commented Nov 9, 2023

See individual commits.

The `ListLicensesCommand` crashes when used for a package with unkown
provenances inside `writeValueAsString()` called from [1], as it passes
an unkown provenance to that function.

Filter out scan results in the first place to avoid running into that
problem.

[1] https://github.com/oss-review-toolkit/ort/blob/f5c556d207b7b3cdbecfb7c8cfb489ba4d5050a4/helper-cli/src/main/kotlin/commands/ListLicensesCommand.kt#L196

Signed-off-by: Frank Viernau <[email protected]>
For packages which do not have a scan result the command just outputs
"scan results:". Change that to a more speaking message.

Signed-off-by: Frank Viernau <[email protected]>
@fviernau fviernau requested a review from a team as a code owner November 9, 2023 10:41
@fviernau fviernau enabled auto-merge (rebase) November 9, 2023 10:41
Copy link

codecov bot commented Nov 9, 2023

Codecov Report

Attention: 3 lines in your changes are missing coverage. Please review.

Comparison is base (dcd3b19) 67.24% compared to head (37f3cf4) 67.23%.
Report is 1 commits behind head on main.

Additional details and impacted files
@@             Coverage Diff              @@
##               main    #7832      +/-   ##
============================================
- Coverage     67.24%   67.23%   -0.01%     
  Complexity     2044     2044              
============================================
  Files           356      356              
  Lines         17050    17053       +3     
  Branches       2439     2440       +1     
============================================
+ Hits          11465    11466       +1     
- Misses         4567     4568       +1     
- Partials       1018     1019       +1     
Flag Coverage Δ
funTest-docker 63.05% <ø> (ø)
funTest-non-docker 37.38% <0.00%> (-0.02%) ⬇️
test 34.94% <0.00%> (-0.02%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files Coverage Δ
...li/src/main/kotlin/commands/ListLicensesCommand.kt 39.54% <0.00%> (-0.69%) ⬇️

... and 1 file with indirect coverage changes

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@fviernau fviernau merged commit 1534d39 into main Nov 9, 2023
@fviernau fviernau deleted the list-licenses-crash-fix branch November 9, 2023 12:47
fviernau added a commit that referenced this pull request Nov 27, 2023
The list licenses command may crash in case `sourceCodeDir` is not
provided in the following scenarios:

1. When the source artifact has been scanned for the given `packageId`
   and `vcsProcessed` is empty, then `fetchScannedSources()` crashes
   withing `Downloader.download()`, because the downloader throws when
   it attempts to download from VCS.
2. When the ORT file does not contain any scan result for the given
   package, then the downloader also throws.

Ensure that the downloader always attempts to download from the right
source code origin, to fix scenario #1. Furthermore, return early in
case there is no scan result for the given package to fix scenario #2.
Recently a similar crash has been fixed by [1] also by returning
earlier. So, move the early return from [1] to an even earlier position.

[1] #7832

Signed-off-by: Frank Viernau <[email protected]>
fviernau added a commit that referenced this pull request Nov 27, 2023
The list licenses command may crash in case `sourceCodeDir` is not
provided in the following scenarios:

1. When the source artifact has been scanned for the given `packageId`
   and `vcsProcessed` is empty, then `fetchScannedSources()` crashes
   withing `Downloader.download()`, because the downloader throws when
   it attempts to download from VCS.
2. When the ORT file does not contain any scan result for the given
   package, then the downloader also throws.

Ensure that the downloader always attempts to download from the right
source code origin, to fix scenario #1. Furthermore, return early in
case there is no scan result for the given package to fix scenario #2.
Recently a similar crash has been fixed by [1] also by returning
earlier. So, move the early return from [1] to an even earlier position.

[1]: #7832

Signed-off-by: Frank Viernau <[email protected]>
fviernau added a commit that referenced this pull request Nov 27, 2023
The list licenses command may crash in case `sourceCodeDir` is not
provided in the following scenarios:

1. When the source artifact has been scanned for the given `packageId`
   and `vcsProcessed` is empty, then `fetchScannedSources()` crashes
   withing `Downloader.download()`, because the downloader throws when
   it attempts to download from VCS.
2. When the ORT file does not contain any scan result for the given
   package, then the downloader also throws.

Ensure that the downloader always attempts to download from the right
source code origin, to fix scenario 1. Furthermore, return early in
case there is no scan result for the given package to fix scenario 2.
Recently a similar crash has been fixed by [1] also by returning
earlier. So, move the early return from [1] to an even earlier position.

[1]: #7832

Signed-off-by: Frank Viernau <[email protected]>
fviernau added a commit that referenced this pull request Nov 28, 2023
The list licenses command may crash in case `sourceCodeDir` is not
provided in the following scenarios:

1. When the source artifact has been scanned for the given `packageId`
   and `vcsProcessed` is empty, then `fetchScannedSources()` crashes
   withing `Downloader.download()`, because the downloader throws when
   it attempts to download from VCS.
2. When the ORT file does not contain any scan result for the given
   package, then the downloader also throws.

Ensure that the downloader always attempts to download from the right
source code origin, to fix scenario 1. Furthermore, return early in
case there is no scan result for the given package to fix scenario 2.
Recently a similar crash has been fixed by [1] also by returning
earlier. So, move the early return from [1] to an even earlier position.

[1]: #7832

Signed-off-by: Frank Viernau <[email protected]>
fviernau added a commit that referenced this pull request Nov 28, 2023
The list licenses command may crash in case `sourceCodeDir` is not
provided in the following scenarios:

1. When the source artifact has been scanned for the given `packageId`
   and `vcsProcessed` is empty, then `fetchScannedSources()` crashes
   withing `Downloader.download()`, because the downloader throws when
   it attempts to download from VCS.
2. When the ORT file does not contain any scan result for the given
   package, then the downloader also throws.

Ensure that the downloader always attempts to download from the right
source code origin, to fix scenario 1. Furthermore, return early in
case there is no scan result for the given package to fix scenario 2.
Recently a similar crash has been fixed by [1] also by returning
earlier. So, move the early return from [1] to an even earlier position.

[1]: #7832

Signed-off-by: Frank Viernau <[email protected]>
fviernau added a commit that referenced this pull request Nov 28, 2023
The list licenses command may crash in case `sourceCodeDir` is not
provided in the following scenarios:

1. When the source artifact has been scanned for the given `packageId`
   and `vcsProcessed` is empty, then `fetchScannedSources()` crashes
   within `Downloader.download()`, because the downloader throws when
   it attempts to download from VCS.
2. When the ORT file does not contain any scan result for the given
   package, then the downloader also throws.

Ensure that the downloader always attempts to download from the right
source code origin, to fix scenario 1. Furthermore, return early in
case there is no scan result for the given package to fix scenario 2.
Recently a similar crash has been fixed by [1] also by returning
earlier. So, move the early return from [1] to an even earlier position.

[1]: #7832

Signed-off-by: Frank Viernau <[email protected]>
fviernau added a commit that referenced this pull request Nov 28, 2023
The list licenses command may crash in case `sourceCodeDir` is not
provided in the following scenarios:

1. When the source artifact has been scanned for the given `packageId`
   and `vcsProcessed` is empty, then `fetchScannedSources()` crashes
   within `Downloader.download()`, because the downloader throws when
   it attempts to download from VCS.
2. When the ORT file does not contain any scan result for the given
   package, then the downloader also throws.

Ensure that the downloader always attempts to download from the right
source code origin, to fix scenario 1. Furthermore, return early in
case there is no scan result for the given package to fix scenario 2.
Recently a similar crash has been fixed by [1] also by returning
earlier. So, move the early return from [1] to an even earlier position.

[1]: #7832

Signed-off-by: Frank Viernau <[email protected]>
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