Add PHP language support to gitlab-advanced-sast
What does this MR do and why?
This MR adds PHP file scanning to the gitlab-advanced-sast analyzer in both the regular and latest GitLab SAST templates.
- Added
**/*.phptogitlab-advanced-sastfile patterns, enabling PHP scanning when this analyzer is enabled - Added PHP to
semgrep-sastexclusion paths to prevent duplicate scanning when both analyzers are active - Maintained consistent configuration across merge request and branch pipelines
Note: When users enable GLAS (gitlab-advanced-sast) for PHP scanning, they will no longer receive results from semgrep-sast for PHP files due to the exclusion paths added to prevent duplicate scanning.
References
https://gitlab.com/gitlab-org/gitlab/-/issues/523657+s
Manual QA
Before
- Project: https://gitlab.com/philipcunningham/manual-qa-glas-php-ci-template
- Pipeline: https://gitlab.com/philipcunningham/manual-qa-glas-php-ci-template/-/pipelines/1831513839
Summary
-
semgrep-sastis executed as normal. -
gitlab-advanced-sastis not executed.
After
- Project: https://gitlab.com/philipcunningham/manual-qa-glas-php-ci-template
- Pipeline: https://gitlab.com/philipcunningham/manual-qa-glas-php-ci-template/-/pipelines/1833588190
Summary
-
semgrep-sastjob now excludes PHP files via theSAST_EXCLUDED_PATHSconfiguration, which explicitly lists**/*.phpin the exclusion pattern. -
gitlab-advanced-sastjob successfully identifies and scans PHP files, processing all.phpfiles in the repository as shown in the target mappings.
Disabling PHP Scanning in GitLab Advanced SAST
To disable PHP scanning in GitLab Advanced SAST while enabling it in semgrep-sast, set these project-level CI/CD variables in your project settings (Settings → CI/CD → Variables):
Variable 1:
Key: FF_GLAS_ENABLE_PHP_SUPPORT
Value: false
Variable 2:
Key: SAST_EXCLUDED_PATHS
Value: spec, test, tests, tmp, **/*.py, **/*.go, **/*.java, **/*.js, **/*.jsx, **/*.ts, **/*.tsx, **/*.cjs, **/*.mjs, **/*.cs, **/*.rb
The project-level variables have higher precedence and will override the template's default behavior.
- Project: https://gitlab.com/philipcunningham/manual-qa-glas-php-ci-template
- Pipeline: https://gitlab.com/philipcunningham/manual-qa-glas-php-ci-template/-/pipelines/1833710080
MR acceptance checklist
Evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.