Skip to content
Open
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
27 changes: 24 additions & 3 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ inputs:
head:
description: Scan commits until here (usually dev branch).
required: false
no_fail:
description: When set, trufflehog does not exit with a 183 code when a credential is found.
required: false
default: ''
extra_args:
default: ""
description: Extra args to be passed to the trufflehog cli.
Expand All @@ -22,6 +26,10 @@ inputs:
default: "latest"
description: Scan with this trufflehog cli version.
required: false
outputs:
results:
description: "Trufflehog scan outputs"
value: ${{ steps.trufflehog.outputs.results }}
branding:
icon: "shield"
color: "green"
Expand All @@ -30,13 +38,15 @@ runs:
using: "composite"
steps:
- shell: bash
id: trufflehog
working-directory: ${{ inputs.path }}
env:
BASE: ${{ inputs.base }}
HEAD: ${{ inputs.head }}
ARGS: ${{ inputs.extra_args }}
COMMIT_IDS: ${{ toJson(github.event.commits.*.id) }}
VERSION: ${{ inputs.version }}
NO_FAIL: ${{ inputs.no_fail }}
run: |
##########################################
## ADVANCED USAGE ##
Expand Down Expand Up @@ -90,17 +100,28 @@ runs:
HEAD=${{github.event.pull_request.head.sha}}
fi
fi

##########################################
## Determine additional args ##
##########################################
if [ -n "$NO_FAIL" ]; then
FAIL=""
else
FAIL="--fail"
fi

##########################################
## Run TruffleHog ##
##########################################
docker run --rm -v .:/tmp -w /tmp \
results=$(docker run --rm -v ${{ github.workspace }}:/tmp -w /tmp \
ghcr.io/trufflesecurity/trufflehog:${VERSION} \
git file:///tmp/ \
--since-commit \
${BASE:-''} \
--branch \
${HEAD:-''} \
--fail \
${FAIL} \
--no-update \
--github-actions \
${ARGS:-''}
${ARGS:-''})
echo "results='$(echo $results)'" >> $GITHUB_OUTPUT