API reference Policy gates
Policy gates
Rules an organisation writes once (known exploited vulnerabilities, end of life, finding age, leaked keys), scoped like notifications, and their violations. See docs/policy-gates.md.
A asset's policy gates
GET /assets/{id}/gate-policies
Policy gates: rules written once and scoped like notifications (docs/policy-gates.md). kind is known_exploited, end_of_life, finding_age or leaked_key, with its params; filters (asset_kinds, environments, exposure any|exposed, tags); mode off, warn (default) or enforce. What the asset inherits (inherited, each with from, state on, off or edit and copy_id) and its own policies, with can_manage.
Parameters
| Parameter | In | Type | Description |
|---|---|---|---|
id required | path | string |
Responses
Add a policy gate of the asset
POST /assets/{id}/gate-policies
Policy gates: rules written once and scoped like notifications (docs/policy-gates.md). kind is known_exploited, end_of_life, finding_age or leaked_key, with its params; filters (asset_kinds, environments, exposure any|exposed, tags); mode off, warn (default) or enforce. Adds a policy owned by the asset, with the fields of POST /gate-policies.
Parameters
| Parameter | In | Type | Description |
|---|---|---|---|
id required | path | string |
Request body
application/json, required: object
Responses
Turn an inherited policy gate on, off, or edit it for the asset
PUT /assets/{id}/gate-policies/inherited/{pid}
Policy gates: rules written once and scoped like notifications (docs/policy-gates.md). kind is known_exploited, end_of_life, finding_age or leaked_key, with its params; filters (asset_kinds, environments, exposure any|exposed, tags); mode off, warn (default) or enforce. state: off (turned off here, audited as gate_policy.exclude), on (applies again; an edited copy is deleted) or edit (the asset gets its own copy, audited as gate_policy.customise). Answers like the GET.
Parameters
| Parameter | In | Type | Description |
|---|---|---|---|
id required | path | string | |
pid required | path | string |
Request body
application/json, required: object
Responses
Replace a policy gate of the asset
PUT /assets/{id}/gate-policies/{pid}
Policy gates: rules written once and scoped like notifications (docs/policy-gates.md). kind is known_exploited, end_of_life, finding_age or leaked_key, with its params; filters (asset_kinds, environments, exposure any|exposed, tags); mode off, warn (default) or enforce. Replaces one of the asset's own policies (404 for another owner's).
Parameters
| Parameter | In | Type | Description |
|---|---|---|---|
id required | path | string | |
pid required | path | string |
Request body
application/json, required: object
Responses
Delete a policy gate of the asset
DELETE /assets/{id}/gate-policies/{pid}
Policy gates: rules written once and scoped like notifications (docs/policy-gates.md). kind is known_exploited, end_of_life, finding_age or leaked_key, with its params; filters (asset_kinds, environments, exposure any|exposed, tags); mode off, warn (default) or enforce. Deletes one of the asset's own policies; deleting an edited copy turns the inherited policy on again.
Parameters
| Parameter | In | Type | Description |
|---|---|---|---|
id required | path | string | |
pid required | path | string |
Responses
List policy gates
GET /gate-policies
Policy gates: rules written once and scoped like notifications (docs/policy-gates.md). kind is known_exploited, end_of_life, finding_age or leaked_key, with its params; filters (asset_kinds, environments, exposure any|exposed, tags); mode off, warn (default) or enforce. Every policy of the organisation, its projects and assets, each with off_projects and off_assets (where an inherited policy is turned off); also kinds and modes.
Responses
Add a policy gate
POST /gate-policies
Policy gates: rules written once and scoped like notifications (docs/policy-gates.md). kind is known_exploited, end_of_life, finding_age or leaked_key, with its params; filters (asset_kinds, environments, exposure any|exposed, tags); mode off, warn (default) or enforce. Adds an organisation policy: name, description, kind, params, filters, mode. Audited as gate_policy.create.
Request body
application/json, required: object
Responses
Check an asset against its policy gates
POST /gate-policies/check
Whether one asset passes the policy gates that apply to it now (docs/policy-gates.md, "In CI" and "At deploy"); used by stackurity scan --policy and stackurity policy check. Name the asset by one of asset_id, repository_url and image_digest (sha256:…, or name@sha256:…), or by collection_id (an upload) alone; source is ci, deploy or api (default), with optional commit and ref. Approved exceptions that have not expired are honoured. Answers result (pass, warn: violations of policies in warn mode only, fail: a violation of an enforced policy), asset_id, asset_name, policies_evaluated, policies_enforced, check_id and violations, each with policy_id, policy_name, mode, kind, reason, component, key, finding_id or leak_id, and link (absolute when the server's public URL is set). In the Community edition a policy in enforce mode counts as a warning and its violations carry enforce_requires_plan: true. Every check is recorded for audit; dry_run: true only answers policies_evaluated and policies_enforced, without reading findings or recording anything. A collector token may check only what it reports: a CI job's token its own repository, a token bound to a host that host, any collector token the asset of its own upload (collection_id).
Request body
application/json, required: object
Responses
List exceptions to policy gates
GET /gate-policies/exceptions
Exceptions to policy gates (docs/policy-gates.md, "Exceptions"): a policy does not count against an asset, one component on it, or one finding or leaked key on it, until an expiry capped by the risk policy's exception_max_days. Asked by anyone who sees the asset, decided by security or admin on it. Each with policy_id, policy_name, target_kind (asset, component, finding), asset_id, asset_name, finding_id or leak_id, component_key, target_label, reason, note, status (pending, approved, declined, ended; an approved one past its expiry is ended with end_reason expired), who asked and decided, requested_expires_at, expires_at, ended_at, end_reason, end_note. Also can_decide and second_approver. Narrowed to the assets the caller can see.
Parameters
| Parameter | In | Type | Description |
|---|---|---|---|
status | query | string | |
policy_id | query | integer | |
asset_id | query | integer | |
limit | query | integer | |
offset | query | integer |
Responses
Ask for an exception to a policy gate
POST /gate-policies/exceptions
Exceptions to policy gates (docs/policy-gates.md, "Exceptions"): a policy does not count against an asset, one component on it, or one finding or leaked key on it, until an expiry capped by the risk policy's exception_max_days. Asked by anyone who sees the asset, decided by security or admin on it. policy_id, asset_id, target_kind (asset, component with component_key, or finding with finding_id or leak_id), reason (accepted_risk, false_positive, mitigated, no_fix), note (required) and optional expires_at. 201 with the pending exception; 400 when the policy does not apply to the asset or the target is not on it; 409 while one for the same target is pending or in force. Audited as policy_exception.request.
Request body
application/json, required: object
Responses
An exception to a policy gate
GET /gate-policies/exceptions/{id}
Exceptions to policy gates (docs/policy-gates.md, "Exceptions"): a policy does not count against an asset, one component on it, or one finding or leaked key on it, until an expiry capped by the risk policy's exception_max_days. Asked by anyone who sees the asset, decided by security or admin on it. One exception, as in the list; 404 for one on an asset the caller cannot see.
Parameters
| Parameter | In | Type | Description |
|---|---|---|---|
id required | path | string |
Responses
Approve or decline an exception to a policy gate
POST /gate-policies/exceptions/{id}/decision
Exceptions to policy gates (docs/policy-gates.md, "Exceptions"): a policy does not count against an asset, one component on it, or one finding or leaked key on it, until an expiry capped by the risk policy's exception_max_days. Asked by anyone who sees the asset, decided by security or admin on it. {"decision": "approve" | "decline", "note", "expires_at"}; a decline needs a note. An approval ends at expires_at, else at the date asked for, else at the limit, never later than the limit. 409 when already decided. Audited as policy_exception.approve or policy_exception.decline.
Parameters
| Parameter | In | Type | Description |
|---|---|---|---|
id required | path | string |
Request body
application/json, required: object
Responses
End an exception to a policy gate early
POST /gate-policies/exceptions/{id}/end
Exceptions to policy gates (docs/policy-gates.md, "Exceptions"): a policy does not count against an asset, one component on it, or one finding or leaked key on it, until an expiry capped by the risk policy's exception_max_days. Asked by anyone who sees the asset, decided by security or admin on it. {"note"} (optional). The violations it covered count again (end_reason revoked). 409 for one not in force. Audited as policy_exception.end.
Parameters
| Parameter | In | Type | Description |
|---|---|---|---|
id required | path | string |
Request body
application/json, required: object
Responses
Policy gate violations
GET /gate-policies/violations
Policy gates: rules written once and scoped like notifications (docs/policy-gates.md). kind is known_exploited, end_of_life, finding_age or leaked_key, with its params; filters (asset_kinds, environments, exposure any|exposed, tags); mode off, warn (default) or enforce. Current violations of the policies that are not off, computed now: each with policy_id, policy_name, mode, kind, asset_id, asset_name, reason, finding_id or leak_id, component, key, link, violation_key.
Parameters
| Parameter | In | Type | Description |
|---|---|---|---|
policy_id | query | integer | |
asset_id | query | integer | |
project_id | query | integer |
Responses
A policy gate
GET /gate-policies/{id}
Policy gates: rules written once and scoped like notifications (docs/policy-gates.md). kind is known_exploited, end_of_life, finding_age or leaked_key, with its params; filters (asset_kinds, environments, exposure any|exposed, tags); mode off, warn (default) or enforce. One policy, with off_projects and off_assets.
Parameters
| Parameter | In | Type | Description |
|---|---|---|---|
id required | path | string |
Responses
Replace a policy gate
PUT /gate-policies/{id}
Policy gates: rules written once and scoped like notifications (docs/policy-gates.md). kind is known_exploited, end_of_life, finding_age or leaked_key, with its params; filters (asset_kinds, environments, exposure any|exposed, tags); mode off, warn (default) or enforce. Replaces a policy (a mode left out keeps the current one). Audited as gate_policy.mode when only the mode changes, else gate_policy.update.
Parameters
| Parameter | In | Type | Description |
|---|---|---|---|
id required | path | string |
Request body
application/json, required: object
Responses
Delete a policy gate
DELETE /gate-policies/{id}
Policy gates: rules written once and scoped like notifications (docs/policy-gates.md). kind is known_exploited, end_of_life, finding_age or leaked_key, with its params; filters (asset_kinds, environments, exposure any|exposed, tags); mode off, warn (default) or enforce. Deletes a policy; its daily history is kept. Audited as gate_policy.delete.
Parameters
| Parameter | In | Type | Description |
|---|---|---|---|
id required | path | string |
Responses
A project's policy gates
GET /projects/{id}/gate-policies
Policy gates: rules written once and scoped like notifications (docs/policy-gates.md). kind is known_exploited, end_of_life, finding_age or leaked_key, with its params; filters (asset_kinds, environments, exposure any|exposed, tags); mode off, warn (default) or enforce. What the project inherits (inherited, each with from, state on, off or edit and copy_id) and its own policies, with can_manage.
Parameters
| Parameter | In | Type | Description |
|---|---|---|---|
id required | path | string |
Responses
Add a policy gate of the project
POST /projects/{id}/gate-policies
Policy gates: rules written once and scoped like notifications (docs/policy-gates.md). kind is known_exploited, end_of_life, finding_age or leaked_key, with its params; filters (asset_kinds, environments, exposure any|exposed, tags); mode off, warn (default) or enforce. Adds a policy owned by the project, with the fields of POST /gate-policies.
Parameters
| Parameter | In | Type | Description |
|---|---|---|---|
id required | path | string |
Request body
application/json, required: object
Responses
Turn an inherited policy gate on, off, or edit it for the project
PUT /projects/{id}/gate-policies/inherited/{pid}
Policy gates: rules written once and scoped like notifications (docs/policy-gates.md). kind is known_exploited, end_of_life, finding_age or leaked_key, with its params; filters (asset_kinds, environments, exposure any|exposed, tags); mode off, warn (default) or enforce. state: off (turned off here, audited as gate_policy.exclude), on (applies again; an edited copy is deleted) or edit (the project gets its own copy, audited as gate_policy.customise). Answers like the GET.
Parameters
| Parameter | In | Type | Description |
|---|---|---|---|
id required | path | string | |
pid required | path | string |
Request body
application/json, required: object
Responses
Replace a policy gate of the project
PUT /projects/{id}/gate-policies/{pid}
Policy gates: rules written once and scoped like notifications (docs/policy-gates.md). kind is known_exploited, end_of_life, finding_age or leaked_key, with its params; filters (asset_kinds, environments, exposure any|exposed, tags); mode off, warn (default) or enforce. Replaces one of the project's own policies (404 for another owner's).
Parameters
| Parameter | In | Type | Description |
|---|---|---|---|
id required | path | string | |
pid required | path | string |
Request body
application/json, required: object
Responses
Delete a policy gate of the project
DELETE /projects/{id}/gate-policies/{pid}
Policy gates: rules written once and scoped like notifications (docs/policy-gates.md). kind is known_exploited, end_of_life, finding_age or leaked_key, with its params; filters (asset_kinds, environments, exposure any|exposed, tags); mode off, warn (default) or enforce. Deletes one of the project's own policies; deleting an edited copy turns the inherited policy on again.
Parameters
| Parameter | In | Type | Description |
|---|---|---|---|
id required | path | string | |
pid required | path | string |