-
Notifications
You must be signed in to change notification settings - Fork 22
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
Create an action for scanning APKs for vulnz #115
Merged
Merged
Changes from all commits
Commits
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 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,40 @@ | ||
name: test-scan-apk | ||
|
||
on: [pull_request] | ||
|
||
jobs: | ||
test-unpinned: | ||
runs-on: ubuntu-latest | ||
permissions: {} | ||
steps: | ||
- uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab # v3.5.2 | ||
- uses: ./scan-apk | ||
id: scan | ||
with: | ||
package: ko | ||
- run: echo ${{ steps.scan.outputs.vuln-count }} | ||
|
||
test-pinned: | ||
runs-on: ubuntu-latest | ||
permissions: {} | ||
steps: | ||
- uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab # v3.5.2 | ||
- uses: ./scan-apk | ||
id: scan | ||
with: | ||
package: ko=0.13.0-r4 | ||
- run: echo ${{ steps.scan.outputs.vuln-count }} | ||
|
||
test-alpine: | ||
runs-on: ubuntu-latest | ||
permissions: {} | ||
steps: | ||
- uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab # v3.5.2 | ||
- uses: ./scan-apk | ||
id: scan | ||
with: | ||
repositories: https://dl-cdn.alpinelinux.org/alpine/edge/main | ||
keyring: "" | ||
package: busybox | ||
- run: echo ${{ steps.scan.outputs.vuln-count }} | ||
|
This file contains 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 |
---|---|---|
|
@@ -163,7 +163,9 @@ runs: | |
APKO_IMAGE="ghcr.io/wolfi-dev/apko:latest" | ||
fi | ||
docker run -i --rm --entrypoint /bin/sh \ | ||
--network host \ | ||
-v $PWD:/github/workspace \ | ||
-v /tmp:/tmp \ | ||
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. To support generated apko configs |
||
--workdir /github/workspace \ | ||
-e "GITHUB_ACTOR=${{ inputs.repository_owner }}" \ | ||
-e "GITHUB_TOKEN=${{ inputs.token }}" \ | ||
|
This file contains 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,14 @@ | ||
# Scan an APK for Vulnerabilities | ||
|
||
This action uses apko to build an ephemeral image and scan it with | ||
[Anchore/Grype](https://github.com/anchore/grype) to identify any | ||
vulnerabilities. | ||
|
||
|
||
## Usage | ||
|
||
```yaml | ||
- uses: chainguard-images/actions/scan-apk@main | ||
with: | ||
package: foo # or foo=1.2.3-r4 | ||
``` |
This file contains 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,82 @@ | ||
# Copyright 2022 The Distroless Authors | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
name: 'Scan APK for vulnerabilities' | ||
description: | | ||
This action scans an APK for vulnerabilities by turning it into an OCI image first. | ||
|
||
inputs: | ||
|
||
repositories: | ||
description: | | ||
A comma-delimited list of APK repositories to include. | ||
required: false | ||
default: https://packages.wolfi.dev/os | ||
|
||
keyring: | ||
description: | | ||
A comma-delimited list of APK keyrings to include. | ||
required: false | ||
default: https://packages.wolfi.dev/os/wolfi-signing.rsa.pub | ||
|
||
package: | ||
description: | | ||
The APK to scan for vulnerabilities. | ||
required: true | ||
|
||
architecture: | ||
description: | | ||
The architecture to scan the package for vulnerabilities. | ||
required: false | ||
default: "x86_64" | ||
|
||
outputs: | ||
vuln-count: | ||
description: Number of vulnerables in Grype scan | ||
value: ${{ steps.scan-report.outputs.vuln-count }} | ||
|
||
runs: | ||
using: composite | ||
steps: | ||
- uses: chainguard-dev/actions/setup-registry@main | ||
with: | ||
port: 1234 | ||
|
||
- shell: bash | ||
id: mkconfig | ||
run: | | ||
TMP=$(mktemp) | ||
|
||
cat > "${TMP}" <<EOF | ||
contents: | ||
repositories: $(echo "${{ inputs.repositories }}" | tr -d '[:space:]' | jq --raw-input -c --slurp 'split(",")') | ||
keyring: $(echo "${{ inputs.keyring }}" | tr -d '[:space:]' | jq --raw-input -c --slurp 'split(",")') | ||
packages: | ||
- ${{ inputs.package }} | ||
|
||
archs: | ||
- ${{ inputs.architecture }} | ||
EOF | ||
|
||
echo "::set-output name=config-file::${TMP}" | ||
|
||
- shell: bash | ||
run: | | ||
cat ${{ steps.mkconfig.outputs.config-file }} | ||
|
||
- uses: ./apko-publish | ||
with: | ||
config: ${{ steps.mkconfig.outputs.config-file }} | ||
tag: localhost:1234/apk-scan | ||
|
||
- id: grype-scan | ||
uses: anchore/scan-action@ecfd0e98932e57ea8f68f29c4f418fc41a8194db | ||
with: | ||
image: localhost:1234/apk-scan | ||
fail-build: false | ||
severity-cutoff: low | ||
|
||
- id: scan-report | ||
shell: bash | ||
run: | | ||
echo "::set-output name=vuln-count::$(cat ${{ steps.grype-scan.outputs.sarif }} | jq '.runs[0].results | length')" |
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.
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.
to support registries on localhost