I am trying to implement a gitlab pipeline used to detect secrets on commits before they are pushed, and prevent the commits from going live. The detection part works just fine. However the pipeline always marks the job as successful, even though the fake secrets i've added are detected, and let the commits got public.
I have tried to scan the detection report : if it's not empty, a message warning the user is displayed, and an exit code is returned. For some reason though, said exit code gets ignored.
Here is the yml config i'm using :
include:
- template: Jobs/Secret-Detection.gitlab-ci.yml
secret_detection:
variables:
SECRET_DETECTION_HISTORIC_SCAN: "true"
SECRET_DETECTION_IMAGE_SUFFIX: "-fips"
after_script:
- |
reportFile="gl-secret-detection-report.json"
$a: wc -l gl-secret-detection-report.json
$b: 0
if [ $a -gt $b ]; then
echo "VULN FOUND. SEE $reportFile FOR MORE DETAILS." && exit 1
fi
I'm quite at a loss here, any help is appreciated. Thanks !