-
Notifications
You must be signed in to change notification settings - Fork 0
fix(osv): keep base scan results across fork checkout #1257
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
Open
seonghobae
wants to merge
7
commits into
main
Choose a base branch
from
fix/osv-preserve-base-results-runner-temp
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+236
−17
Open
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
2c82c36
fix(osv): keep base scan results across fork checkout
seonghobae 96ef882
fix(osv): restore captured scan output without root overwrite
seonghobae 19a9bc0
fix(osv): transfer root-owned results safely
seonghobae 8800253
refactor(osv): keep base capture external
seonghobae 7b8fc20
fix(osv): upload runner-owned debug captures
seonghobae 20d72bc
fix(osv): remove planted result paths robustly
seonghobae 83ad98e
Merge remote-tracking branch 'origin/main' into fix/osv-preserve-base…
claude File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -87,6 +87,10 @@ jobs: | |
| exit 1 | ||
| fi | ||
| echo "SECURITY_CHECKOUT scanner=osv revision=base repository=${EXPECTED_CHECKOUT_REPOSITORY} expected_sha=${EXPECTED_CHECKOUT_SHA} actual_sha=${actual_sha}" | ||
| - name: Discard checkout-provided OSV result files | ||
| run: | | ||
| set -euo pipefail | ||
| rm -rf -- source/old-results.json source/new-results.json | ||
| - name: Scan base with OSV | ||
| id: osv_base | ||
| continue-on-error: true | ||
|
|
@@ -118,6 +122,23 @@ jobs: | |
| --allow-no-lockfiles | ||
| -r | ||
| source/ | ||
|
seonghobae marked this conversation as resolved.
|
||
| - name: Preserve base OSV output outside the checkout path | ||
| run: | | ||
| set -euo pipefail | ||
| dest="${RUNNER_TEMP}/osv-old-results.json" | ||
| rm -f "${dest}" | ||
| umask 077 | ||
| for candidate in old-results.json source/old-results.json; do | ||
| if [ -f "${candidate}" ] && [ ! -L "${candidate}" ] && [ -s "${candidate}" ]; then | ||
| /usr/bin/sudo --non-interactive /usr/bin/cat -- "${candidate}" | /usr/bin/tee "${dest}" >/dev/null | ||
|
seonghobae marked this conversation as resolved.
|
||
| test -s "${dest}" | ||
| test -O "${dest}" | ||
| echo "Preserved OSV base output from ${candidate}" | ||
|
Comment on lines
+130
to
+136
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
| exit 0 | ||
| fi | ||
| done | ||
|
Comment on lines
+128
to
+139
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
| echo "::error::OSV base output was not present after the base scan steps." | ||
| exit 1 | ||
|
seonghobae marked this conversation as resolved.
|
||
| - name: Checkout head | ||
| uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 | ||
| with: | ||
|
|
@@ -138,6 +159,10 @@ jobs: | |
| exit 1 | ||
| fi | ||
| echo "SECURITY_CHECKOUT scanner=osv revision=head repository=${EXPECTED_CHECKOUT_REPOSITORY} expected_sha=${EXPECTED_CHECKOUT_SHA} actual_sha=${actual_sha}" | ||
| - name: Discard checkout-provided OSV result files | ||
| run: | | ||
| set -euo pipefail | ||
| rm -rf -- source/old-results.json source/new-results.json | ||
| - name: Scan head with OSV | ||
| id: osv_head | ||
| continue-on-error: true | ||
|
|
@@ -169,11 +194,33 @@ jobs: | |
| --allow-no-lockfiles | ||
| -r | ||
| source/ | ||
| - name: Capture head OSV output outside the checkout path | ||
| run: | | ||
| set -euo pipefail | ||
| dest="${RUNNER_TEMP}/osv-new-results.json" | ||
| rm -f "${dest}" | ||
| umask 077 | ||
| for candidate in new-results.json source/new-results.json; do | ||
| if [ -f "${candidate}" ] && [ ! -L "${candidate}" ] && [ -s "${candidate}" ]; then | ||
| /usr/bin/sudo --non-interactive /usr/bin/cat -- "${candidate}" | /usr/bin/tee "${dest}" >/dev/null | ||
| test -s "${dest}" | ||
| test -O "${dest}" | ||
| echo "Captured OSV head output from ${candidate}" | ||
| exit 0 | ||
| fi | ||
| done | ||
| echo "::error::OSV head output was not present after the head scan steps." | ||
| exit 1 | ||
| - name: Require OSV scan output | ||
| run: | | ||
| set -euo pipefail | ||
| test -s old-results.json | ||
| test -s new-results.json | ||
| old="${RUNNER_TEMP}/osv-old-results.json" | ||
| new="${RUNNER_TEMP}/osv-new-results.json" | ||
| test -s "${old}" | ||
| test -s "${new}" | ||
| rm -f old-results.json new-results.json | ||
| cp "${old}" old-results.json | ||
| cp "${new}" new-results.json | ||
|
seonghobae marked this conversation as resolved.
seonghobae marked this conversation as resolved.
Comment on lines
+217
to
+223
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
| - name: Print OSV findings being compared | ||
| shell: python3 {0} | ||
| run: | | ||
|
|
@@ -270,8 +317,8 @@ jobs: | |
| with: | ||
| name: osv-scan-debug | ||
| path: | | ||
| old-results.json | ||
| new-results.json | ||
| ${{ runner.temp }}/osv-old-results.json | ||
| ${{ runner.temp }}/osv-new-results.json | ||
| results.sarif | ||
| if-no-files-found: ignore | ||
| retention-days: 5 | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.