@@ -333,6 +333,34 @@ In addition to a textual report in the console, this job produces the following
| `$PYTHON_PROJECT_DIR/reports/py-trivy.gitlab-codequality.json` | [Trivy report format for GitLab Code Quality](https://trivy.dev/docs/latest/tutorials/integrations/gitlab-ci/) format | [GitLab Code Quality](https://docs.gitlab.com/ci/yaml/artifacts_reports/#artifactsreportscodequality) |
| `$PYTHON_PROJECT_DIR/reports/py-trivy.gitlab-sast.json` | [Trivy report format for GitLab SAST](https://trivy.dev/docs/latest/tutorials/integrations/gitlab-ci/) format | [GitLab SAST](https://docs.gitlab.com/ci/yaml/artifacts_reports/#artifactsreportssast) |
### `py-semgrep` job
This job performs a [Semgrep](https://semgrep.dev/docs/) analysis.
It is bound to the `test` stage, and uses the following variables:
| Input / Variable | Description | Default Value |
| `semgrep-disabled` / `PYTHON_SEMGREP_DISABLED` | Set to `true` to disable this job | _none_ (enabled) |
| `semgrep-image` / `PYTHON_SEMGREP_IMAGE` | The Docker image used to run [Semgrep](https://semgrep.dev/docs/) | `docker.io/semgrep/semgrep:latest`<br/>[](https://to-be-continuous.gitlab.io/doc/secu/trivy-DOTNET_SEMGREP_IMAGE) |
| `semgrep-rules` / `PYTHON_SEMGREP_RULES` | Space-separated list of [Semgrep rules](https://semgrep.dev/docs/running-rules).<br/>Can be both local YAML files or remote rules from the [Segmrep Registry](https://semgrep.dev/explore) (denoted by the `p/` prefix). | `p/python p/bandit p/gitlab-bandit p/owasp-top-ten p/security-audit` |
> :information_source: Semgrep may [collect some metrics](https://semgrep.dev/docs/metrics), especially when using rules from the Semgrep Registry.
> To protect your privacy and let you run Semgrep in air-gap environments, this template disables all Semgrep metrics by default:
>
> * rules from the Semgrep registry are pre-downloaded and passed to Semgrep as local rule files (can be disabled by setting `semgrep-download-rules-enabled` / `PYTHON_SEMGREP_DOWNLOAD_RULES_ENABLED` to `false`),
> * the `--metrics` option is set to `off`,
> * the `--disable-version-check` option is set.
In addition to a textual report in the console, this job produces the following reports, kept for one week:
"default":"--metrics off --disable-version-check --error ."
},
{
"name":"PYTHON_SEMGREP_RULES",
"description":"Space-separated list of [Semgrep rules](https://semgrep.dev/docs/running-rules).\n\nCan be both local YAML files or remote rules from the [Semgrep Registry](https://semgrep.dev/explore) (denoted by the `p/` prefix)",
print(" ".join([v["file"] for v in cache_metadata.values() if v.get("exist") and not v.get("error")]))
downloaded, from_cache, errors = (sum(1 for v in cache_metadata.values() if v.get("use_cache") == False), sum(1 for v in cache_metadata.values() if v.get("use_cache") == True), sum(1 for v in cache_metadata.values() if "error" in v))