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

Create a new custom detection rule

Create scanner-specific custom detection rules for Cloud Workload.

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

Go to Posture ManagementRules & PoliciesRulesCloud Workload.

On the Cloud Workload Rules page, select Create Custom Rule.

Enter rule details

Enter the following settings:

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

  • Description: Optional details or context for the rule, such as its purpose or intended behavior.

Select a scanner

Select a Scanner to execute the custom detection rule and its associated script:

  • Agentless Disk Scan

  • Kubernetes Connector

  • XDR Agent

Configure scanner settings

Configure the settings for the scanner you selected.

Agentless Disk Scan settings

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: Detect failed login attempts

Code

Script

Output

Example 2: Detect suspicious passwords

Code

Script

Output

Example 3: Detect weak shadow passwords

Code

Script

Output

Kubernetes Connector settings

Kubernetes Resources

From the drop-down, select one or more resource types:

  • Namespaces: Logical partitions that isolate and organize cluster resources.

  • ReplicaSets: Ensures a specified number of pod replicas run at all times.

  • Deployments: Manages pod replicas through declarative ReplicaSet updates, rollouts, and rollbacks.

  • StatefulSets: Deploys stateful applications with persistent identity and storage.

  • DaemonSets: Ensures a pod copy runs on all or selected nodes.

  • Jobs: Runs one-time or short-lived workloads that terminate after completion.

  • CronJobs: Defines jobs that run at scheduled times or intervals.

  • ClusterRoles: Defines cluster-level permissions across all namespaces.

  • Roles: Defines permissions within a specific namespace.

  • RoleBindings: Associates a role with users, groups, or service accounts in a namespace.

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

  • NetworkPolicies: Controls communication between pods and network entities.

  • Services: Exposes a set of pods as a network service.

  • ServiceAccounts: Provides a pod identity for Kubernetes API authentication.

  • Endpoints: Represents pod network addresses that back a service.

  • Ingresses: Manages external service access, HTTP/HTTPS routing, and load balancing.

  • ConfigMaps: Stores non-sensitive configuration data as key-value pairs.

  • Secrets: Securely stores sensitive data, such as API keys and certificates.

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

Define the Rule (Rego)

All custom Rego policies in Cortex must follow this pattern:

The custom rule must use the match term. Do not use deny or other terms.

XDR Agent settings

Field

Description

Custom Code Execution

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

Note: 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)

Use Python to define the custom detection logic.

This section supports syntax highlighting and validation (IntelliSense) to help users create accurate and efficient rules.

Use the default code in this box as a reference or starting point.

The custom Python scripts are intended to be executed exclusively for compliance checks and validations. To ensure the scripts are used properly and no security risks or unintended changes occur, the system implements the following restrictions and safeguards:

  • Only a predefined set of Python libraries and functions required for compliance checks are available for use. Libraries or functions that enable writing, deleting, or creating operations are excluded.

  • Only authorized users with specific permissions can create or update custom scripts. This ensures that only trusted individuals can define compliance checks.

Finalize the rule

Compliance Violation Severity

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

Compliance Controls

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

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

  1. Click Add.

  2. Select a custom compliance control from the list.

  3. Click Assign.

Remediation

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

Create

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.

Use the rule

Create an issue

Under Posture ManagementPoliciesCloud 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 ManagementComplianceCatalogsStandards, 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?