Skip to main content

Advanced Editor in the Test Builder

Use the Advanced editor to write complex test logic with nested properties, arrays, and JSON-based rules that go beyond the Builder tab's capabilities.

⚠️ Select your experience

The steps depend on your interface version. Select a link to skip to the instructions for your version.

Customers who joined Drata on or after Feb 24, 2026 are automatically on the New Experience.


Instructions for the New Experience ⬇️

The Advanced editor gives you greater flexibility when building custom tests, especially for evaluating nested properties, arrays, and complex logic that can't be expressed in the Builder tab.

You can:

  • Build test logic entirely in the Advanced editor, or

  • Start by selecting attributes, operators, and values in the Builder tab, then switch to the Advanced editor to refine or extend the logic

When you switch to the Advanced editor, Drata automatically converts your selected choices to the JSON-based rule set.

When to Use the Advanced Editor

Use the Advanced editor when you need to:

  • Evaluate nested objects or arrays

  • Apply complex AND / OR logic

  • Check multiple attributes within the same resource

  • Match tag key–value pairs (not just keys)

  • Build tests that go beyond the Builder tab's UI limitations

If you're new to custom tests, start with Create a Custom Test before using the Advanced editor.

How the Advanced Editor Works

Continuous Validation and Guidance

The editor provides real-time validation to help you build correct test logic:

  • Syntax and logic errors are highlighted instantly

  • Error messages identify the exact line and issue

  • Suggestions may be provided to help fix the problem

You cannot save test logic until all validation errors are resolved.

The editor supports IntelliSense to speed up test creation:

  • Press Ctrl + Space to view suggested values

  • Type "" and hover to see available options

  • Select a value to auto-populate it

Build Test Logic with the Advanced Editor

  1. Go to Monitoring

  2. Create or edit a custom test

  3. Enable Advanced editor within the condition group

Each code block supports up to 70 lines.

When starting from scratch, the editor displays this default structure:

{
"all": [
{
"fact": "",
"operator": "",
"value": ""
}
]
}

JSON Structure Explained

Top-Level Logical Operators

  • all → Logical AND — all conditions must evaluate to true

  • any → Logical OR — at least one condition must evaluate to true

You can nest all and any operators to create complex logic.

Condition Properties

Each condition includes:

  • fact: The attribute being evaluated (Builder tab: Attribute)

  • operator: How the value is compared

  • value: The expected state

{
"fact": "encryption.enabled",
"operator": "equal",
"value": true
}

Filtering Criteria (Include / Exclude)

You can define filtering criteria to narrow which resources are evaluated before conditions run.

Examples:

  • Exclude resources with a specific tag

  • Include only production resources

  • Ignore resources marked with DrataExclude

Filtering criteria can be edited or removed at any time.

Advanced JSON Examples

Multiple Conditions (AND logic)

Verify encryption is enabled and region is us-west-2:

{
"all": [
{
"fact": "Encryption",
"operator": "exist",
"value": true
},
{
"fact": "region",
"operator": "equals",
"value": "us-west-2"
}
]
}

Nested Object Property

Evaluate a nested object property using path:

{
"all": [
{
"fact": "MasterUserSecret",
"path": "KmsKeyId",
"operator": "equal",
"value": "xyz"
}
]
}

Array Evaluation (All Items)

Ensure all snapshots are encrypted:

{
"all": [
{
"fact": "dbInstanceSnapshots",
"operator": "all",
"value": {
"fact": "Encrypted",
"operator": "equal",
"value": true
}
}
]
}

Array with Multiple Conditions

Require snapshots to be encrypted and use a specific KMS key:

{
"all": [
{
"fact": "dbInstanceSnapshots",
"operator": "all",
"value": {
"all": [
{
"fact": "Encrypted",
"operator": "equal",
"value": true
},
{
"fact": "KmsKeyId",
"operator": "equal",
"value": "123"
}
]
}
}
]
}

Key Takeaways

  • Advanced editor enables complex, audit-grade test logic

  • Validation prevents broken or misleading tests

  • Drafts protect your compliance posture

  • Nested logic and arrays require the Advanced editor

  • Builder and Advanced editor are interchangeable when possible


Instructions for the Classic Experience ⬇️

The Advanced editor provides more flexibility and capability for building tests, especially when creating custom tests for nested properties. The Advanced editor can be used to build on top of the logic built through the Builder tab or used independently. For example, if you started creating a test through the Builder tab, you can finish it through the Advanced editor. The Advanced Editor will automatically convert the test logic built on the Builder tab as a JSON object on the Advanced editor.

Before using the Advanced editor to build custom test, ensure you know how to create a custom test.

Continuous syntax validation and guidance

When creating your JSON object for your custom test, the text editor continuously validates your the JSON syntax and logic so that you can receive instant feedback about the test logic you built or JSON syntax to have the most help when creating the test logic through our advance editor. The instant feedback will provide the specific lines the misconfigurations are found.

For example in the following image, there is no "operator" selected. The message indicates the line number followed by what the misconfiguration is. It can also suggest the potential solutions.

Advanced editor showing a validation error with no operator selected

The text editor can also suggest values for you to use by enabling IntelliSense. Enter Ctrl + Space to activate IntelliSense. Enter two quotes with a space (such as " ") and hover your mouse to view the suggested values; select the desired option to auto populate with that selected option.

Advanced editor showing IntelliSense suggestions when typing quotes

Create test logic with Advanced editor

Note: Each code block can have up to 70 lines.

On the Test Builder page, select the Advanced editor tab.

Let's discover what each of these properties mean.

  • Top-Level properties

    • "all": This represents a logical AND operation. All conditions within it must evaluate to true for the rule to be true.

    • "any": This represents a logical OR operation. Any of the conditions within it must evaluate to true for the rule to be true.

  • Nested properties

    • "fact": Enter the evaluated property. In the Builder tab, this is the Attribute field.

    • "operator": Select the comparison operator (for example, equal) between the "fact" and "value".

    • "value": Enter the value to compare against the property in the fact.

Filtering criteria

You can add an additional filtering criteria. The filtering criteria can be deleted or edited. Ensure to select the Exclusion or Inclusion option.

Filtering criteria section showing Exclusion and Inclusion options in the Advanced editor

After creating the test logic, ensure to save your changes.

Edit test logic with Advanced editor

To modify the JSON object within the editor, select the edit icon near the top right above the code block. Ensure to save your changes.

Advanced editor showing the edit icon in the top right above the code block

You will not be able to save the conditions in the advanced editor until it is valid.

Advanced editor showing a Save button greyed out due to a validation error

Switch between Builder and Advanced editor tab

After saving your work, you can verify if the test logic you built in the Advanced editor can be displayed in the Builder tab.

If the conditions you've entered in the Advanced editor can be shown in the Builder tab, you can seamlessly select the builder tab and the Builder tab will contain and display the logic there.

If the conditions you've created in the advanced editor are too complex for builder tab to automatically fill out the fields, then the tab will be greyed out as an indicator. Most of the time, test logic evaluating a nested property within an array cannot be shown in the Builder tab.

If you select the greyed out builder tab, you will receive a warning message and have the option to remove all of the test logic to go to the Builder tab (which is the Go to builder button) or continue your work on the Advanced editor tab (which is the Stay on editor button).

Warning modal showing Go to builder and Stay on editor options

Save a draft of your custom test

To save your custom test, you must resolve any JSON syntax issue or test logic. You can view the feedback underneath each code block to verify if your JSON object has any issues.

After building your draft custom test, on the Monitoring page, select your test. Within the Test logic section, you can view your JSON if the test logic you built was too complicated for your Builder tab.

Monitoring test details page showing JSON test logic in the Test logic section

JSON examples

The following sections showcase multiple scenarios when to use the Advanced editor, what kind of test logic can be created, and the example JSON syntax.

Multiple conditions

When you create a test to verify that both encryption is true and the region is us-west-2, you might need to add another condition. Here is a JSON example with two conditions.

{
"all": [
{
"fact": "Encryption",
"operator": "exist",
"value": "true"
},
{
"fact": "region",
"operator": "equals",
"value": "us-west-2"
}
]
}

Nested Properties

There can be an object or an array for the nested properties. The following sections showcase an example with the scenario and the JSON syntax.

Property Type: Object { }

If you would like to evaluate a property of an object, you can use an additional key, "path".

For example, the following code block showcases a part of the AWS DBInstances JSON.

{
"MasterUserSecret": {
"SecretArn": "STRING",
"SecretStatus": "STRING",
"KmsKeyId": "STRING"
}
}

I would like the "KmsKeyId" of the "MasterUserSecret" to be equal to "xyz":

{
"all": [
{
"fact": "MasterUserSecret",
"path": "KmsKeyId",
"operator": "equal",
"value": "xyz"
}
]
}

Property Type: Array [ ]

If the property is an array, you can create a nested condition in the value key of the parent property.

For example, this is a part of the AWS DBInstances JSON:

{
"dbInstanceSnapshots": [
{
"accountId": "STRING",
"Encrypted": "BOOLEAN",
"KmsKeyId": "STRING"
}
]
}

I would like to evaluate every dbInstanceSnapshots to be Encrypted: true.

  • Notice how the operator in the second level is "all". This is because I would like to evaluate every item within the array. Then the nested operator (or the third level operator) is "equal" so that I can verify if it is encrypted to be true.

{
"all": [
{
"fact": "dbInstanceSnapshots",
"operator": "all",
"value": {
"fact": "Encrypted",
"operator": "equal",
"value": true
}
}
]
}

Another scenario is if I would like every dbInstanceSnapshots to be Encrypted: true and KmsKeyId: 123.

{
"all": [
{
"fact": "dbInstanceSnapshots",
"operator": "all",
"value": {
"all": [
{
"fact": "Encrypted",
"operator": "equal",
"value": true
},
{
"fact": "KmsKeyId",
"operator": "equal",
"value": "123"
}
]
}
}
]
}

Tags: Key-Value Pair

Here is how you can configure conditions in the advanced editor to evaluate tags by Key-Value Pair. The builder will only let you match by the Key. For "fact", select the Tags value that corresponds with that resource. Verify your information with the Resource guide.

{
"all": [
{
"fact": "TagList",
"operator": "all",
"value": {
"all": [
{
"fact": "Key",
"operator": "equal",
"value": "key"
},
{
"fact": "Value",
"operator": "equal",
"value": "123"
}
]
}
}
]
}
Did this answer your question?