debian-mirror-gitlab/doc/user/application_security/sast/analyzers.md

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

173 lines
11 KiB
Markdown
Raw Normal View History

2020-06-23 00:09:42 +05:30
---
stage: Secure
group: Static Analysis
2021-02-22 17:27:13 +05:30
info: To determine the technical writer assigned to the Stage/Group associated with this page, see https://about.gitlab.com/handbook/engineering/ux/technical-writing/#assignments
2020-06-23 00:09:42 +05:30
---
2021-03-11 19:13:27 +05:30
# SAST Analyzers **(FREE)**
2021-01-29 00:20:46 +05:30
2022-03-02 08:16:31 +05:30
> [Moved](https://gitlab.com/groups/gitlab-org/-/epics/2098) from GitLab Ultimate to GitLab Free in 13.3.
2019-10-12 21:52:04 +05:30
SAST relies on underlying third party tools that are wrapped into what we call
"Analyzers". An analyzer is a
[dedicated project](https://gitlab.com/gitlab-org/security-products/analyzers)
that wraps a particular tool to:
- Expose its detection logic.
- Handle its execution.
- Convert its output to the common format.
This is achieved by implementing the [common API](https://gitlab.com/gitlab-org/security-products/analyzers/common).
SAST supports the following official analyzers:
- [`bandit`](https://gitlab.com/gitlab-org/security-products/analyzers/bandit) (Bandit)
- [`brakeman`](https://gitlab.com/gitlab-org/security-products/analyzers/brakeman) (Brakeman)
2019-12-26 22:10:19 +05:30
- [`eslint`](https://gitlab.com/gitlab-org/security-products/analyzers/eslint) (ESLint (JavaScript and React))
2019-10-12 21:52:04 +05:30
- [`flawfinder`](https://gitlab.com/gitlab-org/security-products/analyzers/flawfinder) (Flawfinder)
- [`gosec`](https://gitlab.com/gitlab-org/security-products/analyzers/gosec) (Gosec)
2020-01-01 13:55:28 +05:30
- [`kubesec`](https://gitlab.com/gitlab-org/security-products/analyzers/kubesec) (Kubesec)
2021-01-03 14:25:43 +05:30
- [`mobsf`](https://gitlab.com/gitlab-org/security-products/analyzers/mobsf) (MobSF (beta))
2019-10-12 21:52:04 +05:30
- [`nodejs-scan`](https://gitlab.com/gitlab-org/security-products/analyzers/nodejs-scan) (NodeJsScan)
- [`phpcs-security-audit`](https://gitlab.com/gitlab-org/security-products/analyzers/phpcs-security-audit) (PHP CS security-audit)
- [`pmd-apex`](https://gitlab.com/gitlab-org/security-products/analyzers/pmd-apex) (PMD (Apex only))
- [`security-code-scan`](https://gitlab.com/gitlab-org/security-products/analyzers/security-code-scan) (Security Code Scan (.NET))
2021-03-11 19:13:27 +05:30
- [`semgrep`](https://gitlab.com/gitlab-org/security-products/analyzers/semgrep) (Semgrep)
2019-10-12 21:52:04 +05:30
- [`sobelow`](https://gitlab.com/gitlab-org/security-products/analyzers/sobelow) (Sobelow (Elixir Phoenix))
- [`spotbugs`](https://gitlab.com/gitlab-org/security-products/analyzers/spotbugs) (SpotBugs with the Find Sec Bugs plugin (Ant, Gradle and wrapper, Grails, Maven and wrapper, SBT))
2021-01-29 00:20:46 +05:30
The analyzers are published as Docker images that SAST uses to launch
2019-10-12 21:52:04 +05:30
dedicated containers for each analysis.
SAST is pre-configured with a set of **default images** that are maintained by
GitLab, but users can also integrate their own **custom images**.
2021-04-29 21:17:54 +05:30
## SAST analyzer features
2021-06-08 01:23:25 +05:30
For an analyzer to be considered Generally Available, it is expected to minimally
2021-04-29 21:17:54 +05:30
support the following features:
2021-09-04 01:27:46 +05:30
- [Customizable configuration](index.md#available-cicd-variables)
2021-04-29 21:17:54 +05:30
- [Customizable rulesets](index.md#customize-rulesets)
- [Scan projects](index.md#supported-languages-and-frameworks)
- [Multi-project support](index.md#multi-project-support)
- [Offline support](index.md#running-sast-in-an-offline-environment)
- [Emits JSON report format](index.md#reports-json-format)
- [SELinux support](index.md#running-sast-in-selinux)
2019-10-12 21:52:04 +05:30
## Official default analyzers
2021-03-11 19:13:27 +05:30
Any custom change to the official analyzers can be achieved by using a
2022-01-26 12:08:38 +05:30
[CI/CD variable in your `.gitlab-ci.yml`](index.md#available-cicd-variables).
2019-10-12 21:52:04 +05:30
### Using a custom Docker mirror
You can switch to a custom Docker registry that provides the official analyzer
images under a different prefix. For instance, the following instructs
2021-11-11 11:23:49 +05:30
SAST to pull `my-docker-registry/gl-images/sast/bandit`
instead of `registry.gitlab.com/security-products/sast/bandit`.
2019-10-12 21:52:04 +05:30
In `.gitlab-ci.yml` define:
```yaml
include:
2021-01-03 14:25:43 +05:30
- template: Security/SAST.gitlab-ci.yml
2019-10-12 21:52:04 +05:30
variables:
2020-05-24 23:13:21 +05:30
SECURE_ANALYZERS_PREFIX: my-docker-registry/gl-images
2019-10-12 21:52:04 +05:30
```
This configuration requires that your custom registry provides images for all
the official analyzers.
2021-03-08 18:12:59 +05:30
### Disabling all default analyzers
2019-10-12 21:52:04 +05:30
2021-03-08 18:12:59 +05:30
Setting `SAST_DISABLED` to `true` disables all the official
2019-10-12 21:52:04 +05:30
default analyzers. In `.gitlab-ci.yml` define:
```yaml
include:
2021-01-03 14:25:43 +05:30
- template: Security/SAST.gitlab-ci.yml
2019-10-12 21:52:04 +05:30
variables:
2021-03-08 18:12:59 +05:30
SAST_DISABLED: true
2019-10-12 21:52:04 +05:30
```
That's needed when one totally relies on [custom analyzers](#custom-analyzers).
2021-03-08 18:12:59 +05:30
### Disabling specific default analyzers
Set `SAST_EXCLUDED_ANALYZERS` to a comma-delimited string that includes the official
default analyzers that you want to avoid running. In `.gitlab-ci.yml` define the
following to prevent the `eslint` analyzer from running:
```yaml
include:
- template: Security/SAST.gitlab-ci.yml
variables:
SAST_EXCLUDED_ANALYZERS: "eslint"
```
2021-03-11 19:13:27 +05:30
## Post Analyzers **(ULTIMATE)**
While analyzers are thin wrappers for executing scanners, post analyzers work to
enrich the data generated within our reports.
GitLab SAST post analyzers never modify report contents directly but work by
augmenting results with additional properties (such as CWEs), location tracking fields,
and a means of identifying false positives or insignificant findings.
The implementation of post analyzers is determined by feature availability tiers, where
simple data enrichment may occur within our free tier and most advanced processing is split
into separate binaries or pipeline jobs.
2019-10-12 21:52:04 +05:30
## Custom Analyzers
2020-11-24 15:15:51 +05:30
You can provide your own analyzers by
2020-04-22 19:07:51 +05:30
defining CI jobs in your CI configuration. For consistency, you should suffix your custom
SAST jobs with `-sast`. Here's how to add a scanning job that's based on the
Docker image `my-docker-registry/analyzers/csharp` and generates a SAST report
`gl-sast-report.json` when `/analyzer run` is executed. Define the following in
`.gitlab-ci.yml`:
```yaml
csharp-sast:
image:
name: "my-docker-registry/analyzers/csharp"
script:
- /analyzer run
artifacts:
reports:
sast: gl-sast-report.json
```
The [Security Scanner Integration](../../../development/integrations/secure.md) documentation explains how to integrate custom security scanners into GitLab.
2019-12-26 22:10:19 +05:30
2019-10-12 21:52:04 +05:30
## Analyzers Data
2021-03-11 19:13:27 +05:30
| Property / Tool | Apex | Bandit | Brakeman | ESLint security | SpotBugs | Flawfinder | Gosec | Kubesec Scanner | MobSF | NodeJsScan | PHP CS Security Audit | Security code Scan (.NET) | Semgrep | Sobelow |
|--------------------------------|------|--------|----------|-----------------|----------|------------|-------|-----------------|-------|------------|-----------------------|---------------------------|---------|---------|
| Affected item (for example, class or package) | ✓ | ✗ | ✓ | ✗ | ✓ | ✓ | ✗ | ✓ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ |
| Confidence | ✗ | ✓ | ✓ | ✗ | ✓ | x | ✓ | ✓ | ✗ | ✗ | ✗ | ✗ | ⚠ | ✓ |
| Description | ✓ | ✗ | ✗ | ✓ | ✓ | ✗ | ✗ | ✓ | ✓ | ✓ | ✗ | ✗ | ✓ | ✓ |
| End column | ✓ | ✗ | ✗ | ✓ | ✓ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ |
| End line | ✓ | ✓ | ✗ | ✓ | ✓ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ |
| External ID (for example, CVE) | ✗ | ✗ | ⚠ | ✗ | ⚠ | ✓ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ⚠ | ✗ |
| File | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ |
| Internal doc/explanation | ✓ | ⚠ | ✓ | ✗ | ✓ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✓ |
| Internal ID | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✗ | ✗ | ✗ | ✓ | ✓ | ✓ | ✓ |
| Severity | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✗ | ⚠ | ✗ |
| Solution | ✓ | ✗ | ✗ | ✗ | ⚠ | ✓ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ⚠ | ✗ |
| Source code extract | ✗ | ✓ | ✓ | ✓ | ✗ | ✓ | ✓ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ |
| Start column | ✓ | ✗ | ✗ | ✓ | ✓ | ✓ | ✓ | ✗ | ✗ | ✗ | ✓ | ✓ | ✓ | ✗ |
| Start line | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✗ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ |
| Title | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ |
| URLs | ✓ | ✗ | ✓ | ✗ | ⚠ | ✗ | ⚠ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ |
2019-10-12 21:52:04 +05:30
- ✓ => we have that data
- ⚠ => we have that data but it's partially reliable, or we need to extract it from unstructured content
2021-03-11 19:13:27 +05:30
- ✗ => we don't have that data or it would need to develop specific or inefficient/unreliable logic to obtain it.
2019-10-12 21:52:04 +05:30
The values provided by these tools are heterogeneous so they are sometimes
2021-01-29 00:20:46 +05:30
normalized into common values (for example, `severity`, `confidence`, and so on).