From 28066620723bdb4ed24edcb6b51df289ad53703b Mon Sep 17 00:00:00 2001 From: PrimeBuild-pc Date: Wed, 15 Apr 2026 23:47:18 +0200 Subject: [PATCH] Use RUNNER_TEMP for gitleaks and add flags Download and extract gitleaks into a temporary RUNNER_TEMP directory ($toolDir) and remove any existing copy before extraction. Adjust Expand-Archive/tar commands to use $toolDir and resolve the executable from that path. Add a step to remove vendored tool docs from the scan scope to avoid known false positives. Run gitleaks with --no-git and --exit-code 1 so the scan targets the working tree and fails the job on findings. --- .github/workflows/ci-devsecops.yml | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/.github/workflows/ci-devsecops.yml b/.github/workflows/ci-devsecops.yml index cc22fa3..8f9eb9d 100644 --- a/.github/workflows/ci-devsecops.yml +++ b/.github/workflows/ci-devsecops.yml @@ -68,19 +68,29 @@ jobs: $baseUrl = "https://github.com/gitleaks/gitleaks/releases/download/v$version" $zipAsset = "gitleaks_${version}_windows_x64.zip" $tarAsset = "gitleaks_${version}_windows_x64.tar.gz" + $toolDir = Join-Path $env:RUNNER_TEMP "gitleaks-bin" + + if (Test-Path $toolDir) { + Remove-Item -Path $toolDir -Recurse -Force + } try { Invoke-WebRequest -Uri "$baseUrl/$zipAsset" -OutFile "gitleaks.zip" - Expand-Archive -Path "gitleaks.zip" -DestinationPath ".\\gitleaks-bin" -Force + Expand-Archive -Path "gitleaks.zip" -DestinationPath $toolDir -Force } catch { Invoke-WebRequest -Uri "$baseUrl/$tarAsset" -OutFile "gitleaks.tar.gz" - New-Item -ItemType Directory -Force -Path ".\\gitleaks-bin" | Out-Null - tar -xzf "gitleaks.tar.gz" -C ".\\gitleaks-bin" + New-Item -ItemType Directory -Force -Path $toolDir | Out-Null + tar -xzf "gitleaks.tar.gz" -C $toolDir } - $gitleaksExe = Resolve-Path ".\\gitleaks-bin\\gitleaks.exe" - & $gitleaksExe detect --source "." --redact --verbose --report-format json --report-path gitleaks-report.json + # Remove vendored tool docs from scan scope to avoid known upstream sample false positives. + if (Test-Path ".\\gitleaks-bin") { + Remove-Item -Path ".\\gitleaks-bin" -Recurse -Force + } + + $gitleaksExe = Resolve-Path (Join-Path $toolDir "gitleaks.exe") + & $gitleaksExe detect --source "." --no-git --exit-code 1 --redact --verbose --report-format json --report-path gitleaks-report.json - name: Upload security artifacts if: always()