Skip to content
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

Support trivy command and target #5

Merged
merged 3 commits into from
Dec 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ jobs:
id: test
with:
github_token: ${{ secrets.github_token }}
trivy_command: config
trivy_target: .
reporter: github-check
level: info
working_directory: testdata/with_detections
Expand Down Expand Up @@ -60,6 +62,8 @@ jobs:
id: test
with:
github_token: ${{ secrets.github_token }}
trivy_command: config
trivy_target: .
reporter: github-check
level: info
working_directory: testdata/without_detections
Expand Down Expand Up @@ -98,6 +102,8 @@ jobs:
id: test
with:
github_token: ${{ secrets.github_token }}
trivy_command: config
trivy_target: .
reporter: github-pr-check
level: info
working_directory: testdata/with_detections
Expand Down Expand Up @@ -136,6 +142,8 @@ jobs:
id: test
with:
github_token: ${{ secrets.github_token }}
trivy_command: config
trivy_target: .
reporter: github-pr-review
level: info
working_directory: testdata/with_detections
Expand Down Expand Up @@ -179,6 +187,8 @@ jobs:
id: test
with:
github_token: ${{ secrets.github_token }}
trivy_command: config
trivy_target: .
reporter: github-check
level: info
working_directory: testdata/with_detections
Expand Down
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,16 @@ the Pull Request Conversation:

**Required**. Must be in form of `github_token: ${{ secrets.github_token }}`.

### `trivy_command`

**Required**. Trivy command [`aws`, `config`, `filesystem`, `image`, `kubernetes`, `rootfs`, `sbom`, `vm`].
You can see this with `trivy --help`

### `trivy_target`

**Required**. Target to scan.
It's depends on the command. Please check [Trivy Docs](https://aquasecurity.github.io/trivy/latest/docs/)

### `working_directory`

Optional. Directory to run the action on, from the repo root.
Expand Down
10 changes: 10 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,14 @@ inputs:
description: 'Additional reviewdog flags'
default: ''
required: false
trivy_command:
description: |
Trivy command [aws,config,filesystem,image,kubernetes,rootfs,sbom,vm]
required: true
trivy_target:
description: |
Trivy target to scan
required: true
trivy_version:
description: |
The version of trivy to install.
Expand Down Expand Up @@ -88,6 +96,8 @@ runs:
INPUT_FAIL_ON_ERROR: ${{ inputs.fail_on_error }}
INPUT_FLAGS: ${{ inputs.flags }}
INPUT_TRIVY_VERSION: ${{ inputs.trivy_version }}
INPUT_TRIVY_COMMAND: ${{ inputs.trivy_command }}
INPUT_TRIVY_TARGET: ${{ inputs.trivy_target }}
INPUT_TRIVY_FLAGS: ${{ inputs.trivy_flags }}

branding:
Expand Down
2 changes: 1 addition & 1 deletion script.sh
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ echo '::group:: Running trivy with reviewdog 🐶 ...'
set +Eeuo pipefail

# shellcheck disable=SC2086
"${TRIVY_PATH}/trivy" --format json ${INPUT_TRIVY_FLAGS:-} --exit-code 1 config . 2> /dev/null \
"${TRIVY_PATH}/trivy" --format json ${INPUT_TRIVY_FLAGS:-} --exit-code 1 ${INPUT_TRIVY_COMMAND} ${INPUT_TRIVY_TARGET} 2> /dev/null \
| jq -r -f "${GITHUB_ACTION_PATH}/to-rdjson.jq" \
| "${REVIEWDOG_PATH}/reviewdog" -f=rdjson \
-name="${INPUT_TOOL_NAME}" \
Expand Down