debian-mirror-gitlab/doc/user/application_security/threat_monitoring/index.md

195 lines
8.5 KiB
Markdown
Raw Normal View History

2020-04-22 19:07:51 +05:30
---
type: reference, howto
2021-01-29 00:20:46 +05:30
stage: Protect
2020-06-23 00:09:42 +05:30
group: Container Security
2021-02-22 17:27:13 +05:30
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/#assignments
2020-04-22 19:07:51 +05:30
---
# Threat Monitoring **(ULTIMATE)**
2020-06-23 00:09:42 +05:30
> [Introduced](https://gitlab.com/gitlab-org/gitlab/-/issues/14707) in [GitLab Ultimate](https://about.gitlab.com/pricing/) 12.9.
2020-04-22 19:07:51 +05:30
2020-06-23 00:09:42 +05:30
The **Threat Monitoring** page provides metrics and policy management
for the GitLab application runtime security features. You can access
these by navigating to your project's **Security & Compliance > Threat
Monitoring** page.
2020-04-22 19:07:51 +05:30
GitLab supports statistics for the following security features:
- [Container Network Policies](../../../topics/autodevops/stages.md#network-policy)
## Container Network Policy
2020-06-23 00:09:42 +05:30
> [Introduced](https://gitlab.com/gitlab-org/gitlab/-/issues/32365) in [GitLab Ultimate](https://about.gitlab.com/pricing/) 12.9.
2020-04-22 19:07:51 +05:30
The **Container Network Policy** section provides packet flow metrics for
your application's Kubernetes namespace. This section has the following
prerequisites:
2020-05-24 23:13:21 +05:30
- Your project contains at least one [environment](../../../ci/environments/index.md)
2021-09-30 23:02:18 +05:30
- You've [installed Cilium](../../project/clusters/protect/container_network_security/quick_start_guide.md#use-the-cluster-management-template-to-install-cilium)
2020-04-22 19:07:51 +05:30
- You've configured the [Prometheus service](../../project/integrations/prometheus.md#enabling-prometheus-integration)
If you're using custom Helm values for Cilium, you must enable Hubble
with flow metrics for each namespace by adding the following lines to
2021-09-30 23:02:18 +05:30
your [Cilium values](../../project/clusters/protect/container_network_security/quick_start_guide.md#use-the-cluster-management-template-to-install-cilium):
2020-04-22 19:07:51 +05:30
```yaml
2021-09-30 23:02:18 +05:30
hubble:
enabled: true
metrics:
enabled:
- 'flow:sourceContext=namespace;destinationContext=namespace'
2020-04-22 19:07:51 +05:30
```
The **Container Network Policy** section displays the following information
about your packet flow:
- The total amount of the inbound and outbound packets
- The proportion of packets dropped according to the configured
policies
- The per-second average rate of the forwarded and dropped packets
accumulated over time window for the requested time interval
If a significant percentage of packets is dropped, you should
investigate it for potential threats by
2021-09-30 23:02:18 +05:30
examining the Cilium logs:
```shell
kubectl -n gitlab-managed-apps logs -l k8s-app=cilium -c cilium-monitor
```
2020-06-23 00:09:42 +05:30
## Container Network Policy management
> [Introduced](https://gitlab.com/groups/gitlab-org/-/epics/3328) in [GitLab Ultimate](https://about.gitlab.com/pricing/) 13.1.
The **Threat Monitoring** page's **Policy** tab displays deployed
network policies for all available environments. You can check a
2021-09-04 01:27:46 +05:30
network policy's `yaml` manifest, its enforcement
2020-11-24 15:15:51 +05:30
status, and create and edit deployed policies. This section has the
following prerequisites:
2020-06-23 00:09:42 +05:30
- Your project contains at least one [environment](../../../ci/environments/index.md)
2021-09-30 23:02:18 +05:30
- You've [installed Cilium](../../project/clusters/protect/container_network_security/quick_start_guide.md#use-the-cluster-management-template-to-install-cilium)
2020-06-23 00:09:42 +05:30
Network policies are fetched directly from the selected environment's
deployment platform. Changes performed outside of this tab are
2021-09-04 01:27:46 +05:30
reflected upon refresh.
2020-06-23 00:09:42 +05:30
2020-10-24 23:57:45 +05:30
By default, the network policy list contains predefined policies in a
2021-02-22 17:27:13 +05:30
disabled state. Once enabled, a predefined policy deploys to the
2020-10-24 23:57:45 +05:30
selected environment's deployment platform and you can manage it like
the regular policies.
2021-01-03 14:25:43 +05:30
Note that if you're using [Auto DevOps](../../../topics/autodevops/index.md)
and change a policy in this section, your `auto-deploy-values.yaml` file doesn't update. Auto DevOps
users must make changes by following the
[Container Network Policy documentation](../../../topics/autodevops/stages.md#network-policy).
2020-06-23 00:09:42 +05:30
### Changing enforcement status
To change a network policy's enforcement status:
- Click the network policy you want to update.
2021-09-04 01:27:46 +05:30
- Click the **Edit policy** button.
- Click the **Policy status** toggle to update the selected policy.
- Click the **Save changes** button to deploy network policy changes.
2020-06-23 00:09:42 +05:30
2021-01-03 14:25:43 +05:30
Disabled network policies have the `network-policy.gitlab.com/disabled_by: gitlab` selector inside
the `podSelector` block. This narrows the scope of such a policy and as a result it doesn't affect
any pods. The policy itself is still deployed to the corresponding deployment namespace.
2020-11-24 15:15:51 +05:30
### Container Network Policy editor
> [Introduced](https://gitlab.com/groups/gitlab-org/-/epics/3403) in [GitLab Ultimate](https://about.gitlab.com/pricing/) 13.4.
2021-03-11 19:13:27 +05:30
You can use the policy editor to create, edit, and delete policies.
- To create a new policy, click the **New policy** button located in the **Policy** tab's header.
- To edit an existing policy, click **Edit policy** in the selected policy drawer.
The policy editor only supports the [CiliumNetworkPolicy](https://docs.cilium.io/en/v1.8/policy/)
specification. Regular Kubernetes [NetworkPolicy](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.19/#networkpolicy-v1-networking-k8s-io)
2020-11-24 15:15:51 +05:30
resources aren't supported.
The policy editor has two modes:
- The visual _Rule_ mode allows you to construct and preview policy
rules using rule blocks and related controls.
- YAML mode allows you to enter a policy definition in `.yaml` format
and is aimed at expert users and cases that the Rule mode doesn't
support.
You can use both modes interchangeably and switch between them at any
time. If a YAML resource is incorrect, Rule mode is automatically
disabled. You must use YAML mode to fix your policy before Rule mode
is available again.
Rule mode supports the following rule types:
- [Labels](https://docs.cilium.io/en/v1.8/policy/language/#labels-based).
- [Entities](https://docs.cilium.io/en/v1.8/policy/language/#entities-based).
- [IP/CIDR](https://docs.cilium.io/en/v1.8/policy/language/#ip-cidr-based). Only
the `toCIDR` block without `except` is supported.
- [DNS](https://docs.cilium.io/en/v1.8/policy/language/#dns-based).
- [Level 4](https://docs.cilium.io/en/v1.8/policy/language/#layer-4-examples)
can be added to all other rules.
Once your policy is complete, save it by pressing the **Save policy**
button at the bottom of the editor. Existing policies can also be
removed from the editor interface by clicking the **Delete policy**
button at the bottom of the editor.
2021-03-11 19:13:27 +05:30
### Configuring Network Policy Alerts
2021-09-04 01:27:46 +05:30
> - [Introduced](https://gitlab.com/groups/gitlab-org/-/epics/3438) and [enabled by default](https://gitlab.com/gitlab-org/gitlab/-/issues/287676) in [GitLab Ultimate](https://about.gitlab.com/pricing/) 13.9.
> - The feature flag was removed and the Threat Monitoring Alerts Project was [made generally available](https://gitlab.com/gitlab-org/gitlab/-/issues/287676) in GitLab 14.0.
2021-03-11 19:13:27 +05:30
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/index.md#create-an-agent-record-in-gitlab)
a Kubernetes Agent for this project.
There are two ways to create policy alerts:
- In the [policy editor UI](#container-network-policy-editor),
by clicking **Add alert**.
- In the policy editor's YAML mode, through the `metadata.annotations` property:
```yaml
metadata:
annotations:
app.gitlab.com/alert: 'true'
```
Once added, the UI updates and displays a warning about the dangers of too many alerts.
### Container Network Policy Alert list
> [Introduced](https://gitlab.com/groups/gitlab-org/-/epics/3438) in [GitLab Ultimate](https://about.gitlab.com/pricing/) 13.9.
2021-06-08 01:23:25 +05:30
The policy alert list displays your policy's alert activity. You can sort the list by these columns:
- Date and time
- Events
- Status
You can filter the list with the **Policy Name** filter and the **Status** filter at the top. Use
the selector menu in the **Status** column to set the status for each alert:
2021-03-11 19:13:27 +05:30
- Unreviewed
- In review
- Resolved
- Dismissed
2021-06-08 01:23:25 +05:30
By default, the list doesn't display resolved or dismissed alerts.
![Policy Alert List](img/threat_monitoring_policy_alert_list_v13_12.png)
2021-03-11 19:13:27 +05:30
2021-06-08 01:23:25 +05:30
Clicking an alert's row opens the alert drawer, which shows more information about the alert. A user
can also create an incident from the alert and update the alert status in the alert drawer.
2021-03-11 19:13:27 +05:30
2021-04-17 20:07:23 +05:30
Clicking an alert's name takes the user to the [alert details page](../../../operations/incident_management/alerts.md#alert-details-page).
2021-03-11 19:13:27 +05:30
For information on work in progress for the alerts dashboard, see [this epic](https://gitlab.com/groups/gitlab-org/-/epics/5041).