Skip to content

fix(ci): [OPS-723] prevent script injection in gitleaks workflow (#16) #14

fix(ci): [OPS-723] prevent script injection in gitleaks workflow (#16)

fix(ci): [OPS-723] prevent script injection in gitleaks workflow (#16) #14

Workflow file for this run

name: gitleaks
on:
push:
branches: [main]
pull_request:
jobs:
scan:
name: gitleaks
runs-on: ubuntu-latest
permissions:
contents: read
pull-requests: read
actions: read
checks: write
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v4.2.2
with:
fetch-depth: 0
persist-credentials: false
- name: Set scan range
id: range
env:
EVENT: ${{ github.event_name }}
BASE_SHA: ${{ github.event.pull_request.base.sha }}
BEFORE_SHA: ${{ github.event.before }}
FORCED: ${{ github.event.forced }}
run: |
NULL_SHA="0000000000000000000000000000000000000000"
if [ "$EVENT" = "pull_request" ]; then
echo "log_opts=${BASE_SHA}..HEAD" >> $GITHUB_OUTPUT
elif [ "$BEFORE_SHA" = "$NULL_SHA" ] || [ -z "$BEFORE_SHA" ] || [ "$FORCED" = "true" ]; then
echo "log_opts=" >> $GITHUB_OUTPUT
else
echo "log_opts=${BEFORE_SHA}..HEAD" >> $GITHUB_OUTPUT
fi
- uses: gitleaks/gitleaks-action@ff98106e4c7b2bc287b24eaf42907196329070c7 # v2.3.9
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITLEAKS_LICENSE: ${{ secrets.GITLEAKS_LICENSE }}
GITLEAKS_LOG_OPTS: ${{ steps.range.outputs.log_opts }}