# GitLab Secure
> 原文:[https://docs.gitlab.com/ee/user/application_security/](https://docs.gitlab.com/ee/user/application_security/)
* [Quick start](#quick-start)
* [Override the default registry base address](#override-the-default-registry-base-address)
* [Security scanning tools](#security-scanning-tools)
* [Security Scanning with Auto DevOps](#security-scanning-with-auto-devops)
* [Maintenance and update of the vulnerabilities database](#maintenance-and-update-of-the-vulnerabilities-database)
* [Interacting with the vulnerabilities](#interacting-with-the-vulnerabilities)
* [View details of a DAST vulnerability](#view-details-of-a-dast-vulnerability)
* [Hide sensitive information in headers](#hide-sensitive-information-in-headers)
* [Dismissing a vulnerability](#dismissing-a-vulnerability)
* [Adding a dismissal reason](#adding-a-dismissal-reason)
* [Dismissing multiple vulnerabilities](#dismissing-multiple-vulnerabilities)
* [Creating an issue for a vulnerability](#creating-an-issue-for-a-vulnerability)
* [Solutions for vulnerabilities (auto-remediation)](#solutions-for-vulnerabilities-auto-remediation)
* [Manually applying the suggested patch](#manually-applying-the-suggested-patch)
* [Creating a merge request from a vulnerability](#creating-a-merge-request-from-a-vulnerability)
* [Security approvals in merge requests](#security-approvals-in-merge-requests)
* [Enabling Security Approvals within a project](#enabling-security-approvals-within-a-project)
* [Enabling License Approvals within a project](#enabling-license-approvals-within-a-project)
* [Working in an offline environment](#working-in-an-offline-environment)
* [Using private Maven repos](#using-private-maven-repos)
* [Outdated security reports](#outdated-security-reports)
* [Source branch is behind the target branch](#source-branch-is-behind-the-target-branch)
* [Target branch security report is out of date](#target-branch-security-report-is-out-of-date)
* [Troubleshooting](#troubleshooting)
* [Getting error message `sast job: stage parameter should be [some stage name here]`](#getting-error-message-sast-job-stage-parameter-should-be-some-stage-name-here)
* [Getting error message `sast job: config key may not be used with 'rules': only/except`](#getting-error-message-sast-job-config-key-may-not-be-used-with-rules-onlyexcept)
* [Transitioning your `only/except` syntax to `rules`](#transitioning-your-onlyexcept-syntax-to-rules)
* [Pin your templates to the deprecated versions](#pin-your-templates-to-the-deprecated-versions)
# GitLab Secure[](#gitlab-secure-ultimate "Permalink")
GitLab 可以檢查您的應用程序是否存在安全漏洞,這些漏洞可能導致未經授權的訪問,數據泄漏,服務拒絕等. GitLab 在合并請求中報告漏洞,因此您可以在合并之前修復它們. [安全儀表板](security_dashboard/index.html)提供了在項目,管道和組中檢測到的漏洞的高級視圖. " [威脅監視"](threat_monitoring/index.html)頁面提供了應用程序環境的運行時安全性度量. 使用提供的信息,您可以立即開始風險分析和補救.
有關 GitLab 的應用程序安全性的概述,請參閱[Security Deep Dive](https://www.youtube.com/watch?v=k4vEJnGYy84) .
## Quick start[](#quick-start "Permalink")
通過將以下內容添加到`.gitlab-ci.yml` ,可以快速開始進行依賴項掃描,許可證掃描,靜態應用程序安全測試(SAST)和秘密檢測.
```
include:
- template: Dependency-Scanning.gitlab-ci.yml
- template: License-Scanning.gitlab-ci.yml
- template: SAST.gitlab-ci.yml
- template: Secret-Detection.gitlab-ci.yml
```
要添加動態應用程序安全測試(DAST)掃描,請將以下內容添加到`.gitlab-ci.yml` ,并將`https://staging.example.com`替換為登臺服務器的網址:
```
include:
- template: DAST.gitlab-ci.yml
variables:
DAST_WEBSITE: https://staging.example.com
```
為確保 DAST 掃描程序*在*將應用程序部署到登臺服務器*之后*運行,請查閱[DAST 完整文檔](dast/index.html) .
要添加容器掃描,請遵循[容器掃描文檔中](container_scanning/index.html#requirements)列出的步驟.
要進一步配置任何其他掃描儀,請參閱每個掃描儀的文檔.
### Override the default registry base address[](#override-the-default-registry-base-address "Permalink")
默認情況下,GitLab 安全掃描程序使用`registry.gitlab.com/gitlab-org/security-products/analyzers`作為 Docker 映像的基址. 您可以通過將變量`SECURE_ANALYZERS_PREFIX`設置到另一個位置來全局覆蓋此位置. 請注意,這會同時影響所有掃描儀.
## Security scanning tools[](#security-scanning-tools "Permalink")
GitLab 使用以下工具來掃描和報告項目中發現的已知漏洞.
| 安全掃描工具 | Description |
| --- | --- |
| [Container Scanning](container_scanning/index.html) | 掃描 Docker 容器中的已知漏洞. |
| [Dependency List](dependency_list/index.html) | 查看項目的依存關系及其已知漏洞. |
| [Dependency Scanning](dependency_scanning/index.html) | 分析您的依賴項是否存在已知漏洞. |
| [Dynamic Application Security Testing (DAST)](dast/index.html) | 分析運行中的 Web 應用程序是否存在已知漏洞. |
| [Secret Detection](secret_detection/index.html) | 分析 Git 歷史記錄以了解泄露的機密. |
| [Security Dashboard](security_dashboard/index.html) | 查看所有項目和組中的漏洞. |
| [Static Application Security Testing (SAST)](sast/index.html) | Analyze source code for known vulnerabilities. |
## Security Scanning with Auto DevOps[](#security-scanning-with-auto-devops "Permalink")
啟用[自動 DevOps 時](../../topics/autodevops/) ,將使用默認設置配置所有 GitLab 安全掃描工具.
* [Auto SAST](../../topics/autodevops/stages.html#auto-sast-ultimate)
* [Auto Secret Detection](../../topics/autodevops/stages.html#auto-secret-detection-ultimate)
* [Auto DAST](../../topics/autodevops/stages.html#auto-dast-ultimate)
* [Auto Dependency Scanning](../../topics/autodevops/stages.html#auto-dependency-scanning-ultimate)
* [Auto License Compliance](../../topics/autodevops/stages.html#auto-license-compliance-ultimate)
* [Auto Container Scanning](../../topics/autodevops/stages.html#auto-container-scanning-ultimate)
雖然您無法直接自定義 Auto DevOps,但可以[在項目的`.gitlab-ci.yml`文件中包括 Auto DevOps 模板](../../topics/autodevops/customize.html#customizing-gitlab-ciyml) .
## Maintenance and update of the vulnerabilities database[](#maintenance-and-update-of-the-vulnerabilities-database "Permalink")
掃描工具和漏洞數據庫會定期更新.
| 安全掃描工具 | 漏洞數據庫更新 |
| --- | --- |
| [Container Scanning](container_scanning/index.html) | 使用`clair` . 通過運行[`latest` Docker image 標簽](https://gitlab.com/gitlab-org/gitlab/blob/438a0a56dc0882f22bdd82e700554525f552d91b/lib/gitlab/ci/templates/Security/Container-Scanning.gitlab-ci.yml#L37) ,每個作業都使用最新的`clair-db`版本. [根據作者的說法,](https://github.com/arminc/clair-local-scan#clair-server-or-local) `clair-db`數據庫[每天進行更新](https://github.com/arminc/clair-local-scan#clair-server-or-local) . |
| [Dependency Scanning](dependency_scanning/index.html) | 依賴于`bundler-audit` (對于 Ruby gems), `retire.js` (對于 NPM 軟件包)和`gemnasium` (GitLab 自己的所有庫工具). `bundler-audit`和`retire.js`從 GitHub 存儲庫中獲取漏洞數據,因此添加到`ruby-advisory-db`和`retire.js`立即可用. 如果有新版本,工具本身每月更新一次. [Gemnasium 數據庫](https://gitlab.com/gitlab-org/security-products/gemnasium-db)至少每周更新一次. 請參閱我們[當前從發布 CVE 到更新我們產品的時間度量](https://about.gitlab.com/handbook/engineering/development/performance-indicators/#cve-issue-to-update) . |
| [Dynamic Application Security Testing (DAST)](dast/index.html) | 掃描引擎會定期更新. 請參閱[基礎工具`zaproxy`](https://gitlab.com/gitlab-org/security-products/dast/blob/master/Dockerfile#L1)的[版本](https://gitlab.com/gitlab-org/security-products/dast/blob/master/Dockerfile#L1) . 掃描規則在掃描運行時下載. |
| [Static Application Security Testing (SAST)](sast/index.html) | Relies exclusively on [the tools GitLab wraps](sast/index.html#supported-languages-and-frameworks). The underlying analyzers are updated at least once per month if a relevant update is available. The vulnerabilities database is updated by the upstream tools. |
當前,您不必更新 GitLab 即可從最新的漏洞定義中受益. 安全工具作為 Docker 映像發布. 供應商的職位定義使他們能夠使用根據[語義版本控制的](https://semver.org/)主要發行標簽. 工具的每個新版本都會覆蓋這些標簽. Docker 映像已更新為與以前的 GitLab 版本匹配,因此用戶無需執行任何操作即可自動獲取最新版本的掃描工具. 但是,這種方法存在一些已知問題,并且有[解決這些問題](https://gitlab.com/gitlab-org/gitlab/-/issues/9725)的[計劃](https://gitlab.com/gitlab-org/gitlab/-/issues/9725) .
## Interacting with the vulnerabilities[](#interacting-with-the-vulnerabilities "Permalink")
在[GitLab Ultimate](https://about.gitlab.com/pricing/) 10.8 中引入.
合并請求報告或" [安全儀表板"](security_dashboard/index.html)中的每個安全漏洞都是可操作的. 單擊一個條目以查看具有多個選項的詳細信息:
* 消除[漏洞](#dismissing-a-vulnerability) :消除漏洞可在刪除線中設置樣式.
* [創建問題](#creating-an-issue-for-a-vulnerability) :創建一個新問題,其標題和說明已預先填充了漏洞報告中的信息. 默認情況下,此類問題是[機密的](../project/issues/confidential_issues.html) .
* [解決方案](#solutions-for-vulnerabilities-auto-remediation) :對于某些漏洞,提供了有關如何修復該漏洞的解決方案.
[](img/interacting_with_vulnerability_v13_0.png)
### View details of a DAST vulnerability[](#view-details-of-a-dast-vulnerability "Permalink")
DAST 檢測到的漏洞在實時 Web 應用程序中發生. 糾正這些類型的漏洞需要特定的信息. DAST 提供了調查和糾正根本原因所需的信息.
要查看 DAST 漏洞的詳細信息,請執行以下操作:
1. 要查看檢測到的所有漏洞:
* 在一個項目中,轉到該項目的 **安全和合規性**頁面.
* 僅在合并請求中,轉到合并請求的" **安全性"**選項卡.
2. 單擊漏洞的描述. 提供以下詳細信息:
| Field | Description |
| --- | --- |
| Description | Description of the vulnerability. |
| Project | 檢測到漏洞的名稱空間和項目. |
| Method | 用于檢測漏洞的 HTTP 方法. |
| URL | 檢測到漏洞的 URL. |
| 請求標題 | 請求的標題. |
| 回應狀態 | 從應用程序收到的響應狀態. |
| 響應標題 | 從應用程序收到的響應的標頭. |
| Evidence | 數據證據證明該漏洞. 通常是請求或響應的摘要,可以用來幫助驗證發現是否為漏洞. |
| Identifiers | 漏洞的標識符. |
| Severity | 漏洞的嚴重性. |
| 掃描儀類型 | 漏洞報告的類型. |
| Links | 鏈接到檢測到的漏洞的更多詳細信息. |
| Solution | 推薦的漏洞解決方案的詳細信息(可選). |
#### Hide sensitive information in headers[](#hide-sensitive-information-in-headers "Permalink")
HTTP 請求和響應標頭可能包含敏感信息,包括 cookie 和授權憑證. 默認情況下,特定標頭的內容在 DAST 漏洞報告中被屏蔽. 您可以指定要屏蔽的所有標題的列表. 有關詳細信息,請參閱[隱藏敏感信息](dast/index.html#hide-sensitive-information) .
### Dismissing a vulnerability[](#dismissing-a-vulnerability "Permalink")
要消除漏洞,必須將其狀態設置為"消除". 請按照以下步驟操作:
1. 在"安全儀表板"中選擇漏洞.
2. 從右上方的**狀態**選擇器菜單中選擇"已**關閉"** .
您可以通過從同一菜單中選擇其他狀態來撤消此操作.
#### Adding a dismissal reason[](#adding-a-dismissal-reason "Permalink")
在[GitLab Ultimate](https://about.gitlab.com/pricing/) 12.0 中引入.
消除漏洞時,提供這樣做的理由通常很有幫助. 將漏洞的狀態設置為"已撤消"后,將出現一個文本框,供您添加有關撤消的評論. 添加后,您可以對其進行編輯或刪除. 隨著時間的推移,這使您可以添加和更新漏洞的上下文.
[](img/adding_a_dismissal_reason_v13_0.png)
#### Dismissing multiple vulnerabilities[](#dismissing-multiple-vulnerabilities "Permalink")
在[GitLab Ultimate](https://about.gitlab.com/pricing/) 12.9 中引入.
您可以提供多個可選原因,一次消除多個漏洞. 選中列表中每個漏洞旁邊的復選框,將選擇該單個漏洞. 或者,您可以通過選擇表標題中的復選框來選擇列表中的所有漏洞. 取消選中標題中的復選框將取消選擇列表中的所有漏洞. 選擇了某些漏洞后,表格頂部會顯示一個菜單,您可以通過該菜單選擇解雇原因. 按下"關閉選定的漏洞"按鈕將立即消除所有選定的漏洞,并說明您選擇的原因.
[](img/multi_select_v12_9.png)
### Creating an issue for a vulnerability[](#creating-an-issue-for-a-vulnerability "Permalink")
您可以通過從漏洞模式中選擇" **創建問題"**按鈕,或使用組安全性儀表板中漏洞行右側的"操作"按鈕來創建漏洞問題.
這在漏洞來自的項目中創建了一個[機密問題](../project/issues/confidential_issues.html) ,并使用從漏洞報告中獲取的一些有用信息對其進行了預填充. 創建問題后,您將重定向到該問題,以便您可以對其進行編輯,分配或評論.
返回組安全性儀表板后,該漏洞現在在名稱旁邊具有一個關聯的問題.
[](img/issue.png)
### Solutions for vulnerabilities (auto-remediation)[](#solutions-for-vulnerabilities-auto-remediation "Permalink")
[Introduced](https://gitlab.com/gitlab-org/gitlab/-/issues/5656) in [GitLab Ultimate](https://about.gitlab.com/pricing/) 11.7.
可以通過應用 GitLab 自動生成的解決方案來修復某些漏洞. 支持以下掃描儀:
* [依賴項掃描](dependency_scanning/index.html) :自動補丁創建僅適用于使用`yarn`管理的 Node.js 項目.
* [Container Scanning](container_scanning/index.html)
#### Manually applying the suggested patch[](#manually-applying-the-suggested-patch "Permalink")
可以通過應用由 GitLab 自動生成的補丁來修復某些漏洞. 要應用此修復程序:
1. 單擊漏洞.
2. 下載并查看補丁文件`remediation.patch` .
3. 確保本地項目的簽出提交與生成補丁的提交相同.
4. Run `git apply remediation.patch`.
5. 驗證并將更改提交到您的分支.
[](img/vulnerability_solution.png)
#### Creating a merge request from a vulnerability[](#creating-a-merge-request-from-a-vulnerability "Permalink")
[Introduced](https://gitlab.com/gitlab-org/gitlab/-/issues/9224) in [GitLab Ultimate](https://about.gitlab.com/pricing/) 11.9.
在某些情況下,GitLab 允許您創建一個合并請求以自動修復漏洞. 具有[解決方案的](#solutions-for-vulnerabilities-auto-remediation)任何漏洞都可以創建合并請求以自動解決問題.
如果可以使用此操作,則漏洞模式將包含" **創建合并請求"**按鈕. 單擊此按鈕創建合并請求,以將解決方案應用于源分支.
[](img/create_issue_with_list_hover.png)
## Security approvals in merge requests[](#security-approvals-in-merge-requests "Permalink")
[Introduced](https://gitlab.com/gitlab-org/gitlab/-/issues/9928) in [GitLab Ultimate](https://about.gitlab.com/pricing/) 12.2.
可以將合并請求批準配置為在合并請求引入以下安全問題之一時,需要安全團隊成員的批準:
* 一個安全漏洞
* 違反軟件許可證規定
安全漏洞閾值定義為`high` , `critical`或`unknown`嚴重性. `Vulnerability-Check`批準者組必須批準包含漏洞的合并請求.
當 GitLab 可以評估漏洞的嚴重性時,等級可以是以下之一:
* `unknown`
* `low`
* `medium`
* `high`
* `critical`
`unknown`等級表明基礎掃描儀不包含或沒有提供嚴重等級.
### Enabling Security Approvals within a project[](#enabling-security-approvals-within-a-project "Permalink")
要啟用安全批準,必須使用區分大小寫的名稱`Vulnerability-Check`創建[項目批準規則](../project/merge_requests/merge_request_approvals.html#adding--editing-a-default-approval-rule) . 該批準組必須設置為所需的批準數量大于零. 您必須具有維護者或所有者[權限](../permissions.html#project-members-permissions)才能管理批準規則.
1. 導航到您項目的 **設置>常規,**然后展開**合并請求批準** .
2. 單擊**添加批準規則** ,或單擊**編輯** .
* 將**規則名稱**添加或更改為`Vulnerability-Check` (區分大小寫).
[](img/vulnerability-check_v13_0.png)
將這個組添加到您的項目后,將為所有合并請求啟用批準規則.
任何代碼更改都會導致重置所需的批準.
當安全報告:
* 包含`high` , `critical`或`unknown`嚴重性的新漏洞,無論被解雇如何.
* 在管道執行期間未生成.
在安全報告中,批準是可選的:
* 不包含任何新漏洞.
* 僅包含嚴重程度`low`或`medium`新漏洞.
## Enabling License Approvals within a project[](#enabling-license-approvals-within-a-project "Permalink")
[Introduced](https://gitlab.com/gitlab-org/gitlab/-/issues/13067) in [GitLab Ultimate](https://about.gitlab.com/pricing/) 12.3.
`License-Check`是一個批準規則,您可以啟用它來允許個人或組批準包含`denied`許可證的合并請求.
您可以啟用`License-Check`的兩種方式之一:
* 使用區分大小寫的名稱`License-Check`創建[項目批準規則](../project/merge_requests/merge_request_approvals.html#multiple-approval-rules-premium) .
* 在[項目策略部分中為許可合規](../compliance/license_compliance/index.html#policies)創建批準組. 您必須將此批準組的所需批準數量設置為大于零. 在項目中啟用該組后,將為所有合并請求啟用批準規則.
任何代碼更改都會導致重置所需的批準.
許可證報告如下時,需要批準:
* 包含包含被`denied`的軟件許可證的依賴項.
* 在管道執行期間未生成.
許可證報告如下時,批準是可選的:
* 不包含任何違反軟件許可證的行為.
* 僅包含`allowed`或未知的新許可證.
## Working in an offline environment[](#working-in-an-offline-environment "Permalink")
當未連接到 Internet 時,有時會在脫機,受限連接,局域網(LAN),Intranet 或"氣隙"環境中運行大多數 GitLab 安全掃描程序.
閱讀如何[在離線環境中操作安全掃描儀](offline_deployments/index.html) .
## Using private Maven repos[](#using-private-maven-repos "Permalink")
如果您有需要登錄憑據的私有 Apache Maven 存儲庫,則可以使用`MAVEN_CLI_OPTS`環境變量來傳遞用戶名和密碼. 您可以在項目的設置下進行設置,以免憑據在`.gitlab-ci.yml` .
如果用戶名是`myuser`并且密碼非常`verysecret`則可以在項目的設置下[設置以下變量](../../ci/variables/README.html#create-a-custom-variable-in-the-ui) :
| Type | Key | Value |
| --- | --- | --- |
| Variable | `MAVEN_CLI_OPTS` | `--settings mysettings.xml -Drepository.password=verysecret -Drepository.user=myuser` |
```
<!-- mysettings.xml -->
<settings>
...
<servers>
<server>
<id>private_server</id>
<username>${private.username}</username>
<password>${private.password}</password>
</server>
</servers>
</settings>
```
## Outdated security reports[](#outdated-security-reports "Permalink")
在 GitLab 12.7 中[引入](https://gitlab.com/gitlab-org/gitlab/-/issues/4913) .
當為合并請求生成的安全報告過時時,合并請求會在安全小部件中顯示警告消息,并提示您采取適當的措施.
這可能在兩種情況下發生:
1. Your [source branch is behind the target branch](#source-branch-is-behind-the-target-branch).
2. The [target branch security report is out of date](#target-branch-security-report-is-out-of-date).
### Source branch is behind the target branch[](#source-branch-is-behind-the-target-branch "Permalink")
這意味著目標分支和源分支之間的最新公共祖先提交不是目標分支上的最新提交. 到目前為止,這是最常見的情況.
在這種情況下,您必須重新設置基礎或合并以合并來自目標分支的更改.
[](img/outdated_report_branch_v12_9.png)
### Target branch security report is out of date[](#target-branch-security-report-is-out-of-date "Permalink")
發生這種情況的原因有很多,包括工作失敗或新的咨詢. 當合并請求顯示安全報告已過期時,必須在目標分支上運行新管道. 您可以按照提供的超鏈接運行新管道來快速完成此操作.
[](img/outdated_report_pipeline_v12_9.png)
## Troubleshooting[](#troubleshooting "Permalink")
### Getting error message `sast job: stage parameter should be [some stage name here]`[](#getting-error-message-sast-job-stage-parameter-should-be-some-stage-name-here "Permalink")
當[包括](../../ci/yaml/README.html#includetemplate)諸如[`SAST.gitlab-ci.yml`](https://gitlab.com/gitlab-org/gitlab/blob/master/lib/gitlab/ci/templates/Security/SAST.gitlab-ci.yml)的`.gitlab-ci.yml`模板時,根據您的 GitLab CI / CD 配置,可能會發生以下錯誤:
```
Found errors in your .gitlab-ci.yml:
* sast job: stage parameter should be unit-tests
```
如果未在`.gitlab-ci.yml`聲明包含作業的階段(名為`test` ),則會出現此錯誤. 要解決此問題,您可以:
* 在`.gitlab-ci.yml`添加一個`test`階段.
* 更改包含的安全作業的默認階段. 例如,使用 SpotBugs(SAST):
```
include:
template: SAST.gitlab-ci.yml
spotbugs-sast:
stage: unit-tests
```
[了解有關覆蓋 SAST 作業的更多信息](sast/index.html#overriding-sast-jobs) . 所有安全掃描工具都定義了它們的階段,因此,所有這些工具都可能發生此錯誤.
### Getting error message `sast job: config key may not be used with 'rules': only/except`[](#getting-error-message-sast-job-config-key-may-not-be-used-with-rules-onlyexcept "Permalink")
當[包括](../../ci/yaml/README.html#includetemplate)諸如[`SAST.gitlab-ci.yml`](https://gitlab.com/gitlab-org/gitlab/blob/master/lib/gitlab/ci/templates/Security/SAST.gitlab-ci.yml)的`.gitlab-ci.yml`模板時,根據您的 GitLab CI / CD 配置,可能會發生以下錯誤:
```
Found errors in your .gitlab-ci.yml:
jobs:sast config key may not be used with `rules`: only/except
```
當[`only`使用已棄用的或`except`語法`except`](../../ci/yaml/README.html#onlyexcept-basic) [覆蓋](sast/index.html#overriding-sast-jobs)了包含作業的`rules`配置時,將出現此錯誤[.](../../ci/yaml/README.html#onlyexcept-basic) 若要解決此問題,您必須:
* [Transition your `only/except` syntax to `rules`](#transitioning-your-onlyexcept-syntax-to-rules).
* (Temporarily) [Pin your templates to the deprecated versions](#pin-your-templates-to-the-deprecated-versions)
[Learn more on overriding SAST jobs](sast/index.html#overriding-sast-jobs).
#### Transitioning your `only/except` syntax to `rules`[](#transitioning-your-onlyexcept-syntax-to-rules "Permalink")
覆蓋模板以控制作業執行時, [`only`或`except`](../../ci/yaml/README.html#onlyexcept-basic)先前實例不再兼容,必須轉換為[`rules`語法](../../ci/yaml/README.html#rules) .
如果您的替代旨在將作業限制為僅在`master`運行,則先前的語法類似于:
```
include:
- template: SAST.gitlab-ci.yml
# Ensure that the scanning is only executed on master or merge requests
spotbugs-sast:
only:
refs:
- master
- merge_requests
```
要將上面的配置轉換為新的`rules`語法,重寫將如下編寫:
```
include:
- template: SAST.gitlab-ci.yml
# Ensure that the scanning is only executed on master or merge requests
spotbugs-sast:
rules:
- if: $CI_COMMIT_BRANCH == "master"
- if: $CI_MERGE_REQUEST_ID
```
如果您的覆蓋旨在限制作業僅在分支而不是標簽上運行,則其外觀類似于:
```
include:
- template: SAST.gitlab-ci.yml
# Ensure that the scanning is not executed on tags
spotbugs-sast:
except:
- tags
```
為了過渡到新的`rules`語法,重寫將被重寫為:
```
include:
- template: SAST.gitlab-ci.yml
# Ensure that the scanning is not executed on tags
spotbugs-sast:
rules:
- if: $CI_COMMIT_TAG == null
```
[Learn more on the usage of `rules`](../../ci/yaml/README.html#rules).
#### Pin your templates to the deprecated versions[](#pin-your-templates-to-the-deprecated-versions "Permalink")
為了確保獲得最新支持,我們**強烈**建議您遷移到[`rules`](../../ci/yaml/README.html#rules) .
如果您無法立即更新 CI 配置,則有幾種解決方法,其中涉及固定到以前的模板版本,例如:
```
include:
remote: 'https://gitlab.com/gitlab-org/gitlab/-/raw/12-10-stable-ee/lib/gitlab/ci/templates/Security/SAST.gitlab-ci.yml'
```
此外,我們提供了一個專用項目,其中包含版本控制的舊版模板. 這對于脫機設置或希望使用[Auto DevOps 的](../../topics/autodevops/index.html)任何人很有用.
[舊版模板項目](https://gitlab.com/gitlab-org/auto-devops-v12-10)中提供了說明.
- GitLab Docs
- Installation
- Requirements
- GitLab cloud native Helm Chart
- Install GitLab with Docker
- Installation from source
- Install GitLab on Microsoft Azure
- Installing GitLab on Google Cloud Platform
- Installing GitLab on Amazon Web Services (AWS)
- Analytics
- Code Review Analytics
- Productivity Analytics
- Value Stream Analytics
- Kubernetes clusters
- Adding and removing Kubernetes clusters
- Adding EKS clusters
- Adding GKE clusters
- Group-level Kubernetes clusters
- Instance-level Kubernetes clusters
- Canary Deployments
- Cluster Environments
- Deploy Boards
- GitLab Managed Apps
- Crossplane configuration
- Cluster management project (alpha)
- Kubernetes Logs
- Runbooks
- Serverless
- Deploying AWS Lambda function using GitLab CI/CD
- Securing your deployed applications
- Groups
- Contribution Analytics
- Custom group-level project templates
- Epics
- Manage epics
- Group Import/Export
- Insights
- Issues Analytics
- Iterations
- Public access
- SAML SSO for GitLab.com groups
- SCIM provisioning using SAML SSO for GitLab.com groups
- Subgroups
- Roadmap
- Projects
- GitLab Secure
- Security Configuration
- Container Scanning
- Dependency Scanning
- Dependency List
- Static Application Security Testing (SAST)
- Secret Detection
- Dynamic Application Security Testing (DAST)
- GitLab Security Dashboard
- Offline environments
- Standalone Vulnerability pages
- Security scanner integration
- Badges
- Bulk editing issues and merge requests at the project level
- Code Owners
- Compliance
- License Compliance
- Compliance Dashboard
- Create a project
- Description templates
- Deploy Keys
- Deploy Tokens
- File finder
- Project integrations
- Integrations
- Atlassian Bamboo CI Service
- Bugzilla Service
- Custom Issue Tracker service
- Discord Notifications service
- Enabling emails on push
- GitHub project integration
- Hangouts Chat service
- Atlassian HipChat
- Irker IRC Gateway
- GitLab Jira integration
- Mattermost Notifications Service
- Mattermost slash commands
- Microsoft Teams service
- Mock CI Service
- Prometheus integration
- Redmine Service
- Slack Notifications Service
- Slack slash commands
- GitLab Slack application
- Webhooks
- YouTrack Service
- Insights
- Issues
- Crosslinking Issues
- Design Management
- Confidential issues
- Due dates
- Issue Boards
- Issue Data and Actions
- Labels
- Managing issues
- Milestones
- Multiple Assignees for Issues
- Related issues
- Service Desk
- Sorting and ordering issue lists
- Issue weight
- Associate a Zoom meeting with an issue
- Merge requests
- Allow collaboration on merge requests across forks
- Merge Request Approvals
- Browser Performance Testing
- How to create a merge request
- Cherry-pick changes
- Code Quality
- Load Performance Testing
- Merge Request dependencies
- Fast-forward merge requests
- Merge when pipeline succeeds
- Merge request conflict resolution
- Reverting changes
- Reviewing and managing merge requests
- Squash and merge
- Merge requests versions
- Draft merge requests
- Members of a project
- Migrating projects to a GitLab instance
- Import your project from Bitbucket Cloud to GitLab
- Import your project from Bitbucket Server to GitLab
- Migrating from ClearCase
- Migrating from CVS
- Import your project from FogBugz to GitLab
- Gemnasium
- Import your project from GitHub to GitLab
- Project importing from GitLab.com to your private GitLab instance
- Import your project from Gitea to GitLab
- Import your Jira project issues to GitLab
- Migrating from Perforce Helix
- Import Phabricator tasks into a GitLab project
- Import multiple repositories by uploading a manifest file
- Import project from repo by URL
- Migrating from SVN to GitLab
- Migrating from TFVC to Git
- Push Options
- Releases
- Repository
- Branches
- Git Attributes
- File Locking
- Git file blame
- Git file history
- Repository mirroring
- Protected branches
- Protected tags
- Push Rules
- Reduce repository size
- Signing commits with GPG
- Syntax Highlighting
- GitLab Web Editor
- Web IDE
- Requirements Management
- Project settings
- Project import/export
- Project access tokens (Alpha)
- Share Projects with other Groups
- Snippets
- Static Site Editor
- Wiki
- Project operations
- Monitor metrics for your CI/CD environment
- Set up alerts for Prometheus metrics
- Embedding metric charts within GitLab-flavored Markdown
- Embedding Grafana charts
- Using the Metrics Dashboard
- Dashboard YAML properties
- Metrics dashboard settings
- Panel types for dashboards
- Using Variables
- Templating variables for metrics dashboards
- Prometheus Metrics library
- Monitoring AWS Resources
- Monitoring HAProxy
- Monitoring Kubernetes
- Monitoring NGINX
- Monitoring NGINX Ingress Controller
- Monitoring NGINX Ingress Controller with VTS metrics
- Alert Management
- Error Tracking
- Tracing
- Incident Management
- GitLab Status Page
- Feature Flags
- GitLab CI/CD
- GitLab CI/CD pipeline configuration reference
- GitLab CI/CD include examples
- Introduction to CI/CD with GitLab
- Getting started with GitLab CI/CD
- How to enable or disable GitLab CI/CD
- Using SSH keys with GitLab CI/CD
- Migrating from CircleCI
- Migrating from Jenkins
- Auto DevOps
- Getting started with Auto DevOps
- Requirements for Auto DevOps
- Customizing Auto DevOps
- Stages of Auto DevOps
- Upgrading PostgreSQL for Auto DevOps
- Cache dependencies in GitLab CI/CD
- GitLab ChatOps
- Cloud deployment
- Docker integration
- Building Docker images with GitLab CI/CD
- Using Docker images
- Building images with kaniko and GitLab CI/CD
- GitLab CI/CD environment variables
- Predefined environment variables reference
- Where variables can be used
- Deprecated GitLab CI/CD variables
- Environments and deployments
- Protected Environments
- GitLab CI/CD Examples
- Test a Clojure application with GitLab CI/CD
- Using Dpl as deployment tool
- Testing a Phoenix application with GitLab CI/CD
- End-to-end testing with GitLab CI/CD and WebdriverIO
- DevOps and Game Dev with GitLab CI/CD
- Deploy a Spring Boot application to Cloud Foundry with GitLab CI/CD
- How to deploy Maven projects to Artifactory with GitLab CI/CD
- Testing PHP projects
- Running Composer and NPM scripts with deployment via SCP in GitLab CI/CD
- Test and deploy Laravel applications with GitLab CI/CD and Envoy
- Test and deploy a Python application with GitLab CI/CD
- Test and deploy a Ruby application with GitLab CI/CD
- Test and deploy a Scala application to Heroku
- GitLab CI/CD for external repositories
- Using GitLab CI/CD with a Bitbucket Cloud repository
- Using GitLab CI/CD with a GitHub repository
- GitLab Pages
- GitLab Pages
- GitLab Pages domain names, URLs, and baseurls
- Create a GitLab Pages website from scratch
- Custom domains and SSL/TLS Certificates
- GitLab Pages integration with Let's Encrypt
- GitLab Pages Access Control
- Exploring GitLab Pages
- Incremental Rollouts with GitLab CI/CD
- Interactive Web Terminals
- Optimizing GitLab for large repositories
- Metrics Reports
- CI/CD pipelines
- Pipeline Architecture
- Directed Acyclic Graph
- Multi-project pipelines
- Parent-child pipelines
- Pipelines for Merge Requests
- Pipelines for Merged Results
- Merge Trains
- Job artifacts
- Pipeline schedules
- Pipeline settings
- Triggering pipelines through the API
- Review Apps
- Configuring GitLab Runners
- GitLab CI services examples
- Using MySQL
- Using PostgreSQL
- Using Redis
- Troubleshooting CI/CD
- GitLab Package Registry
- GitLab Container Registry
- Dependency Proxy
- GitLab Composer Repository
- GitLab Conan Repository
- GitLab Maven Repository
- GitLab NPM Registry
- GitLab NuGet Repository
- GitLab PyPi Repository
- API Docs
- API resources
- .gitignore API
- GitLab CI YMLs API
- Group and project access requests API
- Appearance API
- Applications API
- Audit Events API
- Avatar API
- Award Emoji API
- Project badges API
- Group badges API
- Branches API
- Broadcast Messages API
- Project clusters API
- Group clusters API
- Instance clusters API
- Commits API
- Container Registry API
- Custom Attributes API
- Dashboard annotations API
- Dependencies API
- Deploy Keys API
- Deployments API
- Discussions API
- Dockerfiles API
- Environments API
- Epics API
- Events
- Feature Flags API
- Feature flag user lists API
- Freeze Periods API
- Geo Nodes API
- Group Activity Analytics API
- Groups API
- Import API
- Issue Boards API
- Group Issue Boards API
- Issues API
- Epic Issues API
- Issues Statistics API
- Jobs API
- Keys API
- Labels API
- Group Labels API
- License
- Licenses API
- Issue links API
- Epic Links API
- Managed Licenses API
- Markdown API
- Group and project members API
- Merge request approvals API
- Merge requests API
- Project milestones API
- Group milestones API
- Namespaces API
- Notes API
- Notification settings API
- Packages API
- Pages domains API
- Pipeline schedules API
- Pipeline triggers API
- Pipelines API
- Project Aliases API
- Project import/export API
- Project repository storage moves API
- Project statistics API
- Project templates API
- Projects API
- Protected branches API
- Protected tags API
- Releases API
- Release links API
- Repositories API
- Repository files API
- Repository submodules API
- Resource label events API
- Resource milestone events API
- Resource weight events API
- Runners API
- SCIM API
- Search API
- Services API
- Application settings API
- Sidekiq Metrics API
- Snippets API
- Project snippets
- Application statistics API
- Suggest Changes API
- System hooks API
- Tags API
- Todos API
- Users API
- Project-level Variables API
- Group-level Variables API
- Version API
- Vulnerabilities API
- Vulnerability Findings API
- Wikis API
- GraphQL API
- Getting started with GitLab GraphQL API
- GraphQL API Resources
- API V3 to API V4
- Validate the .gitlab-ci.yml (API)
- User Docs
- Abuse reports
- User account
- Active sessions
- Deleting a User account
- Permissions
- Personal access tokens
- Profile preferences
- Threads
- GitLab and SSH keys
- GitLab integrations
- Git
- GitLab.com settings
- Infrastructure as code with Terraform and GitLab
- GitLab keyboard shortcuts
- GitLab Markdown
- AsciiDoc
- GitLab Notification Emails
- GitLab Quick Actions
- Autocomplete characters
- Reserved project and group names
- Search through GitLab
- Advanced Global Search
- Advanced Syntax Search
- Time Tracking
- GitLab To-Do List
- Administrator Docs
- Reference architectures
- Reference architecture: up to 1,000 users
- Reference architecture: up to 2,000 users
- Reference architecture: up to 3,000 users
- Reference architecture: up to 5,000 users
- Reference architecture: up to 10,000 users
- Reference architecture: up to 25,000 users
- Reference architecture: up to 50,000 users
- Troubleshooting a reference architecture set up
- Working with the bundled Consul service
- Configuring PostgreSQL for scaling
- Configuring GitLab application (Rails)
- Load Balancer for multi-node GitLab
- Configuring a Monitoring node for Scaling and High Availability
- NFS
- Working with the bundled PgBouncer service
- Configuring Redis for scaling
- Configuring Sidekiq
- Admin Area settings
- Continuous Integration and Deployment Admin settings
- Custom instance-level project templates
- Diff limits administration
- Enable and disable GitLab features deployed behind feature flags
- Geo nodes Admin Area
- GitLab Pages administration
- Health Check
- Job logs
- Labels administration
- Log system
- PlantUML & GitLab
- Repository checks
- Repository storage paths
- Repository storage types
- Account and limit settings
- Service templates
- System hooks
- Changing your time zone
- Uploads administration
- Abuse reports
- Activating and deactivating users
- Audit Events
- Blocking and unblocking users
- Broadcast Messages
- Elasticsearch integration
- Gitaly
- Gitaly Cluster
- Gitaly reference
- Monitoring GitLab
- Monitoring GitLab with Prometheus
- Performance Bar
- Usage statistics
- Object Storage
- Performing Operations in GitLab
- Cleaning up stale Redis sessions
- Fast lookup of authorized SSH keys in the database
- Filesystem Performance Benchmarking
- Moving repositories managed by GitLab
- Run multiple Sidekiq processes
- Sidekiq MemoryKiller
- Switching to Puma
- Understanding Unicorn and unicorn-worker-killer
- User lookup via OpenSSH's AuthorizedPrincipalsCommand
- GitLab Package Registry administration
- GitLab Container Registry administration
- Replication (Geo)
- Geo database replication
- Geo with external PostgreSQL instances
- Geo configuration
- Using a Geo Server
- Updating the Geo nodes
- Geo with Object storage
- Docker Registry for a secondary node
- Geo for multiple nodes
- Geo security review (Q&A)
- Location-aware Git remote URL with AWS Route53
- Tuning Geo
- Removing secondary Geo nodes
- Geo data types support
- Geo Frequently Asked Questions
- Geo Troubleshooting
- Geo validation tests
- Disaster Recovery (Geo)
- Disaster recovery for planned failover
- Bring a demoted primary node back online
- Automatic background verification
- Rake tasks
- Back up and restore GitLab
- Clean up
- Namespaces
- Maintenance Rake tasks
- Geo Rake Tasks
- GitHub import
- Import bare repositories
- Integrity check Rake task
- LDAP Rake tasks
- Listing repository directories
- Praefect Rake tasks
- Project import/export administration
- Repository storage Rake tasks
- Generate sample Prometheus data
- Uploads migrate Rake tasks
- Uploads sanitize Rake tasks
- User management
- Webhooks administration
- X.509 signatures
- Server hooks
- Static objects external storage
- Updating GitLab
- GitLab release and maintenance policy
- Security
- Password Storage
- Custom password length limits
- Restrict allowed SSH key technologies and minimum length
- Rate limits
- Webhooks and insecure internal web services
- Information exclusivity
- How to reset your root password
- How to unlock a locked user from the command line
- User File Uploads
- How we manage the TLS protocol CRIME vulnerability
- User email confirmation at sign-up
- Security of running jobs
- Proxying assets
- CI/CD Environment Variables
- Contributor and Development Docs
- Contribute to GitLab
- Community members & roles
- Implement design & UI elements
- Issues workflow
- Merge requests workflow
- Code Review Guidelines
- Style guides
- GitLab Architecture Overview
- CI/CD development documentation
- Database guides
- Database Review Guidelines
- Database Review Guidelines
- Migration Style Guide
- What requires downtime?
- Understanding EXPLAIN plans
- Rake tasks for developers
- Mass inserting Rails models
- GitLab Documentation guidelines
- Documentation Style Guide
- Documentation structure and template
- Documentation process
- Documentation site architecture
- Global navigation
- GitLab Docs monthly release process
- Telemetry Guide
- Usage Ping Guide
- Snowplow Guide
- Experiment Guide
- Feature flags in development of GitLab
- Feature flags process
- Developing with feature flags
- Feature flag controls
- Document features deployed behind feature flags
- Frontend Development Guidelines
- Accessibility & Readability
- Ajax
- Architecture
- Axios
- Design Patterns
- Frontend Development Process
- DropLab
- Emojis
- Filter
- Frontend FAQ
- GraphQL
- Icons and SVG Illustrations
- InputSetter
- Performance
- Principles
- Security
- Tooling
- Vuex
- Vue
- Geo (development)
- Geo self-service framework (alpha)
- Gitaly developers guide
- GitLab development style guides
- API style guide
- Go standards and style guidelines
- GraphQL API style guide
- Guidelines for shell commands in the GitLab codebase
- HTML style guide
- JavaScript style guide
- Migration Style Guide
- Newlines style guide
- Python Development Guidelines
- SCSS style guide
- Shell scripting standards and style guidelines
- Sidekiq debugging
- Sidekiq Style Guide
- SQL Query Guidelines
- Vue.js style guide
- Instrumenting Ruby code
- Testing standards and style guidelines
- Flaky tests
- Frontend testing standards and style guidelines
- GitLab tests in the Continuous Integration (CI) context
- Review Apps
- Smoke Tests
- Testing best practices
- Testing levels
- Testing Rails migrations at GitLab
- Testing Rake tasks
- End-to-end Testing
- Beginner's guide to writing end-to-end tests
- End-to-end testing Best Practices
- Dynamic Element Validation
- Flows in GitLab QA
- Page objects in GitLab QA
- Resource class in GitLab QA
- Style guide for writing end-to-end tests
- Testing with feature flags
- Translate GitLab to your language
- Internationalization for GitLab
- Translating GitLab
- Proofread Translations
- Merging translations from CrowdIn
- Value Stream Analytics development guide
- GitLab subscription
- Activate GitLab EE with a license