gitleaks-action
gitleaks-action copied to clipboard
Failed with Self hosted GitHub Runner
I am using a self-hosted GitHub Runner. But when I run Git Leaks it through error to write and upload artifacts on GitHub
12:23PM DBG 1 commits scanned. Note: this number might be smaller than expected due to commits with no additions
12:23PM INF scan completed in 67.3ms
12:23PM WRN leaks found: 2
Starting artifact upload
For more detailed logs during the artifact upload process, enable step-debugging: https://docs.github.com/actions/monitoring-and-troubleshooting-workflows/enabling-debug-logging#enabling-step-debug-logging
Artifact name is valid!
/runner/_work/_actions/gitleaks/gitleaks-action/v2/dist/index.js:1857
throw new Error(`The rootDirectory: ${rootDirectory} is not a parent directory of the file: ${file}`);
^
Error: The rootDirectory: /home/runner is not a parent directory of the file: /runner/_work/fe-app/fe-app/results.sarif
at Object.getUploadSpecification (/runner/_work/_actions/gitleaks/gitleaks-action/v2/dist/index.js:1857:23)
at DefaultArtifactClient.<anonymous> (/runner/_work/_actions/gitleaks/gitleaks-action/v2/dist/index.js:83:64)
at Generator.next (<anonymous>)
at /runner/_work/_actions/gitleaks/gitleaks-action/v2/dist/index.js:[53](https://github.com/org/fe-app/actions/runs/5999759253/job/16270522345#step:4:54):71
at new Promise (<anonymous>)
at __webpack_modules__.8802.__awaiter (/runner/_work/_actions/gitleaks/gitleaks-action/v2/dist/index.js:49:12)
at DefaultArtifactClient.uploadArtifact (/runner/_work/_actions/gitleaks/gitleaks-action/v2/dist/index.js:78:16)
at Object.Scan (/runner/_work/_actions/gitleaks/gitleaks-action/v2/dist/index.js:70[59](https://github.com/org/fe-app/actions/runs/5999759253/job/16270522345#step:4:60)0:26)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at async start (/runner/_work/_actions/gitleaks/gitleaks-action/v2/dist/index.js:713[63](https://github.com/org/fe-app/actions/runs/5999759253/job/16270522345#step:4:64):16)
Also I am looking for an exit code in case leaks are found to Trigger Slack notifications which I am not able to do so.
GitHub Action Workflow file
name: gitleaks
on:
pull_request:
branches:
- main
- develop
push:
branches:
- main
- develop
jobs:
scan:
permissions:
contents: write
pull-requests: write
checks: write
name: gitleaks
runs-on:
labels: [self-hosted,dev-image-builder]
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- uses: gitleaks/gitleaks-action@v2
id: gitleaks
env:
GITHUB_TOKEN: ${{ secrets.GH_PAT }}
GITLEAKS_LICENSE: ${{ secrets.GITLEAKS_LICENSE}}
- name: Notify Token Detected
if: steps.gitleaks.outputs.exitcode == 1
uses: voxmedia/github-action-slack-notify-build@v1
id: slack-token-notify
with:
channel_id: ${{ secrets.SLACK_CHANNEL_ID }}
status: Token Detected. Check Report at workflow.
color: warning
env:
SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }}
cc @zricethezav
Is there any resolution or workaround 🤔 ^^ 🧑💻?
I am still looking for the same.
You can disabling uploading the artifact by setting GITLEAKS_ENABLE_UPLOAD_ARTIFACT to false like this:
`
runs-on: [self-hosted, linux, build]
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- uses: AdmincontrolAS/gitleaks-action@v2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITLEAKS_LICENSE: ${{ secrets.GITLEAKS_LICENSE}}
GITLEAKS_ENABLE_UPLOAD_ARTIFACT: false
`