Secret detection ignores SECRET_DETECTION_HISTORIC_SCAN in feature branch
Summary
It is not possible to run secret detection with SECRET_DETECTION_HISTORIC_SCAN in a feature branch.
Steps to reproduce
- Set up secret detection in a feature branch and enable 'trace' log level
- Observe that enabling or disabling SECRET_DETECTION_HISTORIC_SCAN does not make any difference to the number of commits that are being scanned
What is the current bug behavior?
-
The gitlab pipeline will always set the SECRET_DETECTION_COMMITS_FILE variable: https://gitlab.com/gitlab-org/gitlab/-/blob/master/lib/gitlab/ci/templates/Security/Secret-Detection.gitlab-ci.yml#L43
-
The analyzer never reaches the set_historic_scan statement if the SECRET_DETECTION_COMMITS_FILE variable is set https://gitlab.com/gitlab-org/security-products/analyzers/secrets/-/blob/160424589ef1eed7b91b59484e019095bc7233bd/analyze.go#L172
-
SECRET_DETECTION_HISTORIC_SCAN is ignored
What is the expected correct behavior?
Either document that this does not work except for the main branch, or don't ignore SECRET_DETECTION_HISTORIC_SCAN.
Results of GitLab environment info
GitLab Enterprise Edition 13.11.3-ee
Possible fixes
--> move the historic scan flag check upwards