Skip to content

Commit d20e000

Browse files
authored
Fix check for snykMonitor and add target-reference option (#44)
* Add fix for snyk monitor command Signed-off-by: Jakub Stejskal <xstejs24@gmail.com> * Simplify monitor cmd for maven Signed-off-by: Jakub Stejskal <xstejs24@gmail.com> * Add testing branch also to integration workflow Signed-off-by: Jakub Stejskal <xstejs24@gmail.com> * Handle container target reference Signed-off-by: Jakub Stejskal <xstejs24@gmail.com> * Add reference param Signed-off-by: Jakub Stejskal <xstejs24@gmail.com> * Revert testing changes Signed-off-by: Jakub Stejskal <xstejs24@gmail.com> * Fix one missing leftover Signed-off-by: Jakub Stejskal <xstejs24@gmail.com> --------- Signed-off-by: Jakub Stejskal <xstejs24@gmail.com>
1 parent 18137f3 commit d20e000

3 files changed

Lines changed: 14 additions & 6 deletions

File tree

.github/actions/security/snyk-container-scan/action.yml

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@ inputs:
1515
projectPrefix:
1616
description: "Project prefix for Snyk dashboard (e.g., 'strimzi')"
1717
required: true
18+
snykMonitorTargetReference:
19+
description: "Value for --target-reference in 'snyk container monitor' (e.g. release version). Defaults to the image tag."
20+
required: false
21+
default: ""
1822
uploadToCodeScanning:
1923
description: "Whether to upload SARIF results to GitHub Code Scanning"
2024
required: false
@@ -89,13 +93,18 @@ runs:
8993

9094
# Monitor command is used for upload snapshot of the scan to Snyk App where Snyk will do daily scans and can generate reports
9195
- name: Run Snyk monitor
92-
if: ${{ inputs.monitor == 'true' }}
96+
if: ${{ inputs.snykMonitor == 'true' }}
9397
shell: bash
9498
continue-on-error: true
99+
env:
100+
TARGET_REFERENCE: ${{ inputs.snykMonitorTargetReference }}
95101
run: |
96102
if [ -n "$LOADED_IMAGE" ]; then
97103
MONITOR_PROJECT="${LOADED_IMAGE%%:*}"
98104
MONITOR_REVISION="${LOADED_IMAGE##*:}"
105+
if [ -n "$TARGET_REFERENCE" ]; then
106+
MONITOR_REVISION="$TARGET_REFERENCE"
107+
fi
99108
snyk container monitor "$LOADED_IMAGE" \
100109
--project-name="$MONITOR_PROJECT" \
101110
--target-reference="$MONITOR_REVISION"

.github/actions/security/snyk-maven-scan/action.yml

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -59,11 +59,8 @@ runs:
5959

6060
# Monitor command is used for upload snapshot of the scan to Snyk App where Snyk will do daily scans and can generate reports
6161
- name: Run Snyk monitor
62-
if: ${{ inputs.monitor == 'true' }}
62+
if: ${{ inputs.snykMonitor == 'true' }}
6363
shell: bash
6464
continue-on-error: true
65-
env:
66-
PROJECT_PREFIX: ${{ inputs.projectPrefix }}
6765
run: |
68-
REPO_NAME="${GITHUB_REPOSITORY##*/}"
69-
snyk monitor --project-name="${PROJECT_PREFIX}/${REPO_NAME}"
66+
snyk monitor --target-reference="${GITHUB_REF_NAME}"

.github/workflows/test-snyk.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,7 @@ jobs:
205205
imageFile: docker-images/container-archives/${{ matrix.image }}.tar.gz
206206
image: ${{ matrix.image }}
207207
snykMonitor: "false"
208+
snykMonitorTargetReference: "latest"
208209
uploadToCodeScanning: "false"
209210
projectPrefix: test-operators
210211
env:
@@ -255,6 +256,7 @@ jobs:
255256
image: drain-cleaner-amd64
256257
# Keep false to avoid uploading testing results to Snyk App
257258
snykMonitor: "false"
259+
snykMonitorTargetReference: "latest"
258260
# Keep false to avoid uploading results to GitHub Code Scanning page
259261
uploadToCodeScanning: "false"
260262
projectPrefix: test-drain-cleaner

0 commit comments

Comments
 (0)