summaryrefslogtreecommitdiff
path: root/doc/user/application_security/policies/index.md
diff options
context:
space:
mode:
Diffstat (limited to 'doc/user/application_security/policies/index.md')
-rw-r--r--doc/user/application_security/policies/index.md335
1 files changed, 60 insertions, 275 deletions
diff --git a/doc/user/application_security/policies/index.md b/doc/user/application_security/policies/index.md
index 11f2b91177a..803f3983b96 100644
--- a/doc/user/application_security/policies/index.md
+++ b/doc/user/application_security/policies/index.md
@@ -17,8 +17,9 @@ can access these by navigating to your project's **Security & Compliance > Polic
GitLab supports the following security policies:
-- [Container Network Policy](#container-network-policy)
-- [Scan Execution Policy](#scan-execution-policy-schema)
+- [Scan Execution Policy](scan-execution-policies.md)
+- [Scan Result Policy](scan-result-policies.md)
+- [Container Network Policy](#container-network-policy) (DEPRECATED)
## Policy management
@@ -77,9 +78,62 @@ by the Rule mode, Rule mode is automatically
disabled. If the YAML is incorrect, you must use YAML
mode to fix your policy before Rule mode is available again.
+## Security Policies project
+
+NOTE:
+We recommend using the [Security Policies project](#security-policies-project)
+exclusively for managing policies for the project. Do not add your application's source code to such
+projects.
+
+The Security Policies feature is a repository to store policies. All security policies are stored in
+the `.gitlab/security-policies/policy.yml` YAML file. The format for this YAML is specific to the type of policy that is being stored there. Examples and schema information are available for the following policy types:
+
+- [Scan execution policy](scan-execution-policies.md#example-security-policies-project)
+- [Scan result policy](scan-result-policies.md#example-security-scan-result-policies-project)
+
+Policies created in this project are applied through a background job that runs once every 10
+minutes. Allow up to 10 minutes for any policy changes committed to this project to take effect.
+
+## Security Policy project selection
+
+NOTE:
+Only project Owners have the [permissions](../../permissions.md#project-members-permissions)
+to select Security Policy Project.
+
+When the Security Policy project is created and policies are created within that repository, you
+must create an association between that project and the project you want to apply policies to:
+
+1. On the top bar, select **Menu > Projects** and find your project.
+1. On the left sidebar, select **Security & Compliance > Policies**.
+1. Select **Edit Policy Project**, and search for and select the
+ project you would like to link from the dropdown menu.
+1. Select **Save**.
+
+ ![Security Policy Project](img/security_policy_project_v14_6.png)
+
+### Unlink Security Policy projects
+
+Project owners can unlink Security Policy projects from development projects. To do this, follow
+the steps described in [Security Policy project selection](#security-policy-project-selection),
+but select the trash can icon in the modal.
+
+## Scan execution policies
+
+See [Scan execution policies](scan-execution-policies.md).
+
+## Scan result policy editor
+
+See [Scan result policies](scan-result-policies.md).
+
## Container Network Policy
-> [Introduced](https://gitlab.com/gitlab-org/gitlab/-/issues/32365) in GitLab 12.9.
+> - [Introduced](https://gitlab.com/gitlab-org/gitlab/-/issues/32365) in GitLab 12.9.
+> - [Deprecated](https://gitlab.com/groups/gitlab-org/-/epics/7476) in GitLab 14.8, and planned for [removal](https://gitlab.com/groups/gitlab-org/-/epics/7477) in GitLab 15.0.
+
+WARNING:
+Container Network Policy is in its end-of-life process. It's [deprecated](https://gitlab.com/groups/gitlab-org/-/epics/7476)
+for use in GitLab 14.8, and planned for [removal](https://gitlab.com/groups/gitlab-org/-/epics/7477)
+in GitLab 15.0.
The **Container Network Policy** section provides packet flow metrics for
your application's Kubernetes namespace. This section has the following
@@ -159,7 +213,7 @@ at the bottom of the editor.
You can use policy alerts to track your policy's impact. Alerts are only available if you've
[installed](../../clusters/agent/repository.md)
-and [configured](../../clusters/agent/install/index.md#register-an-agent-with-gitlab)
+and [configured](../../clusters/agent/install/index.md#register-the-agent-with-gitlab)
an agent for this project.
There are two ways to create policy alerts:
@@ -176,276 +230,7 @@ There are two ways to create policy alerts:
Once added, the UI updates and displays a warning about the dangers of too many alerts.
-## Security Policies project
-
-NOTE:
-We recommend using the [Security Policies project](#security-policies-project)
-exclusively for managing policies for the project. Do not add your application's source code to such
-projects.
-
-The Security Policies feature is a repository to store policies. All security policies are stored as
-the `.gitlab/security-policies/policy.yml` YAML file with this format:
-
-```yaml
----
-scan_execution_policy:
-- name: Enforce DAST in every pipeline
- description: This policy enforces pipeline configuration to have a job with DAST scan
- enabled: true
- rules:
- - type: pipeline
- branches:
- - master
- actions:
- - scan: dast
- scanner_profile: Scanner Profile A
- site_profile: Site Profile B
-- name: Enforce DAST in every pipeline in main branch
- description: This policy enforces pipeline configuration to have a job with DAST scan for main branch
- enabled: true
- rules:
- - type: pipeline
- branches:
- - main
- actions:
- - scan: dast
- scanner_profile: Scanner Profile C
- site_profile: Site Profile D
-```
-
-## Security Policy project selection
-
-NOTE:
-Only project Owners have the [permissions](../../permissions.md#project-members-permissions)
-to select Security Policy Project.
-
-When the Security Policy project is created and policies are created within that repository, you
-must create an association between that project and the project you want to apply policies to:
-
-1. On the top bar, select **Menu > Projects** and find your project.
-1. On the left sidebar, select **Security & Compliance > Policies**.
-1. Select **Edit Policy Project**, and search for and select the
- project you would like to link from the dropdown menu.
-1. Select **Save**.
-
- ![Security Policy Project](img/security_policy_project_v14_6.png)
-
-### Unlink Security Policy projects
-
-Project owners can unlink Security Policy projects from development projects. To do this, follow
-the steps described in [Security Policy project selection](#security-policy-project-selection),
-but select the trash can icon in the modal.
-
-## Scan execution policies
-
-Project owners can use scan execution policies to require that security scans run on a specified
-schedule or with the project pipeline. Required scans are injected into the CI pipeline as new jobs
-with a long, random job name. In the unlikely event of a job name collision, the security policy job
-overwrites any pre-existing job in the pipeline.
-
-This feature has some overlap with [compliance framework pipelines](../../project/settings/#compliance-pipeline-configuration),
-as we have not [unified the user experience for these two features](https://gitlab.com/groups/gitlab-org/-/epics/7312).
-For details on the similarities and differences between these features, see
-[Enforce scan execution](../#enforce-scan-execution).
-
-### Scan Execution Policy editor
-
-NOTE:
-Only project Owners have the [permissions](../../permissions.md#project-members-permissions)
-to select Security Policy Project.
-
-Once your policy is complete, save it by selecting **Create via merge request**
-at the bottom of the editor. You are redirected to the merge request on the project's
-configured security policy project. If one does not link to your project, a security
-policy project is automatically created. Existing policies can also be
-removed from the editor interface by selecting **Delete policy**
-at the bottom of the editor.
-
-![Scan Execution Policy Editor YAML Mode](img/scan_execution_policy_yaml_mode_v14_7.png)
-
-The policy editor currently only supports the YAML mode. The Rule mode is tracked in the [Allow Users to Edit Rule-mode Scan Execution Policies in the Policy UI](https://gitlab.com/groups/gitlab-org/-/epics/5363) epic.
-
-### Scan Execution Policies Schema
-
-The YAML file with Scan Execution Policies consists of an array of objects matching Scan Execution Policy Schema nested under the `scan_execution_policy` key. You can configure a maximum of 5 policies under the `scan_execution_policy` key.
-
-When you save a new policy, GitLab validates its contents against [this JSON schema](https://gitlab.com/gitlab-org/gitlab/-/blob/master/ee/app/validators/json_schemas/security_orchestration_policy.json).
-If you're not familiar with how to read [JSON schemas](https://json-schema.org/),
-the following sections and tables provide an alternative.
-
-| Field | Type | Possible values | Description |
-|-------|------|-----------------|-------------|
-| `scan_execution_policy` | `array` of Scan Execution Policy | | List of scan execution policies (maximum 5) |
-
-### Scan Execution Policy Schema
-
-| Field | Type | Possible values | Description |
-|-------|------|-----------------|-------------|
-| `name` | `string` | | Name of the policy. |
-| `description` (optional) | `string` | | Description of the policy. |
-| `enabled` | `boolean` | `true`, `false` | Flag to enable (`true`) or disable (`false`) the policy. |
-| `rules` | `array` of rules | | List of rules that the policy applies. |
-| `actions` | `array` of actions | | List of actions that the policy enforces. |
-
-### `pipeline` rule type
-
-This rule enforces the defined actions whenever the pipeline runs for a selected branch.
-
-| Field | Type | Possible values | Description |
-|-------|------|-----------------|-------------|
-| `type` | `string` | `pipeline` | The rule's type. |
-| `branches` | `array` of `string` | `*` or the branch's name | The branch the given policy applies to (supports wildcard). |
-
-### `schedule` rule type
-
-This rule enforces the defined actions and schedules a scan on the provided date/time.
-
-| Field | Type | Possible values | Description |
-|------------|------|-----------------|-------------|
-| `type` | `string` | `schedule` | The rule's type. |
-| `branches` | `array` of `string` | `*` or the branch's name | The branch the given policy applies to (supports wildcard). |
-| `cadence` | `string` | CRON expression (for example, `0 0 * * *`) | A whitespace-separated string containing five fields that represents the scheduled time. |
-| `clusters` | `object` | | The cluster where the given policy enforces running selected scans (only for `container_scanning`/`cluster_image_scanning` scans). The key of the object is the name of the Kubernetes cluster configured for your project in GitLab. In the optionally provided value of the object, you can precisely select Kubernetes resources that are scanned. |
-
-#### `cluster` schema
-
-Use this schema to define `clusters` objects in the [`schedule` rule type](#schedule-rule-type).
-
-| Field | Type | Possible values | Description |
-|--------------|---------------------|--------------------------|-------------|
-| `containers` | `array` of `string` | | The container name that is scanned (only the first value is currently supported). |
-| `resources` | `array` of `string` | | The resource name that is scanned (only the first value is currently supported). |
-| `namespaces` | `array` of `string` | | The namespace that is scanned (only the first value is currently supported). |
-| `kinds` | `array` of `string` | `deployment`/`daemonset` | The resource kind that should be scanned (only the first value is currently supported). |
-
-### `scan` action type
-
-This action executes the selected `scan` with additional parameters when conditions for at least one
-rule in the defined policy are met.
-
-| Field | Type | Possible values | Description |
-|-------|------|-----------------|-------------|
-| `scan` | `string` | `dast`, `secret_detection`, `sast`, `container_scanning`, `cluster_image_scanning` | The action's type. |
-| `site_profile` | `string` | Name of the selected [DAST site profile](../dast/index.md#site-profile). | The DAST site profile to execute the DAST scan. This field should only be set if `scan` type is `dast`. |
-| `scanner_profile` | `string` or `null` | Name of the selected [DAST scanner profile](../dast/index.md#scanner-profile). | The DAST scanner profile to execute the DAST scan. This field should only be set if `scan` type is `dast`.|
-| `variables` | `object` | | Set of variables applied and enforced for the selected scan. The object's key is the variable name with a value provided as a string. |
-
-Note the following:
-
-- You must create the [site profile](../dast/index.md#site-profile) and [scanner profile](../dast/index.md#scanner-profile)
- with selected names for each project that is assigned to the selected Security Policy Project.
- Otherwise, the policy is not applied and a job with an error message is created instead.
-- Once you associate the site profile and scanner profile by name in the policy, it is not possible
- to modify or delete them. If you want to modify them, you must first disable the policy by setting
- the `active` flag to `false`.
-- When configuring policies with a scheduled DAST scan, the author of the commit in the security
- policy project's repository must have access to the scanner and site profiles. Otherwise, the scan
- is not scheduled successfully.
-- For a secret detection scan, only rules with the default ruleset are supported. [Custom rulesets](../secret_detection/index.md#custom-rulesets)
- are not supported.
-- A secret detection scan runs in `normal` mode when executed as part of a pipeline, and in
- [`historic`](../secret_detection/index.md#full-history-secret-detection)
- mode when executed as part of a scheduled scan.
-- A container scanning and cluster image scanning scans configured for the `pipeline` rule type ignores the cluster defined in the `clusters` object.
- They use predefined CI/CD variables defined for your project. Cluster selection with the `clusters` object is supported for the `schedule` rule type.
- Cluster with name provided in `clusters` object must be created and configured for the project. To be able to successfully perform the `container_scanning`/`cluster_image_scanning` scans for the cluster you must follow instructions for the [Cluster Image Scanning feature](../cluster_image_scanning/index.md#prerequisites).
-- The SAST scan uses the default template and runs in a [child pipeline](../../../ci/pipelines/parent_child_pipelines.md).
-
-### Example security policies project
-
-You can use this example in a `.gitlab/security-policies/policy.yml`, as described in
-[Security policies project](#security-policies-project).
-
-```yaml
----
-scan_execution_policy:
-- name: Enforce DAST in every release pipeline
- description: This policy enforces pipeline configuration to have a job with DAST scan for release branches
- enabled: true
- rules:
- - type: pipeline
- branches:
- - release/*
- actions:
- - scan: dast
- scanner_profile: Scanner Profile A
- site_profile: Site Profile B
-- name: Enforce DAST and secret detection scans every 10 minutes
- description: This policy enforces DAST and secret detection scans to run every 10 minutes
- enabled: true
- rules:
- - type: schedule
- branches:
- - main
- cadence: "*/10 * * * *"
- actions:
- - scan: dast
- scanner_profile: Scanner Profile C
- site_profile: Site Profile D
- - scan: secret_detection
-- name: Enforce Secret Detection and Container Scanning in every default branch pipeline
- description: This policy enforces pipeline configuration to have a job with Secret Detection and Container Scanning scans for the default branch
- enabled: true
- rules:
- - type: pipeline
- branches:
- - main
- actions:
- - scan: secret_detection
- - scan: sast
- variables:
- SAST_EXCLUDED_ANALYZERS: brakeman
- - scan: container_scanning
-- name: Enforce Cluster Image Scanning on production-cluster every 24h
- description: This policy enforces Cluster Image Scanning scan to run every 24 hours
- enabled: true
- rules:
- - type: schedule
- cadence: "15 3 * * *"
- clusters:
- production-cluster:
- containers:
- - database
- resources:
- - production-application
- namespaces:
- - production-namespace
- kinds:
- - deployment
- actions:
- - scan: cluster_image_scanning
-```
-
-In this example:
-
-- For every pipeline executed on branches that match the `release/*` wildcard (for example, branch
- `release/v1.2.1`), DAST scans run with `Scanner Profile A` and `Site Profile B`.
-- DAST and secret detection scans run every 10 minutes. The DAST scan runs with `Scanner Profile C`
- and `Site Profile D`.
-- Secret detection, container scanning, and SAST scans run for every pipeline executed on the `main`
- branch. The SAST scan runs with the `SAST_EXCLUDED_ANALYZER` variable set to `"brakeman"`.
-- Cluster Image Scanning scan runs every 24h. The scan runs on the `production-cluster` cluster and fetches vulnerabilities
- from the container with the name `database` configured for deployment with the name `production-application` in the `production-namespace` namespace.
-
-### Example for scan execution policy editor
-
-You can use this example in the YAML mode of the [Scan Execution Policy editor](#scan-execution-policy-editor).
-It corresponds to a single object from the previous example.
-
-```yaml
-name: Enforce Secret Detection and Container Scanning in every default branch pipeline
-description: This policy enforces pipeline configuration to have a job with Secret Detection and Container Scanning scans for the default branch
-enabled: true
-rules:
- - type: pipeline
- branches:
- - main
-actions:
- - scan: secret_detection
- - scan: container_scanning
-```
-
## Roadmap
-See the [Category Direction page](https://about.gitlab.com/direction/protect/container_network_security/)
-for more information on the product direction of Container Network Security.
+See the [Category Direction page](https://about.gitlab.com/direction/protect/security_orchestration/)
+for more information on the product direction of security policies within GitLab.