<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                ThinkChat2.0新版上線,更智能更精彩,支持會話、畫圖、視頻、閱讀、搜索等,送10W Token,即刻開啟你的AI之旅 廣告
                # 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) :對于某些漏洞,提供了有關如何修復該漏洞的解決方案. [![Interacting with security reports](https://img.kancloud.cn/e3/cc/e3ccdf8deadd721aa072b30ab9f61284_1001x733.png)](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 中引入. 消除漏洞時,提供這樣做的理由通常很有幫助. 將漏洞的狀態設置為"已撤消"后,將出現一個文本框,供您添加有關撤消的評論. 添加后,您可以對其進行編輯或刪除. 隨著時間的推移,這使您可以添加和更新漏洞的上下文. [![Dismissed vulnerability comment](https://img.kancloud.cn/b8/c7/b8c788454b93d93d4d0d1a22624ae043_980x981.png)](img/adding_a_dismissal_reason_v13_0.png) #### Dismissing multiple vulnerabilities[](#dismissing-multiple-vulnerabilities "Permalink") 在[GitLab Ultimate](https://about.gitlab.com/pricing/) 12.9 中引入. 您可以提供多個可選原因,一次消除多個漏洞. 選中列表中每個漏洞旁邊的復選框,將選擇該單個漏洞. 或者,您可以通過選擇表標題中的復選框來選擇列表中的所有漏洞. 取消選中標題中的復選框將取消選擇列表中的所有漏洞. 選擇了某些漏洞后,表格頂部會顯示一個菜單,您可以通過該菜單選擇解雇原因. 按下"關閉選定的漏洞"按鈕將立即消除所有選定的漏洞,并說明您選擇的原因. [![Multiple vulnerability dismissal](https://img.kancloud.cn/de/da/deda3d52cb83893f922628afae508ee8_1095x224.png)](img/multi_select_v12_9.png) ### Creating an issue for a vulnerability[](#creating-an-issue-for-a-vulnerability "Permalink") 您可以通過從漏洞模式中選擇" **創建問題"**按鈕,或使用組安全性儀表板中漏洞行右側的"操作"按鈕來創建漏洞問題. 這在漏洞來自的項目中創建了一個[機密問題](../project/issues/confidential_issues.html) ,并使用從漏洞報告中獲取的一些有用信息對其進行了預填充. 創建問題后,您將重定向到該問題,以便您可以對其進行編輯,分配或評論. 返回組安全性儀表板后,該漏洞現在在名稱旁邊具有一個關聯的問題. [![Linked issue in the group security dashboard](https://img.kancloud.cn/03/51/03513db12001b33a8549055ea4b60d41_486x82.png)](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. 驗證并將更改提交到您的分支. [![Apply patch for dependency scanning](https://img.kancloud.cn/53/d2/53d2448473af1434af018f39a586f112_766x115.png)](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)任何漏洞都可以創建合并請求以自動解決問題. 如果可以使用此操作,則漏洞模式將包含" **創建合并請求"**按鈕. 單擊此按鈕創建合并請求,以將解決方案應用于源分支. [![Create merge request from vulnerability](https://img.kancloud.cn/c5/27/c5270f92466b1f99737d7ce3e2d41ae0_800x715.png)](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` (區分大小寫). [![Vulnerability Check Approver Rule](https://img.kancloud.cn/59/45/59451c00d2c52628e81aed5b006f9d11_1014x982.png)](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") 這意味著目標分支和源分支之間的最新公共祖先提交不是目標分支上的最新提交. 到目前為止,這是最常見的情況. 在這種情況下,您必須重新設置基礎或合并以合并來自目標分支的更改. [![Incorporate target branch changes](https://img.kancloud.cn/b6/4d/b64db500fe8e44d9f13d50100553aadb_1926x160.png)](img/outdated_report_branch_v12_9.png) ### Target branch security report is out of date[](#target-branch-security-report-is-out-of-date "Permalink") 發生這種情況的原因有很多,包括工作失敗或新的咨詢. 當合并請求顯示安全報告已過期時,必須在目標分支上運行新管道. 您可以按照提供的超鏈接運行新管道來快速完成此操作. [![Run a new pipeline](https://img.kancloud.cn/36/5b/365bab0007da4487a36c159c476dccc4_1936x162.png)](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)中提供了說明.
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看