Commit 73450710 authored by Achilleas Pipinellis's avatar Achilleas Pipinellis

Refactor the SAST docs

- Rearrange to look like the DAST docs
- Replace with new SAST image
parent e24f1562
...@@ -9,10 +9,12 @@ This example shows how to run ...@@ -9,10 +9,12 @@ This example shows how to run
on your project's source code by using GitLab CI/CD. on your project's source code by using GitLab CI/CD.
First, you need GitLab Runner with [docker-in-docker executor](https://docs.gitlab.com/ee/ci/docker/using_docker_build.html#use-docker-in-docker-executor). First, you need GitLab Runner with [docker-in-docker executor](https://docs.gitlab.com/ee/ci/docker/using_docker_build.html#use-docker-in-docker-executor).
You can then add a new job to `.gitlab-ci.yml`, You can then add a new job to `.gitlab-ci.yml`, called `sast`:
called `sast`:
```yaml ```yaml
before_script:
- *functions
sast: sast:
image: docker:latest image: docker:latest
variables: variables:
...@@ -26,8 +28,8 @@ sast: ...@@ -26,8 +28,8 @@ sast:
artifacts: artifacts:
paths: [gl-sast-report.json] paths: [gl-sast-report.json]
.auto_devops: &auto_devops | .functions: &functions |
# Auto DevOps variables and functions # Variables and functions
function setup_docker() { function setup_docker() {
if ! docker info &>/dev/null; then if ! docker info &>/dev/null; then
...@@ -48,25 +50,16 @@ sast: ...@@ -48,25 +50,16 @@ sast:
"registry.gitlab.com/gitlab-org/security-products/sast:$SAST_VERSION" /app/bin/run /code "registry.gitlab.com/gitlab-org/security-products/sast:$SAST_VERSION" /app/bin/run /code
;; ;;
*) *)
echo "GitLab EE is required" echo "GitLab Enterprise Edition is required"
;; ;;
esac esac
} }
before_script:
- *auto_devop
``` ```
Please check the [Auto-DevOps template](https://gitlab.com/gitlab-org/gitlab-ci-yml/blob/master/Auto-DevOps.gitlab-ci.yml) for full reference.
Behind the scenes, the [GitLab SAST Docker image](https://gitlab.com/gitlab-org/security-products/sast)
is used to detect the languages/frameworks and in turn runs the matching scan tools.
Some security scanners require to send a list of project dependencies to GitLab central servers to check for vulnerabilities. To learn more about this or to disable it please
check [GitLab SAST documentation](https://gitlab.com/gitlab-org/security-products/sast#remote-checks).
The above example will create a `sast` job in your CI pipeline and will allow The above example will create a `sast` job in your CI pipeline and will allow
you to download and analyze the report artifact in JSON format. you to download and analyze the report artifact in JSON format. Check the
[Auto-DevOps template](https://gitlab.com/gitlab-org/gitlab-ci-yml/blob/master/Auto-DevOps.gitlab-ci.yml)
for a full reference.
The results are sorted by the priority of the vulnerability: The results are sorted by the priority of the vulnerability:
...@@ -76,6 +69,13 @@ The results are sorted by the priority of the vulnerability: ...@@ -76,6 +69,13 @@ The results are sorted by the priority of the vulnerability:
1. Unknown 1. Unknown
1. Everything else 1. Everything else
Behind the scenes, the [GitLab SAST Docker image](https://gitlab.com/gitlab-org/security-products/sast)
is used to detect the languages/frameworks and in turn runs the matching scan tools.
Some security scanners require to send a list of project dependencies to GitLab
central servers to check for vulnerabilities. To learn more about this or to
disable it, check the [GitLab SAST tool documentation](https://gitlab.com/gitlab-org/security-products/sast#remote-checks).
TIP: **Tip:** TIP: **Tip:**
Starting with [GitLab Ultimate][ee] 10.3, this information will Starting with [GitLab Ultimate][ee] 10.3, this information will
be automatically extracted and shown right in the merge request widget. To do be automatically extracted and shown right in the merge request widget. To do
......
...@@ -40,7 +40,7 @@ prerequisites: ...@@ -40,7 +40,7 @@ prerequisites:
you try to also include other files, it will break the vulnerability display you try to also include other files, it will break the vulnerability display
in the merge request. in the merge request.
The `sast` job will perform an analysis on the running web application, the The `dast` job will perform an analysis on the running web application, the
resulting JSON file will be uploaded as an artifact, and GitLab will then check resulting JSON file will be uploaded as an artifact, and GitLab will then check
this file and show the information inside the merge request. this file and show the information inside the merge request.
......
...@@ -11,9 +11,7 @@ by implicitly using [Auto SAST](../../../topics/autodevops/index.md#auto-sast) ...@@ -11,9 +11,7 @@ by implicitly using [Auto SAST](../../../topics/autodevops/index.md#auto-sast)
that is provided by [Auto DevOps](../../../topics/autodevops/index.md). that is provided by [Auto DevOps](../../../topics/autodevops/index.md).
Going a step further, GitLab can show the vulnerability list right in the merge Going a step further, GitLab can show the vulnerability list right in the merge
request widget area: request widget area.
![SAST Widget](img/sast.png)
## Use cases ## Use cases
...@@ -25,7 +23,7 @@ request widget area: ...@@ -25,7 +23,7 @@ request widget area:
## Supported languages and frameworks ## Supported languages and frameworks
The following languages and frameworks are supported: The following languages and frameworks are supported.
| Language (package managers) / framework | Scan tool | | Language (package managers) / framework | Scan tool |
| ---------------------- | --------- | | ---------------------- | --------- |
...@@ -38,17 +36,21 @@ The following languages and frameworks are supported: ...@@ -38,17 +36,21 @@ The following languages and frameworks are supported:
## How it works ## How it works
In order for the report to show in the merge request, you need to specify a First of all, you need to define a job named `sast` in your `.gitlab-ci.yml`
`sast` job (exact name) that will analyze the code and upload the resulting file. [Check how the `sast` job should look like][cc-docs].
`gl-sast-report.json` file as an artifact. GitLab will then check this file and
show the information inside the merge request. In order for the report to show in the merge request, there are two
prerequisites:
- the specified job **must** be named `sast`
- the resulting report **must** be named `gl-sast-report.json` and uploaded as
an artifact
This JSON file needs to be the only artifact file for the job. If you try The `sast` job will perform an analysis on the running web application, the
to also include other files, it will break the vulnerability display in the resulting JSON file will be uploaded as an artifact, and GitLab will then check
merge request. this file and show the information inside the merge request.
For more information on how the `sast` job should look like, check the ![SAST Widget](img/gemnasium.png)
[example on analyzing a project's code for vulnerabilities][cc-docs].
[ee-3775]: https://gitlab.com/gitlab-org/gitlab-ee/issues/3775 [ee-3775]: https://gitlab.com/gitlab-org/gitlab-ee/issues/3775
[ee]: https://about.gitlab.com/products/ [ee]: https://about.gitlab.com/products/
......
...@@ -11,7 +11,7 @@ a Vulnerability Static Analysis tool for containers. ...@@ -11,7 +11,7 @@ a Vulnerability Static Analysis tool for containers.
Going a step further, GitLab can show the vulnerability list right in the merge Going a step further, GitLab can show the vulnerability list right in the merge
request widget area. request widget area.
![SAST Widget](img/sast-image.png) ![SAST Docker Widget](img/sast_docker.png)
## Use cases ## Use cases
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment