Skip to content
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

Failed with Self hosted GitHub Runner #125

Open
Dr-DevOps opened this issue Aug 29, 2023 · 3 comments
Open

Failed with Self hosted GitHub Runner #125

Dr-DevOps opened this issue Aug 29, 2023 · 3 comments

Comments

@Dr-DevOps
Copy link

Dr-DevOps commented Aug 29, 2023

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

@jtmilan
Copy link

jtmilan commented Oct 7, 2023

Is there any resolution or workaround 🤔 ^^ 🧑‍💻?

@Dr-DevOps
Copy link
Author

I am still looking for the same.

@sydseter
Copy link

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

`

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

No branches or pull requests

3 participants