Skip to content

Removing hardcoded options in GHA docker run and providing output configuration #4068

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

Open
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

kellydunn
Copy link

@kellydunn kellydunn commented Apr 18, 2025

Description:

When using the trufflesecurity/trufflehog Github Action, there's currently no way to configure --fail, in the Github action itself, as it is hardcoded in action.yml here.

Additionally, it's helpful to be able to take the very useful output of trufflehog and process it in our own actions so we can aggregate the data to our observability tools. To enable this, this PR also provides an output block that enables developers to reference Trufflehog output in their actions via ${{ steps.trufflehog.outputs.results }}

This way, developers can run the github action like so:

      - name: Run Trufflehog
        id: trufflehog
        uses: trufflesecurity/trufflehog@main
        with:
          base: <base>
          head: <head>
          no_fail: "true"
          extra_args: "--json --results=verified,unknown"
          
      - name: Use Output
        id: use-output
        run: |
          echo ${{ steps.trufflehog.outputs.results }} | jq -s | ./bin/script

Update: This PR now also includes a more explicit mounting of ${{ github.workspace }} to the docker container, as before the relative path being mounted to /tmp wouldn't pick up any changes when providing commit ranges to the scan.

Checklist:

  • Tests passing (make test-community)?
  • Lint passing (make lint this requires golangci-lint)?

@kellydunn kellydunn requested a review from a team as a code owner April 18, 2025 01:20
@CLAassistant
Copy link

CLAassistant commented Apr 18, 2025

CLA assistant check
All committers have signed the CLA.

@kashifkhan0771
Copy link
Contributor

Hi @kellydunn Thanks for submitting the PR. Can you please sign the CLA.

action.yml Outdated
ghcr.io/trufflesecurity/trufflehog:${VERSION} \
git file:///tmp/ \
--since-commit \
${BASE:-''} \
--branch \
${HEAD:-''} \
--fail \
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @kellydunn, thanks for this! This definitely looks like a really useful feature for workflows integrating this action.

One question, particularly about the removal of the --fail argument. Does this change alter the expected behavior of the workflow, i.e. fail and exit with a 183 code if a secret is detected (ref)? If so, this may impact any setups that rely on this failure behavior as a guardrail.

Would it make sense to make this behavior configurable, i.e. fail by default, unless explicitly disabled?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello! And fair question! I could see how this might impact workflows that rely on default fail behavior; explicitly opt-ing out of --fail seems reasonable. I'll take a swing at providing a GHA input control similar to base and head parameters in the workflow.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@nabeelalam, just pushed up 6d2c6cc. We've tested this with our setup, and we can confirm that by default this will preserve the behavior of exiting with 183 unless a user explicitly provides a no_fail value in their workflow action. Lmk what you think.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@nabeelalam Checking in here, anything else you'd like to see? Mind giving the updates a review?

@kellydunn kellydunn force-pushed the gha-fix branch 2 times, most recently from e194d8f to c00a72c Compare June 9, 2025 19:07
…figuration

outputting results

outputting results

outputting results

outputting results

outputting results

outputting results

outputting results

Attempting to mount github workspace for commit scans

Adding back in hardcoded options, but electing to use GHA vars

Adding in explicit no_fail input and check

Removing conditional break
@kellydunn kellydunn requested a review from nabeelalam June 26, 2025 18:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants