For the complete documentation index, see llms.txt. This page is also available as Markdown.
Cortex Cloud Runtime

Create a new custom detection rule

Create a custom detection rule for cloud workload security risks.

Creating Custom Detection Rules give you the flexibility to define and enforce security best practices tailored to your organization's objectives, as well as regulatory requirements not already covered by the compliance standards in our catalog.

Before you begin

Ensure you have a custom compliance control defined to associate the Custom Detection Rule to. For more information, see Use a built-in or custom standard.

How to create a custom detection rule

  1. Go to Posture ManagementRules & PoliciesRulesCloud Workload.

  2. In the Cloud Workload Rules page, click Create Custom Rule.

  3. Enter the following settings:

    • Rule name: A descriptive name for the custom rule.

    • Description: An optional field for adding additional details or context about the rule, such as its purpose or intended behavior.

  4. Select a Scanner to execute the Custom Detection Rule and its associated script. The options are:

    • Agentless Disk Scan

    • Kubernetes Connector

    • XDR Agent

  5. Configure settings specific to the scanner you select.

Agentless Disk Scan settings
Field
Description

Operating System

The operating system targeted by the rule. The available options are:

  • Linux

  • Windows

Input file(s) path

The full file path for one or more files. For example, /nfs/an/disks/jj/home/dir/file.txt

Define the Rule (Rego)

Use Rego to define the custom detection logic.

Use the default code in this box as a reference or starting point. Click read here for more information how to use Rego syntax. Example 1

Example 2

Example 3

Kubernetes Connector Settings

Field

Description

Kubernetes Resources

From the drop down, select one or more from the following:

  • Namespaces: Logical partitions within a Kubernetes cluster that allow resource isolation and organization.

  • ReplicaSets: Ensures a specified number of pod replicas are running at all times by automatically scaling up or down.

  • Deployments: Manages and control pod replicas by providing declarative updates for ReplicaSets, enabling rolling updates and rollbacks.

  • StatefulSets: Deploys stateful applications that require persistent identity and storage, ensuring stable pod names and ordered scaling.

  • DaemonSets: Ensures that a copy of a specific pod runs on all or selected nodes in the cluster, commonly used for logging and monitoring agents.

  • Jobs: Runs one-time or short-lived workloads that complete execution and then terminate.

  • CronJobs: Defines scheduled jobs that run at specified times or intervals, similar to Linux cron jobs.

  • ClusterRoles: Defines permissions at the cluster level, granting access to resources across all namespaces.

  • Roles: Defines permissions within a specific namespace, restricting access to resources within that namespace.

  • RoleBindings: Associates a role with a user, group, or service account within a specific namespace.

  • ClusterRoleBindings: Associates a cluster role with users, groups, or service accounts at the cluster-wide level.

  • NetworkPolicies: Defines rules that control the communication between pods and other network entities within the cluster, enforcing security restrictions.

  • Services: Exposes a set of pods as a network service, allowing stable communication within and outside the cluster.

  • ServiceAccounts: Provides an identity for pods to authenticate against the Kubernetes API, allowing controlled access to resources.

  • Endpoints: Represents the actual network addresses of the pods backing a service, dynamically updated as pods start or stop.

  • Ingresses: Manages external access to services, providing HTTP/HTTPS routing, load balancing, and SSL termination.

  • ConfigMaps: Stores non-sensitive configuration data in key-value pairs, allowing applications to retrieve configuration without modifying container images.

  • Secrets: Securely stores and manage sensitive data, such as API keys, passwords, and certificates, in an encrypted format.

  • Nodes: Defines the physical or virtual machines that run the workloads in a Kubernetes cluster.

Define the Rule (Rego)

All custom Rego policies in Cortex must follow this pattern:

NOTE

The custom rule must use the match term (not deny or others) to function properly.

XDR Agent Settings
Field
Description

Custom Code Execution

NOTE

Enable this setting for the scanner to perform custom compliance checks by executing user-defined Python scripts.

Only users with the following roles can enable or disable Custom Code Execution:

  • Account Admin

  • Instance Administrator

  • Deployment Admin

  • Privileged Security Admin

Click Confirm to accept the following terms:

  • The Python scripts you provide will be executed in your cloud environment(s).

  • This capability is solely for the purpose of enabling you to define the compliance check rules for your cloud environment(s). Any other purposes are expressly prohibited.

  • Any actions involving WRITE, MODIFY, or DELETE operations of your cloud environment(s) are strictly prohibited. It is your responsibility to ensure that your custom Python scripts only perform read-only operations of your cloud environment(s) explicitly for compliance check purposes.

  • You are solely responsible for the quality, content, use, and execution results of your Python script. You assume all risks and liabilities arising from executing your Python script(s), including any potential errors, damages, or consequences resulting from its use.

After you confirm accepting the terms, the rest of the XDR Agent settings appear.

Operating System

The operating system targeted by the rule. The available options are:

  • Linux

  • Windows

Define the Rule (Python)

  1. For Compliance Violation Severity, define the severity level of the compliance violation to ensure proper categorization and prioritization. Possible values are:

    • Critical

    • High

    • Medium

    • Low

    • Informational

  2. For Compliance Controls, assign the rule to one or more existing compliance controls.

NOTE

Only Custom Detection Rules (not built-in rules) can be assigned to custom controls.

   a. Click Add.    b. Select a custom compliance control from the list.    c. Click Assign.

  1. For Remediation, you can optionally define the remediation steps to address any detected misconfiguration.

  2. Click Create. The new rule appears in the Rules List. You can now use the rule as a check to either create an issue or monitor adherence to a specific requirement.

Create an issue

Under Posture Management → Policies → Cloud Workload, add the Custom Detection Rule to a Policy. This policy automatically runs the rule and creates an issue if the check fails.

Monitor compliance adherence

Under Posture Management → Compliance → Catalogs → Standards, create a custom standard that includes the custom control associated with the Custom Detection Rule, and then create an assessment profile that runs the custom standard. You can then monitor the compliance results in a report. For more information, see Monitor and track compliance adherence.

Last updated

Was this helpful?