Skip to content

Commit

Permalink
feat(sbom): Send results within the entrypoint.sh
Browse files Browse the repository at this point in the history
  • Loading branch information
simar7 committed Jun 20, 2022
1 parent dbb62d8 commit 6f9d699
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
4 changes: 4 additions & 0 deletions action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,9 @@ inputs:
artifact-type:
description: 'input artifact type (image, fs, repo, archive) for SBOM generation'
required: false
github-pat:
description: 'GitHub Personal Access Token (PAT) needed if submitting SBOM to GitHub Dependency Snapshot API'
required: false

runs:
using: 'docker'
Expand All @@ -108,3 +111,4 @@ runs:
- '-s ${{ inputs.security-checks }}'
- '-t ${{ inputs.trivyignores }}'
- '-u ${{ inputs.artifact-type }}'
- '-v ${{ inputs.github-pat }}'
10 changes: 9 additions & 1 deletion entrypoint.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash
set -e
while getopts "a:b:c:d:e:f:g:h:i:j:k:l:m:n:o:p:q:r:s:t:u:" o; do
while getopts "a:b:c:d:e:f:g:h:i:j:k:l:m:n:o:p:q:r:s:t:u:v:" o; do
case "${o}" in
a)
export scanType=${OPTARG}
Expand Down Expand Up @@ -65,6 +65,9 @@ while getopts "a:b:c:d:e:f:g:h:i:j:k:l:m:n:o:p:q:r:s:t:u:" o; do
u)
export artifactType=${OPTARG}
;;
v)
export githubPAT=${OPTARG}
;;
esac
done

Expand Down Expand Up @@ -172,4 +175,9 @@ if [[ "${format}" == "sarif" ]]; then
trivy --quiet ${scanType} --format sarif --output ${output} $SARIF_ARGS ${artifactRef}
fi

if [[ "${format}" == "github" ]]; then
echo "Uploading GitHub Dependency Snapshot"
curl -u "${githubPAT}" -H 'Content-Type: application/json' 'https://api.github.com/repos/'$GITHUB_REPOSITORY'/dependency-graph/snapshots' -d @./dependency-results.sbom.json
fi

exit $returnCode

0 comments on commit 6f9d699

Please sign in to comment.