Set SEARCH_MAX_DEPTH to 20 for the Advanced SAST C++ job

What does this MR do and why?

gitlab-advanced-sast-cpp declares no SEARCH_MAX_DEPTH of its own, so it inherits the 4 that the base sast job sets. The analyzer then descends only four directory levels when looking for C and C++ files, and anything below that is never scanned. Vulnerabilities in those files are silently absent from the report rather than reported as findings.

Every sibling analyzer already overrides the value. gitlab-advanced-sast and semgrep-sast both set 20, and the SAST documentation gives 20 as the default for GitLab Advanced SAST. The C++ job was the only one left on the base value, and it was left there in both the stable and the latest template.

Setting SEARCH_MAX_DEPTH: 20 on the job brings it in line with its siblings and with the documented default.

References

Differences

Before: the gitlab-advanced-sast-cpp job ran with SEARCH_MAX_DEPTH=4. A vulnerable C or C++ file more than four directories deep was skipped, so the scan came back clean while the vulnerability was still there. The behaviour did not match the documentation, which states a default of 20 for GitLab Advanced SAST.

After: the job runs with SEARCH_MAX_DEPTH=20, the same value gitlab-advanced-sast and semgrep-sast already use, and files up to twenty levels deep are searched and reported on.

How to set up and validate locally

The templates are data, so the change can be read directly:

grep -n "SEARCH_MAX_DEPTH" lib/gitlab/ci/templates/Jobs/SAST.gitlab-ci.yml lib/gitlab/ci/templates/Jobs/SAST.latest.gitlab-ci.yml

Parsing either template and reading the effective value per job shows the intent of the change. On master, gitlab-advanced-sast-cpp sets no value and resolves to the base 4, while gitlab-advanced-sast and semgrep-sast both resolve to 20. With this change all three resolve to 20, and the base sast job keeps its own 4.

End to end, a project with a vulnerable C file more than four directories deep now reports the finding, using the example project linked in the issue.

Edited by Jeston Singh

Merge request reports

Loading
Loading