Skip to content

Commit e899a18

Browse files
authored
Merge pull request #4 from accuknox/upload_artifact
feat(upload_artifact): upload the scan results to github artifact…
2 parents ffaf492 + d727a24 commit e899a18

File tree

2 files changed

+17
-3
lines changed

2 files changed

+17
-3
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ This GitHub Action scans your repository for secrets and uploads the result to y
2828
| `use_extended_ruleset` | Enable extended regex rules for detecting sensitive data. | Optional | `false` |
2929
| `results` | Specifies which type(s) of results to output: `verified`, `unknown`, `unverified`, `filtered_unverified`. Defaults to all types. | Optional | `all` |
3030
| `fail` | Fail the pipeline if secrets are found. | Optional | `false` |
31+
| `upload_artifact` | Upload scan results as artifact | Optional | `true` |
3132

3233
---
3334

action.yml

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,11 @@ inputs:
7979
description: "Additional arguments to pass."
8080
required: false
8181

82+
upload_artifact:
83+
description: 'Upload the scan results as a GitHub artifact'
84+
required: true
85+
default: 'true'
86+
8287
runs:
8388
using: "composite"
8489
steps:
@@ -166,22 +171,22 @@ runs:
166171
BUCKET_FLAG="--bucket=${{ inputs.bucket_name }}"
167172
fi
168173
169-
docker run --rm -e AWS_ACCESS_KEY_ID="${{ inputs.aws_access_key_id }}" -e AWS_SECRET_ACCESS_KEY="${{ inputs.aws_secret_access_key }}" -e HUGGINGFACE_TOKEN="${{ inputs.huggingface_token }}" -v $PWD/extended_ruleset_path.yml:/extended_ruleset_path.yml -v "$PWD:/pwd" trufflesecurity/trufflehog:3.88.1 $SECRET_SCAN_TYPE --json --no-update $BUCKET_FLAG $DATASET_FLAG $BRANCH_FLAG $RESULTS_FLAG $CONFIG_OPTION $FAIL_FLAG $EXCLUDE_FLAG $EXTRA_ARGS > trufflehog-results.json || exit_code=$?
174+
docker run --rm -e AWS_ACCESS_KEY_ID="${{ inputs.aws_access_key_id }}" -e AWS_SECRET_ACCESS_KEY="${{ inputs.aws_secret_access_key }}" -e HUGGINGFACE_TOKEN="${{ inputs.huggingface_token }}" -v $PWD/extended_ruleset_path.yml:/extended_ruleset_path.yml -v "$PWD:/pwd" trufflesecurity/trufflehog:3.88.1 $SECRET_SCAN_TYPE --json --no-update $BUCKET_FLAG $DATASET_FLAG $BRANCH_FLAG $RESULTS_FLAG $CONFIG_OPTION $FAIL_FLAG $EXCLUDE_FLAG $EXTRA_ARGS > accuknox-secret-scan-results.json || exit_code=$?
170175
171176
echo "TRUFFLEHOG_EXIT_CODE=${exit_code:-0}" >> $GITHUB_ENV
172177
shell: bash
173178

174179
- name: Push report to Control Plane
175180
run: |
176-
if [[ ! -s trufflehog-results.json ]]; then
181+
if [[ ! -s accuknox-secret-scan-results.json ]]; then
177182
echo "No secrets found. Skipping API upload."
178183
exit 0
179184
fi
180185
181186
RESPONSE=$(curl --location 'https://${{ inputs.endpoint }}/api/v1/artifact/?tenant_id=${{ inputs.tenant_id }}&data_type=TruffleHog&save_to_s3=true&label_id=${{ inputs.label }}' \
182187
--header 'Tenant-Id: ${{ inputs.tenant_id }}' \
183188
--header 'Authorization: Bearer ${{ inputs.token }}' \
184-
--form 'file=@./trufflehog-results.json')
189+
--form 'file=@./accuknox-secret-scan-results.json')
185190
186191
echo "Response: $RESPONSE"
187192
if [[ "$RESPONSE" != *"File received successfully"* ]]; then
@@ -190,6 +195,14 @@ runs:
190195
fi
191196
shell: bash
192197

198+
- name: Upload Scan Results as Artifact
199+
if: inputs.upload_artifact == 'true'
200+
uses: actions/upload-artifact@v4
201+
with:
202+
name: scan-results-${{ github.sha }}
203+
path: accuknox-secret-scan-results.json
204+
if-no-files-found: ignore
205+
193206
- name: Quality Check with exit_code
194207
if: env.TRUFFLEHOG_EXIT_CODE == '183'
195208
run: |

0 commit comments

Comments
 (0)