|
| 1 | +name: TruffleHog Secrets Scan |
| 2 | +on: |
| 3 | + push: |
| 4 | + branches: |
| 5 | + - master |
| 6 | + pull_request: |
| 7 | + branches: |
| 8 | + - master |
| 9 | + schedule: |
| 10 | + - cron: '0 4 * * *' |
| 11 | + |
| 12 | +permissions: |
| 13 | + actions: write # Needed for skip-duplicate-jobs job |
| 14 | + contents: read |
| 15 | + |
| 16 | +jobs: |
| 17 | + # Special job which automatically cancels old runs for the same branch, prevents runs for the |
| 18 | + # same file set which has already passed, etc. |
| 19 | + pre_job: |
| 20 | + name: Skip Duplicate Jobs Pre Job |
| 21 | + runs-on: ubuntu-latest |
| 22 | + outputs: |
| 23 | + should_skip: ${{ steps.skip_check.outputs.should_skip }} |
| 24 | + steps: |
| 25 | + - id: skip_check |
| 26 | + uses: fkirc/skip-duplicate-actions@12aca0a884f6137d619d6a8a09fcc3406ced5281 # v5.3.0 |
| 27 | + with: |
| 28 | + cancel_others: 'true' |
| 29 | + github_token: ${{ github.token }} |
| 30 | + |
| 31 | + TruffleHog: |
| 32 | + runs-on: ubuntu-latest |
| 33 | + needs: pre_job |
| 34 | + if: ${{ needs.pre_job.outputs.should_skip != 'true' || github.ref_name == 'main' }} |
| 35 | + |
| 36 | + steps: |
| 37 | + - name: Checkout code |
| 38 | + uses: actions/checkout@v3 |
| 39 | + with: |
| 40 | + fetch-depth: 0 |
| 41 | + |
| 42 | + - name: scan-pr |
| 43 | + uses: trufflesecurity/trufflehog@main |
| 44 | + if: ${{ github.event_name == 'pull_request' }} |
| 45 | + with: |
| 46 | + path: ./ |
| 47 | + base: ${{ github.event.repository.default_branch }} |
| 48 | + head: HEAD |
| 49 | + extra_args: --debug --only-verified |
| 50 | + --exclude-paths=${{ inputs.exclude-paths }} |
| 51 | + |
| 52 | + - name: scan-push |
| 53 | + uses: trufflesecurity/trufflehog@main |
| 54 | + if: ${{ github.event_name == 'push' }} |
| 55 | + with: |
| 56 | + path: ./ |
| 57 | + base: "" |
| 58 | + head: ${{ github.ref_name }} |
| 59 | + extra_args: --debug --only-verified |
| 60 | + |
| 61 | + # As part of cron trigger we scan the whole repo directory. |
| 62 | + # NOTE: Since trufflehog GHA is meant to be used in context of push / pr it can't be |
| 63 | + # used dorectly to scan the whole repo directory. This may take a while, but it's good idea |
| 64 | + # to run it on a daily basis. |
| 65 | + - name: scan-cron |
| 66 | + if: ${{ github.event_name == 'schedule' }} |
| 67 | + run: | |
| 68 | + docker run --rm -v "$PWD:/workdir" trufflesecurity/trufflehog:latest git \ |
| 69 | + file:///workdir --fail --no-update --debug --only-verified |
| 70 | +
|
| 71 | + - name: Notify Slack on Failure |
| 72 | + if: ${{ failure() && github.ref_name == 'master' }} |
| 73 | + uses: act10ns/slack@ed1309ab9862e57e9e583e51c7889486b9a00b0f # v2.0.0 |
| 74 | + env: |
| 75 | + SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} |
| 76 | + with: |
| 77 | + status: ${{ job.status }} |
| 78 | + steps: ${{ toJson(steps) }} |
| 79 | + channel: '#eng-dataset-o11y' |
0 commit comments