- Docs
- Reference
Rule DSL Reference
The complete grammar of archigov rules — scopes, matchers, operators, evidence and decision assertions, and how errors are treated.
A rule is a JSON object stored on a catalogue artefact (rule_json). Only adopted artefacts are evaluated in runs; drafts can be dry-run.
#Shape
Rule = ResourceRule | ApplicationRule
ResourceRule = { "scope": "resource", "match"?: Match, "assert": Assert }
ApplicationRule = { "scope": "application", "match"?: AppMatch, "assert": AppAssert }
Match = { "type"?: string, "typeIn"?: string[], "typePrefix"?: string, "where"?: Assert[] }
AppMatch = { "where"?: Assert[] } -- path assertions on name and app.*
Assert = { "path": string, "op": PathOp, "value"?: any }
| { "op": "evidence", "control": string, "source"?: Source, "state"?: State }
| { "op": "decisionConstraint", "topic": string }
| { "op": "lifecycle", "states"?: LifecycleState[], "unknown"?: "ignore" | "finding" }
AppAssert = { "op": "hasDecision", "topic": string, "type"?: string }
| { "op": "hasOwnerTag" }
| { "op": "maxResourcesOfType", "type": string, "max": number }
| { "op": "assessmentCurrent", "kind": "legacy" | "exit_plan" }
PathOp = "eq" | "neq" | "in" | "notIn" | "exists" | "missing" | "gte" | "lte" | "matches"
Source = "defender" | "azure_policy" | "manual"
State = "pass" | "fail" | "unknown"
LifecycleState = "supported" | "ending" | "extended" | "end_of_life"match.where takes path assertions only; evidence, decisionConstraint and lifecycle are resource-rule asserts.
#Match
All given conditions must hold. A resource rule with no match applies to every resource; an application rule with no match applies to every application.
| Key | Meaning |
|---|---|
type | Resource type equals, e.g. Microsoft.Storage/storageAccounts |
typeIn | Resource type is one of a list |
typePrefix | Resource type starts with, e.g. Microsoft.Sql |
where | Every path assertion in the list holds |
Type comparisons are case-insensitive. The type keys apply to resource rules only. An application rule may carry match.where, validated like a resource rule's, to choose which applications it checks — for example critical applications only.
#Paths
A path is a dotted path into the resource view:
| Path | Value |
|---|---|
name | Resource name |
type | Resource type |
location | Azure region (also props.location) |
tags.<key> | A tag value, e.g. tags.env, tags.owner |
props.<key> | A property; the normalised ones are below |
app.<key> | The owning application's classification; below |
lifecycle.<key> | The resource's support lifecycle; below |
An application rule's where sees the application's name and the same app.* paths; lifecycle.* is for resource rules only.
| Classification path | Value |
|---|---|
app.criticality | critical, important, standard, or null when unclassified |
app.regulated | true when an important business service, a critical or important function or an essential function depends on the application |
app.services | The names of the services that depend on it, comma-joined |
app.service_kinds | Their kinds — ibs, cif, essential_function, business_service — comma-joined |
The classification is refreshed from the latest tags at the start of every run, and rules read only the stored classification, never an AI suggestion. A resource outside any application sees a null app.criticality. See Criticality and Business Services.
{
"scope": "application",
"match": { "where": [ { "path": "app.regulated", "op": "eq", "value": true } ] },
"assert": { "op": "hasOwnerTag" }
}| Normalised property | Meaning |
|---|---|
props.publicAccess | Public network access is allowed |
props.minTlsVersion | Minimum TLS version, e.g. "1.2" |
props.httpsOnly | HTTP is redirected to HTTPS |
props.osSku | Operating system SKU |
props.location | Region |
| Lifecycle path | Value |
|---|---|
lifecycle.state | The resource's worst component state: supported, ending, extended, end_of_life, or unknown |
lifecycle.product | The worst component's product, e.g. windows-server |
lifecycle.cycle | Its version cycle, e.g. 2012-r2 |
lifecycle.eol | Its end of standard support (YYYY-MM-DD, or ended when the data gives no date) |
lifecycle.tracked | true for a lifecycle-tracked resource (virtual machine, App Service, PostgreSQL or MySQL flexible server, AKS cluster) or one a person has set components on |
The components are matched from collected facts or set by a person; see Legacy Register.
#Path Operators
| Op | Passes when | value |
|---|---|---|
eq | Equal (strings compare case-insensitively) | Any |
neq | Not equal | Any |
in | Equal to one of | Array |
notIn | Equal to none of | Array |
exists | Present, not null and not an empty string | — |
missing | Absent, null or an empty string | — |
gte | The value is a number greater than or equal to value | Number |
lte | The value is a number less than or equal to value | Number |
matches | The value is a string matching the regular expression (case-insensitive) | Pattern string |
A path that does not resolve is undefined: eq, in, gte, lte and matches fail on it, missing and notIn pass.
#Evidence Assertion
{ "op": "evidence", "control": "storage-public-access", "source": "defender", "state": "pass" }Looks up the latest imported evidence for the resource and control (from source, or any source if omitted) and requires its state to equal state (default pass).
- No evidence → a finding, no evidence imported for "control", at medium severity. Never a pass.
- Different state → a finding at the artefact's severity, carrying the evidence record.
The default control map produces these keys: storage-public-access, storage-secure-transfer, min-tls-1.2, db-public-network-access, web-https-only, kv-purge-protection, kv-soft-delete, cognitive-local-auth, cognitive-public-access and system-updates. Items the map does not know keep defender:<slug> or policy:<definitionName> until mapped in the evidence control map.
#Lifecycle Assertion
{ "op": "lifecycle", "states": ["extended", "end_of_life"], "unknown": "finding" }Resource scope. Produces a finding for each lifecycle-tracked resource whose worst component is in one of states (default ["end_of_life"]), citing the product, the version and its dates. Resources that are not tracked are skipped.
- Unknown version → no finding by default (
"unknown": "ignore"); with"unknown": "finding", a finding that the lifecycle could not be determined. - A state outside
supported,ending,extended,end_of_life, or anunknownother thanignoreorfinding, is a rule error.
#Decision Assertions
decisionConstraint (resource scope) — find the resource's application's accepted decision on topic. If its checkable constraint lists allowedTypes and the resource's type is not among them, the resource is a finding citing the decision. If the application has no accepted decision on the topic, the resource is skipped.
hasDecision (application scope) — the application must have an accepted decision on topic. With type, only applications owning a resource whose type starts with type are checked.
#Other Application Assertions
hasOwnerTag— at least one of the application's resources carries anownertag.maxResourcesOfType— the application has at mostmaxresources oftype.assessmentCurrent— withkind: "legacy", the application's yearly legacy assessment is in date and covers every legacy component. A due or stale assessment is a finding; an application with no legacy component never is. Withkind: "exit_plan", every provider the application relies on has an exit plan in date. The finding names the providers with none; an application that is not critical or important and supports no regulated service never produces one.
#Errors
Rules are validated when an artefact is saved and before every evaluation. An unknown scope or operator, a missing required field (topic, control, type, max, kind), or an invalid regular expression is a rule error: the run lists it under rule_errors, the artefact shows it, and it never counts as passing.
#Findings
Each failure becomes a finding keyed by artefact × element × application, with first-seen and last-seen dates, the artefact's severity, a message, and evidence: the path with expected and actual values, the imported evidence record, or the decision and its allowed types.
Something unclear or out of date? Write to hello@archigov.com or open an issue on GitHub.