2019-07-25 10:16:25 -04:00
---
type: reference, howto
2020-05-26 14:08:20 -04:00
stage: Secure
group: Composition Analysis
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/#designated-technical-writers
2019-07-25 10:16:25 -04:00
---
2019-07-08 04:50:38 -04:00
# Dependency Scanning **(ULTIMATE)**
2019-05-05 12:12:56 -04:00
2020-05-21 23:08:28 -04:00
> [Introduced](https://gitlab.com/gitlab-org/gitlab/-/issues/5105) in [GitLab Ultimate](https://about.gitlab.com/pricing/) 10.7.
2019-09-10 06:06:45 -04:00
2020-09-29 02:09:45 -04:00
GitLab's Dependency Scanning feature can automatically find security vulnerabilities in your
dependencies while you're developing and testing your applications. For example, dependency scanning
lets you know if your application uses an external (open source) library that is known to be
vulnerable. You can then take action to protect your application.
2019-05-05 12:12:56 -04:00
## Overview
2020-09-29 02:09:45 -04:00
If you're using [GitLab CI/CD ](../../../ci/README.md ), you can use dependency scanning to analyze
your dependencies for known vulnerabilities. GitLab scans all dependencies, including transitive
dependencies (also known as nested dependencies). You can take advantage of dependency scanning by
either [including the dependency scanning template ](#configuration )
in your existing `.gitlab-ci.yml` file, or by implicitly using
the [auto dependency scanning ](../../../topics/autodevops/stages.md#auto-dependency-scanning )
2020-05-05 23:09:33 -04:00
provided by [Auto DevOps ](../../../topics/autodevops/index.md ).
2019-05-05 12:12:56 -04:00
2020-09-29 02:09:45 -04:00
GitLab checks the dependency scanning report, compares the found vulnerabilities
2019-09-10 06:06:45 -04:00
between the source and target branches, and shows the information on the
2019-05-05 12:12:56 -04:00
merge request.
2020-09-29 02:09:45 -04:00
![Dependency scanning Widget ](img/dependency_scanning_v13_2.png )
2019-05-05 12:12:56 -04:00
2019-05-20 14:13:10 -04:00
The results are sorted by the severity of the vulnerability:
2019-05-05 12:12:56 -04:00
2019-05-20 14:13:10 -04:00
1. Critical
2019-05-05 12:12:56 -04:00
1. High
1. Medium
1. Low
1. Unknown
1. Everything else
## Requirements
2020-09-29 02:09:45 -04:00
To run dependency scanning jobs, by default, you need GitLab Runner with the
2020-05-15 14:07:52 -04:00
[`docker` ](https://docs.gitlab.com/runner/executors/docker.html ) or
[`kubernetes` ](https://docs.gitlab.com/runner/install/kubernetes.html ) executor.
2020-09-14 23:09:24 -04:00
If you're using the shared runners on GitLab.com, this is enabled by default.
2019-05-05 12:12:56 -04:00
2019-09-09 01:47:49 -04:00
CAUTION: **Caution:**
2020-09-14 23:09:24 -04:00
If you use your own runners, make sure your installed version of Docker
2020-04-14 20:09:27 -04:00
is **not** `19.03.0` . See [troubleshooting information ](#error-response-from-daemon-error-processing-tar-file-docker-tar-relocation-error ) for details.
2019-09-09 01:47:49 -04:00
2019-05-05 12:12:56 -04:00
## Supported languages and package managers
2020-06-01 02:08:21 -04:00
GitLab relies on [`rules` ](../../../ci/yaml/README.md#rules ) to start relevant analyzers depending on the languages detected in the repository.
The current detection logic limits the maximum search depth to two levels. For example, the `gemnasium-dependency_scanning` job is enabled if a repository contains either a `Gemfile` or `api/Gemfile` file, but not if the only supported dependency file is `api/client/Gemfile` .
2020-06-09 17:08:21 -04:00
The following languages and dependency managers are supported:
2020-09-25 14:09:46 -04:00
| Package Managers | Languages | Supported files | Scan tools |
| ------------------- | --------- | --------------- | ------------ |
| [Bundler ](https://bundler.io/ ) | Ruby | `Gemfile.lock` , `gems.locked` | [Gemnasium ](https://gitlab.com/gitlab-org/security-products/gemnasium ), [bundler-audit ](https://github.com/rubysec/bundler-audit ) |
| [Composer ](https://getcomposer.org/ ) | PHP | `composer.lock` | [Gemnasium ](https://gitlab.com/gitlab-org/security-products/gemnasium ) |
| [Conan ](https://conan.io/ ) | C, C++ | [`conan.lock` ](https://docs.conan.io/en/latest/versioning/lockfiles.html ) | [Gemnasium ](https://gitlab.com/gitlab-org/security-products/gemnasium ) |
| [Golang ](https://golang.org/ ) | Go | `go.sum` | [Gemnasium ](https://gitlab.com/gitlab-org/security-products/gemnasium ) |
| [Gradle ](https://gradle.org/ ), [Maven ](https://maven.apache.org/ ) | Java | `build.gradle` , `build.gradle.kts` , `pom.xml` | [Gemnasium ](https://gitlab.com/gitlab-org/security-products/gemnasium ) |
| [npm ](https://www.npmjs.com/ ), [yarn ](https://classic.yarnpkg.com/en/ ) | JavaScript | `package-lock.json` , `npm-shrinkwrap.json` , `yarn.lock` | [Gemnasium ](https://gitlab.com/gitlab-org/security-products/gemnasium ), [Retire.js ](https://retirejs.github.io/retire.js/ ) |
| [NuGet ](https://www.nuget.org/ ) 4.9+ | .NET, C# | [`packages.lock.json` ](https://docs.microsoft.com/en-us/nuget/consume-packages/package-references-in-project-files#enabling-lock-file ) | [Gemnasium ](https://gitlab.com/gitlab-org/security-products/gemnasium ) |
| [setuptools ](https://setuptools.readthedocs.io/en/latest/ ), [pip ](https://pip.pypa.io/en/stable/ ), [Pipenv ](https://pipenv.pypa.io/en/latest/ ) | Python | `setup.py` , `requirements.txt` , `requirements.pip` , `requires.txt` , `Pipfile` | [Gemnasium ](https://gitlab.com/gitlab-org/security-products/gemnasium ) |
2020-10-15 14:08:43 -04:00
| [sbt ](https://www.scala-sbt.org/ ) 1.2 and below ([Ivy](http://ant.apache.org/ivy/)) | Scala | `build.sbt` | [Gemnasium ](https://gitlab.com/gitlab-org/security-products/gemnasium ) |
2020-06-09 17:08:21 -04:00
Plans are underway for supporting the following languages, dependency managers, and dependency files. For details, see the issue link for each.
2020-09-25 14:09:46 -04:00
| Package Managers | Languages | Supported files | Scan tools |
| ------------------- | --------- | --------------- | ------------ |
| [Pipenv ](https://pipenv.pypa.io/en/latest/ ) | Python | `Pipfile.lock` | [Gemnasium ](https://gitlab.com/gitlab-org/security-products/gemnasium ) | [GitLab#11756 ](https://gitlab.com/gitlab-org/gitlab/-/issues/11756 ) |
| [Poetry ](https://python-poetry.org/ ) | Python | `poetry.lock` | [Gemnasium ](https://gitlab.com/gitlab-org/security-products/gemnasium ) | [GitLab#7006 ](https://gitlab.com/gitlab-org/gitlab/-/issues/7006 ) |
2020-10-15 14:08:43 -04:00
| [sbt ](https://www.scala-sbt.org/ ) 1.3+ ([Coursier](https://get-coursier.io/))| Scala | `build.sbt` | [Gemnasium ](https://gitlab.com/gitlab-org/security-products/gemnasium ) | [GitLab#249526 ](https://gitlab.com/gitlab-org/gitlab/-/issues/249526 ) |
2019-05-05 12:12:56 -04:00
2020-03-20 05:09:22 -04:00
## Contribute your scanner
The [Security Scanner Integration ](../../../development/integrations/secure.md ) documentation explains how to integrate other security scanners into GitLab.
2019-07-09 12:41:33 -04:00
## Configuration
2019-05-05 12:12:56 -04:00
2020-09-29 02:09:45 -04:00
To enable dependency scanning for GitLab 11.9 and later, you must
2019-07-09 12:41:33 -04:00
[include ](../../../ci/yaml/README.md#includetemplate ) the
2019-09-18 10:02:45 -04:00
[`Dependency-Scanning.gitlab-ci.yml` template ](https://gitlab.com/gitlab-org/gitlab/blob/master/lib/gitlab/ci/templates/Security/Dependency-Scanning.gitlab-ci.yml )
2020-08-09 17:10:01 -04:00
that is provided as a part of your GitLab installation.
2019-07-09 12:41:33 -04:00
For GitLab versions earlier than 11.9, you can copy and use the job as defined
that template.
2019-05-05 12:12:56 -04:00
2019-07-09 12:41:33 -04:00
Add the following to your `.gitlab-ci.yml` file:
2019-05-05 12:12:56 -04:00
```yaml
include:
2020-02-05 10:08:48 -05:00
- template: Dependency-Scanning.gitlab-ci.yml
2019-05-05 12:12:56 -04:00
```
2020-09-29 02:09:45 -04:00
The included template creates dependency scanning jobs in your CI/CD
2020-08-09 17:10:01 -04:00
pipeline and scans your project's source code for possible vulnerabilities.
The results are saved as a
2020-09-29 02:09:45 -04:00
[dependency scanning report artifact ](../../../ci/pipelines/job_artifacts.md#artifactsreportsdependency_scanning )
2019-05-05 12:12:56 -04:00
that you can later download and analyze. Due to implementation limitations, we
2020-09-29 02:09:45 -04:00
always take the latest dependency scanning artifact available.
2019-05-05 12:12:56 -04:00
2020-09-29 02:09:45 -04:00
### Customizing the dependency scanning settings
2019-05-05 12:12:56 -04:00
2020-09-29 02:09:45 -04:00
The dependency scanning settings can be changed through [environment variables ](#available-variables ) by using the
2019-05-05 12:12:56 -04:00
[`variables` ](../../../ci/yaml/README.md#variables ) parameter in `.gitlab-ci.yml` .
For example:
```yaml
include:
2020-02-05 10:08:48 -05:00
- template: Dependency-Scanning.gitlab-ci.yml
2019-05-05 12:12:56 -04:00
variables:
2019-10-30 11:14:17 -04:00
DS_PYTHON_VERSION: 2
2019-05-05 12:12:56 -04:00
```
Because template is [evaluated before ](../../../ci/yaml/README.md#include ) the pipeline
2020-08-09 17:10:01 -04:00
configuration, the last mention of the variable takes precedence.
2019-05-05 12:12:56 -04:00
2020-09-29 02:09:45 -04:00
### Overriding dependency scanning jobs
2019-05-05 12:12:56 -04:00
2020-04-21 11:21:10 -04:00
CAUTION: **Deprecation:**
Beginning in GitLab 13.0, the use of [`only` and `except` ](../../../ci/yaml/README.md#onlyexcept-basic )
is no longer supported. When overriding the template, you must use [`rules` ](../../../ci/yaml/README.md#rules ) instead.
2020-05-15 14:07:52 -04:00
To override a job definition (for example, to change properties like `variables` or `dependencies` ),
declare a new job with the same name as the one to override. Place this new job after the template
inclusion and specify any additional keys under it. For example, this disables `DS_REMEDIATE` for
the `gemnasium` analyzer:
2019-05-05 12:12:56 -04:00
```yaml
include:
2020-02-05 10:08:48 -05:00
- template: Dependency-Scanning.gitlab-ci.yml
2019-05-05 12:12:56 -04:00
2020-05-15 14:07:52 -04:00
gemnasium-dependency_scanning:
2019-05-05 12:12:56 -04:00
variables:
2020-05-15 14:07:52 -04:00
DS_REMEDIATE: "false"
2019-05-05 12:12:56 -04:00
```
2019-07-09 12:41:33 -04:00
### Available variables
2019-06-07 06:48:46 -04:00
2020-09-29 02:09:45 -04:00
Dependency scanning can be [configured ](#customizing-the-dependency-scanning-settings )
2019-06-07 06:48:46 -04:00
using environment variables.
2020-09-29 02:09:45 -04:00
#### Configuring dependency scanning
2020-03-10 08:08:16 -04:00
The following variables allow configuration of global dependency scanning settings.
2020-04-08 14:09:16 -04:00
| Environment variable | Description |
| --------------------------------------- |------------ |
2020-05-11 14:09:55 -04:00
| `SECURE_ANALYZERS_PREFIX` | Override the name of the Docker registry providing the official default images (proxy). Read more about [customizing analyzers ](analyzers.md ). |
2020-04-08 14:09:16 -04:00
| `DS_DEFAULT_ANALYZERS` | Override the names of the official default images. Read more about [customizing analyzers ](analyzers.md ). |
2020-09-02 14:10:40 -04:00
| `ADDITIONAL_CA_CERT_BUNDLE` | Bundle of CA certs to trust. The bundle of certificates provided here is also used by other tools during the scanning process, such as `git` , `yarn` , or `npm` . |
2020-06-11 08:08:54 -04:00
| `DS_EXCLUDED_PATHS` | Exclude vulnerabilities from output based on the paths. A comma-separated list of patterns. Patterns can be globs, or file or folder paths (for example, `doc,spec` ). Parent directories also match patterns. Default: `"spec, test, tests, tmp"` |
2020-07-20 20:09:37 -04:00
| `SECURE_LOG_LEVEL` | Set the minimum logging level. Messages of this logging level or higher are output. From highest to lowest severity, the logging levels are: `fatal` , `error` , `warn` , `info` , `debug` . [Introduced ](https://gitlab.com/gitlab-org/gitlab/-/issues/10880 ) in GitLab 13.1. Default: `info` |
2020-04-08 14:09:16 -04:00
2020-09-29 02:09:45 -04:00
#### Configuring specific analyzers used by dependency scanning
2020-03-10 08:08:16 -04:00
The following variables are used for configuring specific analyzers (used for a specific language/framework).
| Environment variable | Analyzer | Default | Description |
| --------------------------------------- | ------------------ | ---------------------------- |------------ |
2020-05-05 23:09:33 -04:00
| `GEMNASIUM_DB_LOCAL_PATH` | `gemnasium` | `/gemnasium-db` | Path to local Gemnasium database. |
| `GEMNASIUM_DB_REMOTE_URL` | `gemnasium` | `https://gitlab.com/gitlab-org/security-products/gemnasium-db.git` | Repository URL for fetching the Gemnasium database. |
2020-03-10 08:08:16 -04:00
| `GEMNASIUM_DB_REF_NAME` | `gemnasium` | `master` | Branch name for remote repository database. `GEMNASIUM_DB_REMOTE_URL` is required. |
2020-05-11 14:09:55 -04:00
| `DS_REMEDIATE` | `gemnasium` | `"true"` | Enable automatic remediation of vulnerable dependencies. |
2020-03-10 08:08:16 -04:00
| `PIP_INDEX_URL` | `gemnasium-python` | `https://pypi.org/simple` | Base URL of Python Package Index. |
2020-05-05 23:09:33 -04:00
| `PIP_EXTRA_INDEX_URL` | `gemnasium-python` | | Array of [extra URLs ](https://pip.pypa.io/en/stable/reference/pip_install/#cmdoption-extra-index-url ) of package indexes to use in addition to `PIP_INDEX_URL` . Comma-separated. |
2020-03-10 08:08:16 -04:00
| `PIP_REQUIREMENTS_FILE` | `gemnasium-python` | | Pip requirements file to be scanned. |
2020-05-21 23:08:28 -04:00
| `DS_PIP_VERSION` | `gemnasium-python` | | Force the install of a specific pip version (example: `"19.3"` ), otherwise the pip installed in the Docker image is used. ([Introduced](https://gitlab.com/gitlab-org/gitlab/-/issues/12811) in GitLab 12.7) |
| `DS_PIP_DEPENDENCY_PATH` | `gemnasium-python` | | Path to load Python pip dependencies from. ([Introduced](https://gitlab.com/gitlab-org/gitlab/-/issues/12412) in GitLab 12.2) |
| `DS_PYTHON_VERSION` | `retire.js` | | Version of Python. If set to 2, dependencies are installed using Python 2.7 instead of Python 3.6. ([Introduced](https://gitlab.com/gitlab-org/gitlab/-/issues/12296) in GitLab 12.1)|
2020-08-09 17:10:01 -04:00
| `DS_JAVA_VERSION` | `gemnasium-maven` | `11` | Version of Java. Available versions: `8` , `11` , `13` , `14` . Maven and Gradle use the Java version specified by this value. |
| `MAVEN_CLI_OPTS` | `gemnasium-maven` | `"-DskipTests --batch-mode"` | List of command line arguments that are passed to `maven` by the analyzer. See an example for [using private repositories ](../index.md#using-private-maven-repos ). |
| `GRADLE_CLI_OPTS` | `gemnasium-maven` | | List of command line arguments that are passed to `gradle` by the analyzer. |
| `SBT_CLI_OPTS` | `gemnasium-maven` | | List of command-line arguments that the analyzer passes to `sbt` . |
2020-09-29 02:09:45 -04:00
| `BUNDLER_AUDIT_UPDATE_DISABLED` | `bundler-audit` | `"false"` | Disable automatic updates for the `bundler-audit` analyzer. Useful if you're running dependency scanning in an offline, air-gapped environment.|
2020-03-10 08:08:16 -04:00
| `BUNDLER_AUDIT_ADVISORY_DB_URL` | `bundler-audit` | `https://github.com/rubysec/ruby-advisory-db` | URL of the advisory database used by bundler-audit. |
| `BUNDLER_AUDIT_ADVISORY_DB_REF_NAME` | `bundler-audit` | `master` | Git ref for the advisory database specified by `BUNDLER_AUDIT_ADVISORY_DB_URL` . |
2020-04-13 14:09:35 -04:00
| `RETIREJS_JS_ADVISORY_DB` | `retire.js` | `https://raw.githubusercontent.com/RetireJS/retire.js/master/repository/jsrepository.json` | Path or URL to `retire.js` JS vulnerability data file. Note that if the URL hosting the data file uses a custom SSL certificate, for example in an offline installation, you can pass the certificate in the `ADDITIONAL_CA_CERT_BUNDLE` environment variable. |
| `RETIREJS_NODE_ADVISORY_DB` | `retire.js` | `https://raw.githubusercontent.com/RetireJS/retire.js/master/repository/npmrepository.json` | Path or URL to `retire.js` node vulnerability data file. Note that if the URL hosting the data file uses a custom SSL certificate, for example in an offline installation, you can pass the certificate in the `ADDITIONAL_CA_CERT_BUNDLE` environment variable. |
| `RETIREJS_ADVISORY_DB_INSECURE` | `retire.js` | `false` | Enable fetching remote JS and Node vulnerability data files (defined by the `RETIREJS_JS_ADVISORY_DB` and `RETIREJS_NODE_ADVISORY_DB` variables) from hosts using an insecure or self-signed SSL (TLS) certificate. |
2019-11-07 16:06:14 -05:00
### Using private Maven repos
2020-05-05 23:09:33 -04:00
If your private Maven repository requires login credentials,
2020-04-06 14:09:37 -04:00
you can use the `MAVEN_CLI_OPTS` environment variable.
2020-05-05 23:09:33 -04:00
Read more on [how to use private Maven repositories ](../index.md#using-private-maven-repos ).
2019-06-07 06:48:46 -04:00
2019-09-10 06:06:45 -04:00
## Interacting with the vulnerabilities
Once a vulnerability is found, you can interact with it. Read more on how to
[interact with the vulnerabilities ](../index.md#interacting-with-the-vulnerabilities ).
## Solutions for vulnerabilities (auto-remediation)
Some vulnerabilities can be fixed by applying the solution that GitLab
2020-05-05 23:09:33 -04:00
automatically generates. Read more about the
2020-10-22 02:08:26 -04:00
[solutions for vulnerabilities ](../index.md#automatic-remediation-for-vulnerabilities ).
2019-09-10 06:06:45 -04:00
## Security Dashboard
The Security Dashboard is a good place to get an overview of all the security
vulnerabilities in your groups, projects and pipelines. Read more about the
[Security Dashboard ](../security_dashboard/index.md ).
## Vulnerabilities database update
For more information about the vulnerabilities database update, check the
[maintenance table ](../index.md#maintenance-and-update-of-the-vulnerabilities-database ).
## Dependency List
2020-09-29 02:09:45 -04:00
An additional benefit of dependency scanning is the ability to view your
2019-09-10 06:06:45 -04:00
project's dependencies and their known vulnerabilities. Read more about
the [Dependency List ](../dependency_list/index.md ).
2019-06-12 07:11:00 -04:00
## Reports JSON format
2020-09-29 02:09:45 -04:00
The dependency scanning tool emits a JSON report file. For more information, see the
2020-06-15 14:08:43 -04:00
[schema for this report ](https://gitlab.com/gitlab-org/security-products/security-report-schemas/-/blob/master/dist/dependency-scanning-report-format.json ).
2019-06-12 07:11:00 -04:00
2020-09-29 02:09:45 -04:00
Here's an example dependency scanning report:
2019-06-12 07:11:00 -04:00
```json-doc
{
"version": "2.0",
"vulnerabilities": [
{
2020-04-09 17:09:19 -04:00
"id": "51e83874-0ff6-4677-a4c5-249060554eae",
2019-06-12 07:11:00 -04:00
"category": "dependency_scanning",
"name": "Regular Expression Denial of Service",
"message": "Regular Expression Denial of Service in debug",
"description": "The debug module is vulnerable to regular expression denial of service when untrusted user input is passed into the `o` formatter. It takes around 50k characters to block for 2 seconds making this a low severity issue.",
"severity": "Unknown",
"solution": "Upgrade to latest versions.",
"scanner": {
"id": "gemnasium",
"name": "Gemnasium"
},
"location": {
"file": "yarn.lock",
"dependency": {
"package": {
"name": "debug"
},
"version": "1.0.5"
}
},
"identifiers": [
{
"type": "gemnasium",
"name": "Gemnasium-37283ed4-0380-40d7-ada7-2d994afcc62a",
"value": "37283ed4-0380-40d7-ada7-2d994afcc62a",
"url": "https://deps.sec.gitlab.com/packages/npm/debug/versions/1.0.5/advisories"
}
],
"links": [
{
"url": "https://nodesecurity.io/advisories/534"
},
{
"url": "https://github.com/visionmedia/debug/issues/501"
},
{
"url": "https://github.com/visionmedia/debug/pull/504"
}
]
},
{
2020-04-09 17:09:19 -04:00
"id": "5d681b13-e8fa-4668-957e-8d88f932ddc7",
2019-06-12 07:11:00 -04:00
"category": "dependency_scanning",
"name": "Authentication bypass via incorrect DOM traversal and canonicalization",
"message": "Authentication bypass via incorrect DOM traversal and canonicalization in saml2-js",
2020-08-09 17:10:01 -04:00
"description": "Some XML DOM traversal and canonicalization APIs may be inconsistent in handling of comments within XML nodes. Incorrect use of these APIs by some SAML libraries results in incorrect parsing of the inner text of XML nodes such that any inner text after the comment is lost prior to cryptographically signing the SAML message. Text after the comment, therefore, has no impact on the signature on the SAML message.\r\n\r\nA remote attacker can modify SAML content for a SAML service provider without invalidating the cryptographic signature, which may allow attackers to bypass primary authentication for the affected SAML service provider.",
2019-06-12 07:11:00 -04:00
"severity": "Unknown",
"solution": "Upgrade to fixed version.\r\n",
"scanner": {
"id": "gemnasium",
"name": "Gemnasium"
},
"location": {
"file": "yarn.lock",
"dependency": {
"package": {
"name": "saml2-js"
},
"version": "1.5.0"
}
},
"identifiers": [
{
"type": "gemnasium",
"name": "Gemnasium-9952e574-7b5b-46fa-a270-aeb694198a98",
"value": "9952e574-7b5b-46fa-a270-aeb694198a98",
"url": "https://deps.sec.gitlab.com/packages/npm/saml2-js/versions/1.5.0/advisories"
},
{
"type": "cve",
"name": "CVE-2017-11429",
"value": "CVE-2017-11429",
"url": "https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2017-11429"
}
],
"links": [
{
"url": "https://github.com/Clever/saml2/commit/3546cb61fd541f219abda364c5b919633609ef3d#diff-af730f9f738de1c9ad87596df3f6de84R279"
},
{
"url": "https://github.com/Clever/saml2/issues/127"
},
{
"url": "https://www.kb.cert.org/vuls/id/475445"
}
]
}
],
"remediations": [
{
"fixes": [
{
2020-04-09 17:09:19 -04:00
"id": "5d681b13-e8fa-4668-957e-8d88f932ddc7",
2019-06-12 07:11:00 -04:00
}
],
"summary": "Upgrade saml2-js",
"diff": "ZGlmZiAtLWdpdCBhL...OR0d1ZUc2THh3UT09Cg==" // some content is omitted for brevity
}
]
}
```
2019-06-07 06:48:46 -04:00
## Versioning and release process
Please check the [Release Process documentation ](https://gitlab.com/gitlab-org/security-products/release/blob/master/docs/release_process.md ).
2019-06-05 14:40:31 -04:00
## Contributing to the vulnerability database
You can search the [gemnasium-db ](https://gitlab.com/gitlab-org/security-products/gemnasium-db ) project
to find a vulnerability in the Gemnasium database.
2019-06-21 12:04:29 -04:00
You can also [submit new vulnerabilities ](https://gitlab.com/gitlab-org/security-products/gemnasium-db/blob/master/CONTRIBUTING.md ).
2019-07-25 10:16:25 -04:00
2020-09-29 02:09:45 -04:00
## Running dependency scanning in an offline environment
2020-04-21 11:21:10 -04:00
For self-managed GitLab instances in an environment with limited, restricted, or intermittent access
2020-09-29 02:09:45 -04:00
to external resources through the internet, some adjustments are required for dependency scanning
2020-05-06 14:09:38 -04:00
jobs to run successfully. For more information, see [Offline environments ](../offline_deployments/index.md ).
2020-04-21 11:21:10 -04:00
2020-09-29 02:09:45 -04:00
### Requirements for offline dependency scanning
2020-04-21 11:21:10 -04:00
2020-09-29 02:09:45 -04:00
Here are the requirements for using dependency scanning in an offline environment:
2020-04-21 11:21:10 -04:00
- GitLab Runner with the [`docker` or `kubernetes` executor ](#requirements ).
2020-09-29 02:09:45 -04:00
- Docker Container Registry with locally available copies of dependency scanning [analyzer ](https://gitlab.com/gitlab-org/security-products/analyzers ) images.
2020-10-26 08:08:44 -04:00
- If you have a limited access environment you will need to allow access, such as using a proxy, to the advisory database: `https://gitlab.com/gitlab-org/security-products/gemnasium-db.git` .
If you are unable to permit access to `https://gitlab.com/gitlab-org/security-products/gemnasium-db.git` you must host an offline copy of this `git` repository and set the `GEMNASIUM_DB_REMOTE_URL` variable to the URL of this repository. For more information on configuration variables, see [Dependency Scanning ](#configuring-dependency-scanning ).
This advisory database is constantly being updated, so you will need to periodically sync your local copy with GitLab's.
2020-04-21 11:21:10 -04:00
- _Only if scanning Ruby projects_: Host an offline Git copy of the [advisory database ](https://github.com/rubysec/ruby-advisory-db ).
- _Only if scanning npm/yarn projects_: Host an offline copy of the [retire.js ](https://github.com/RetireJS/retire.js/ ) [node ](https://github.com/RetireJS/retire.js/blob/master/repository/npmrepository.json ) and [js ](https://github.com/RetireJS/retire.js/blob/master/repository/jsrepository.json ) advisory databases.
2020-09-29 23:09:46 -04:00
Note that GitLab Runner has a [default `pull policy` of `always` ](https://docs.gitlab.com/runner/executors/docker.html#using-the-always-pull-policy ),
2020-09-14 23:09:24 -04:00
meaning the runner tries to pull Docker images from the GitLab container registry even if a local
copy is available. The GitLab Runner [`pull_policy` can be set to `if-not-present` ](https://docs.gitlab.com/runner/executors/docker.html#using-the-if-not-present-pull-policy )
2020-05-06 14:09:38 -04:00
in an offline environment if you prefer using only locally available Docker images. However, we
recommend keeping the pull policy setting to `always` if not in an offline environment, as this
enables the use of updated scanners in your CI/CD pipelines.
2020-04-21 11:21:10 -04:00
2020-09-29 02:09:45 -04:00
### Make GitLab dependency scanning analyzer images available inside your Docker registry
2020-04-21 11:21:10 -04:00
2020-09-29 02:09:45 -04:00
For dependency scanning with all [supported languages and frameworks ](#supported-languages-and-package-managers ),
import the following default dependency scanning analyzer images from `registry.gitlab.com` into
2020-05-06 14:09:38 -04:00
your [local Docker container registry ](../../packages/container_registry/index.md ):
2020-04-21 11:21:10 -04:00
```plaintext
registry.gitlab.com/gitlab-org/security-products/analyzers/gemnasium:2
registry.gitlab.com/gitlab-org/security-products/analyzers/gemnasium-maven:2
registry.gitlab.com/gitlab-org/security-products/analyzers/gemnasium-python:2
registry.gitlab.com/gitlab-org/security-products/analyzers/retire.js:2
registry.gitlab.com/gitlab-org/security-products/analyzers/bundler-audit:2
```
The process for importing Docker images into a local offline Docker registry depends on
**your network security policy**. Please consult your IT staff to find an accepted and approved
2020-05-05 23:09:33 -04:00
process by which external resources can be imported or temporarily accessed.
Note that these scanners are [updated periodically ](../index.md#maintenance-and-update-of-the-vulnerabilities-database )
with new definitions, so consider if you can make periodic updates yourself.
2020-04-21 11:21:10 -04:00
For details on saving and transporting Docker images as a file, see Docker's documentation on
[`docker save` ](https://docs.docker.com/engine/reference/commandline/save/ ), [`docker load` ](https://docs.docker.com/engine/reference/commandline/load/ ),
[`docker export` ](https://docs.docker.com/engine/reference/commandline/export/ ), and [`docker import` ](https://docs.docker.com/engine/reference/commandline/import/ ).
2020-10-13 17:09:27 -04:00
#### Support for Custom Certificate Authorities
Support for custom certificate authorities was introduced in the following versions.
| Analyzer | Version |
| -------- | ------- |
| `gemnasium` | [v2.8.0 ](https://gitlab.com/gitlab-org/security-products/analyzers/gemnasium/-/releases/v2.8.0 ) |
| `gemnasium-maven` | [v2.9.0 ](https://gitlab.com/gitlab-org/security-products/analyzers/gemnasium-maven/-/releases/v2.9.0 ) |
| `gemnasium-python` | [v2.7.0 ](https://gitlab.com/gitlab-org/security-products/analyzers/gemnasium-python/-/releases/v2.7.0 ) |
| `retire.js` | [v2.4.0 ](https://gitlab.com/gitlab-org/security-products/analyzers/retire.js/-/releases/v2.4.0 ) |
| `bundler-audit` | [v2.4.0 ](https://gitlab.com/gitlab-org/security-products/analyzers/bundler-audit/-/releases/v2.4.0 ) |
2020-09-29 02:09:45 -04:00
### Set dependency scanning CI job variables to use local dependency scanning analyzers
2020-04-21 11:21:10 -04:00
2020-07-22 17:09:50 -04:00
Add the following configuration to your `.gitlab-ci.yml` file. You must change the value of
`SECURE_ANALYZERS_PREFIX` to refer to your local Docker container registry. You must also change the
value of `GEMNASIUM_DB_REMOTE_URL` to the location of your offline Git copy of the
[gemnasium-db advisory database ](https://gitlab.com/gitlab-org/security-products/gemnasium-db/ ):
2020-04-21 11:21:10 -04:00
```yaml
include:
- template: Dependency-Scanning.gitlab-ci.yml
variables:
2020-06-17 17:08:24 -04:00
SECURE_ANALYZERS_PREFIX: "docker-registry.example.com/analyzers"
2020-05-18 14:08:22 -04:00
GEMNASIUM_DB_REMOTE_URL: "gitlab.example.com/gemnasium-db.git"
2020-04-21 11:21:10 -04:00
```
See explanations of the variables above in the [configuration section ](#configuration ).
### Specific settings for languages and package managers
2020-05-18 14:08:22 -04:00
See the following sections for configuring specific languages and package managers.
2020-04-21 11:21:10 -04:00
#### JavaScript (npm and yarn) projects
Add the following to the variables section of `.gitlab-ci.yml` :
```yaml
RETIREJS_JS_ADVISORY_DB: "example.com/jsrepository.json"
RETIREJS_NODE_ADVISORY_DB: "example.com/npmrepository.json"
```
#### Ruby (gem) projects
Add the following to the variables section of `.gitlab-ci.yml` :
```yaml
BUNDLER_AUDIT_ADVISORY_DB_REF_NAME: "master"
BUNDLER_AUDIT_ADVISORY_DB_URL: "gitlab.example.com/ruby-advisory-db.git"
```
#### Python (setuptools)
2020-05-05 23:09:33 -04:00
When using self-signed certificates for your private PyPi repository, no extra job configuration (aside
2020-04-21 11:21:10 -04:00
from the template `.gitlab-ci.yml` above) is needed. However, you must update your `setup.py` to
2020-05-05 23:09:33 -04:00
ensure that it can reach your private repository. Here is an example configuration:
2020-04-21 11:21:10 -04:00
2020-05-05 23:09:33 -04:00
1. Update `setup.py` to create a `dependency_links` attribute pointing at your private repository for each
2020-04-21 11:21:10 -04:00
dependency in the `install_requires` list:
2020-05-20 23:08:00 -04:00
```python
install_requires=['pyparsing>=2.0.3'],
dependency_links=['https://pypi.example.com/simple/pyparsing'],
```
2020-04-21 11:21:10 -04:00
1. Fetch the certificate from your repository URL and add it to the project:
2020-05-20 23:08:00 -04:00
```shell
echo -n | openssl s_client -connect pypi.example.com:443 | sed -ne '/-BEGIN CERTIFICATE-/,/-END CERTIFICATE-/p' > internal.crt
```
2020-04-21 11:21:10 -04:00
1. Point `setup.py` at the newly downloaded certificate:
2020-05-20 23:08:00 -04:00
```python
import setuptools.ssl_support
setuptools.ssl_support.cert_paths = ['internal.crt']
```
2020-04-21 11:21:10 -04:00
2020-05-14 14:08:06 -04:00
## Limitations
### Referencing local dependencies using a path in JavaScript projects
2020-05-18 14:08:22 -04:00
The [Retire.js ](https://gitlab.com/gitlab-org/security-products/analyzers/retire.js ) analyzer
doesn't support dependency references made with [local paths ](https://docs.npmjs.com/files/package.json#local-paths )
in the `package.json` of JavaScript projects. The dependency scan outputs the following error for
such references:
2020-05-14 14:08:06 -04:00
2020-05-19 23:08:04 -04:00
```plaintext
2020-05-14 14:08:06 -04:00
ERROR: Could not find dependencies: < dependency-name > . You may need to run npm install
```
2020-05-18 14:08:22 -04:00
As a workaround, remove the [`retire.js` ](analyzers.md#selecting-specific-analyzers ) analyzer from
[DS_DEFAULT_ANALYZERS ](#configuring-dependency-scanning ).
2019-09-09 01:47:49 -04:00
## Troubleshooting
2019-07-25 10:16:25 -04:00
2020-05-27 05:08:30 -04:00
### `Error response from daemon: error processing tar file: docker-tar: relocation error`
2019-07-25 10:16:25 -04:00
2020-09-29 02:09:45 -04:00
This error occurs when the Docker version that runs the dependency scanning job is `19.03.00` .
2020-05-05 23:09:33 -04:00
Consider updating to Docker `19.03.1` or greater. Older versions are not
2019-09-09 01:47:49 -04:00
affected. Read more in
2020-05-21 23:08:28 -04:00
[this issue ](https://gitlab.com/gitlab-org/gitlab/-/issues/13830#note_211354992 "Current SAST container fails" ).
2020-09-28 14:09:40 -04:00
2020-09-29 14:09:52 -04:00
### Getting warning message `gl-dependency-scanning-report.json: no matching files`
For information on this, see the [general Application Security troubleshooting section ](../../../ci/pipelines/job_artifacts.md#error-message-no-files-to-upload ).
2020-09-28 14:09:40 -04:00
### Limitation when using rules:exists
2020-09-29 02:09:45 -04:00
The [dependency scanning CI template ](https://gitlab.com/gitlab-org/gitlab/-/blob/master/lib/gitlab/ci/templates/Security/Dependency-Scanning.gitlab-ci.yml )
2020-09-28 14:09:40 -04:00
uses the [`rules:exists` ](../../../ci/yaml/README.md#rulesexists )
syntax. This directive is limited to 10000 checks and always returns `true` after reaching this
2020-09-29 02:09:45 -04:00
number. Because of this, and depending on the number of files in your repository, a dependency
scanning job might be triggered even if the scanner doesn't support your project.