forked from ubuntu-robotics/snap_workflows
-
Notifications
You must be signed in to change notification settings - Fork 2
feat(cve-check): check for cves #10
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
Guillaumebeuzeboc
wants to merge
9
commits into
main
Choose a base branch
from
feature/cve-check
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.
Open
Changes from 5 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
5b9908c
feat(cve-check): check for cves
Guillaumebeuzeboc c5238b4
readme: add cves-check to the readme
Guillaumebeuzeboc ed48532
fix readme
Guillaumebeuzeboc d28c929
fix: alphabetic order for inputs and outputs
Guillaumebeuzeboc e14c2e4
fix: pr comments
Guillaumebeuzeboc 9479c75
fix: rename cves-found into has-cves
Guillaumebeuzeboc 5ac2838
fix(cves-check): rename input from snap-name to snap
Guillaumebeuzeboc 7be27ac
typo
Guillaumebeuzeboc bc04da8
Merge branch 'main' into feature/cve-check
Guillaumebeuzeboc 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 |
|---|---|---|
| @@ -0,0 +1,69 @@ | ||
| name: Check for CVE in a snap | ||
|
|
||
| on: | ||
| workflow_call: | ||
| inputs: | ||
| channel: | ||
| default: "latest/stable" | ||
| description: The channel of the snap to scan. | ||
| required: false | ||
| type: string | ||
| runs-on: | ||
| default: 'ubuntu-latest' | ||
| description: The runner(s) to use. | ||
| required: false | ||
| type: string | ||
| snap-name: | ||
Guillaumebeuzeboc marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| description: The name of the snap to scan. | ||
| required: true | ||
| type: string | ||
| outputs: | ||
| cves-dict: | ||
Guillaumebeuzeboc marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| description: "The dictionary of found CVEs." | ||
| value: ${{ jobs.CVE-scan.outputs.cves-dict }} | ||
| cves-found: | ||
| description: "Whether CVEs were found or not. Returns `true` or `false`." | ||
| value: ${{ jobs.CVE-scan.outputs.cves-found }} | ||
|
|
||
|
|
||
| jobs: | ||
| prepare-scan-runners: | ||
| runs-on: ubuntu-latest | ||
| outputs: | ||
| runs-on: ${{ steps.string-to-json.outputs.json }} | ||
| steps: | ||
| - name: String to JSON list | ||
| id: string-to-json | ||
| uses: canonical/robotics-actions-workflows/string-to-json@main | ||
| with: | ||
| string: ${{ inputs.runs-on }} | ||
|
|
||
| CVE-scan: | ||
| name: CVEs scan | ||
| needs: [prepare-scan-runners] | ||
| runs-on: ${{ matrix.runs-on }} | ||
| strategy: | ||
| fail-fast: false | ||
| matrix: | ||
| runs-on: ${{ fromJSON(needs.prepare-scan-runners.outputs.runs-on) }} | ||
| outputs: | ||
| cves-found: ${{ steps.check_notice.outputs.cves_found }} | ||
Guillaumebeuzeboc marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| cves-dict: ${{ steps.check_notice.outputs.cves_dict }} | ||
| steps: | ||
| - name: Install review-tools | ||
| run: sudo snap install review-tools | ||
| - name: Dowload the sap file | ||
Guillaumebeuzeboc marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| run: snap download ${{ inputs.snap-name }} --channel=${{ inputs.channel }} | ||
| - name: Check notices | ||
| id: check_notice | ||
| run: | | ||
| CVES_DICT=$(review-tools.check-notices ${{ inputs.snap-name }}_*.snap | jq -c '."${{ inputs.snap-name }}" | . []') | ||
| RESULT=$(echo $CVES_DICT | jq -r 'length >0') | ||
| if [[ "$RESULT" == "true" ]]; then | ||
| echo "The snap ${{ inputs.snap-name }} contains known CVEs!" | ||
| echo "The following CVEs are detected in your package: ${CVES_DICT}" | ||
| else | ||
| echo "No known CVEs found." | ||
| fi | ||
| echo "cves_found=${RESULT}" >> $GITHUB_OUTPUT | ||
| echo "cves_dict=${CVES_DICT}" >> $GITHUB_OUTPUT | ||
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
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we need to specify a runner? Can't we run an amd64
review-toolssnaps on an arm64 snap? Can we download an arm64 snap file on an amd64 machine?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't find a way to specify the arch from the
snap downloadcommand. This means thatsnap downloaddownload the snap from the architecture of the host.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.