Stackurity Start free trial

API reference Policy gates

Policy gates

22 operations. Base URL https://app.stackurity.dev/api/v1 on Stackurity Cloud; see authentication.

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

Role: security on the asset

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

ParameterInTypeDescription
id requiredpathstring

Responses

StatusMeaningBody
2XXSuccessobject
4XXAn errorError
5XXAn errorError

Add a policy gate of the asset

POST /assets/{id}/gate-policies

Role: admin of the asset

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

ParameterInTypeDescription
id requiredpathstring

Request body

application/json, required: object

Responses

StatusMeaningBody
2XXSuccessobject
4XXAn errorError
5XXAn errorError

Turn an inherited policy gate on, off, or edit it for the asset

PUT /assets/{id}/gate-policies/inherited/{pid}

Role: admin of the asset

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

ParameterInTypeDescription
id requiredpathstring
pid requiredpathstring

Request body

application/json, required: object

Responses

StatusMeaningBody
2XXSuccessobject
4XXAn errorError
5XXAn errorError

Replace a policy gate of the asset

PUT /assets/{id}/gate-policies/{pid}

Role: admin of the asset

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

ParameterInTypeDescription
id requiredpathstring
pid requiredpathstring

Request body

application/json, required: object

Responses

StatusMeaningBody
2XXSuccessobject
4XXAn errorError
5XXAn errorError

Delete a policy gate of the asset

DELETE /assets/{id}/gate-policies/{pid}

Role: admin of the asset

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

ParameterInTypeDescription
id requiredpathstring
pid requiredpathstring

Responses

StatusMeaningBody
2XXSuccess (usually 204 No Content)no body
4XXAn errorError
5XXAn errorError

List policy gates

GET /gate-policies

Role: security

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

StatusMeaningBody
2XXSuccessobject
4XXAn errorError
5XXAn errorError

Add a policy gate

POST /gate-policies

Role: admin

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

StatusMeaningBody
2XXSuccessobject
4XXAn errorError
5XXAn errorError

Check an asset against its policy gates

POST /gate-policies/check

Role: viewer (on the asset or its project), or a collector token for its own asset

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

StatusMeaningBody
2XXSuccessobject
4XXAn errorError
5XXAn errorError

List exceptions to policy gates

GET /gate-policies/exceptions

Role: viewer

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

ParameterInTypeDescription
statusquerystring
policy_idqueryinteger
asset_idqueryinteger
limitqueryinteger
offsetqueryinteger

Responses

StatusMeaningBody
2XXSuccessobject
4XXAn errorError
5XXAn errorError

Ask for an exception to a policy gate

POST /gate-policies/exceptions

Role: viewer on the asset

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

StatusMeaningBody
2XXSuccessobject
4XXAn errorError
5XXAn errorError

An exception to a policy gate

GET /gate-policies/exceptions/{id}

Role: viewer

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

ParameterInTypeDescription
id requiredpathstring

Responses

StatusMeaningBody
2XXSuccessobject
4XXAn errorError
5XXAn errorError

Approve or decline an exception to a policy gate

POST /gate-policies/exceptions/{id}/decision

Role: security on the asset

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

ParameterInTypeDescription
id requiredpathstring

Request body

application/json, required: object

Responses

StatusMeaningBody
2XXSuccessobject
4XXAn errorError
5XXAn errorError

End an exception to a policy gate early

POST /gate-policies/exceptions/{id}/end

Role: security on the asset

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

ParameterInTypeDescription
id requiredpathstring

Request body

application/json, required: object

Responses

StatusMeaningBody
2XXSuccessobject
4XXAn errorError
5XXAn errorError

Policy gate violations

GET /gate-policies/violations

Role: security

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

ParameterInTypeDescription
policy_idqueryinteger
asset_idqueryinteger
project_idqueryinteger

Responses

StatusMeaningBody
2XXSuccessobject
4XXAn errorError
5XXAn errorError

A policy gate

GET /gate-policies/{id}

Role: security

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

ParameterInTypeDescription
id requiredpathstring

Responses

StatusMeaningBody
2XXSuccessobject
4XXAn errorError
5XXAn errorError

Replace a policy gate

PUT /gate-policies/{id}

Role: admin

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

ParameterInTypeDescription
id requiredpathstring

Request body

application/json, required: object

Responses

StatusMeaningBody
2XXSuccessobject
4XXAn errorError
5XXAn errorError

Delete a policy gate

DELETE /gate-policies/{id}

Role: admin

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

ParameterInTypeDescription
id requiredpathstring

Responses

StatusMeaningBody
2XXSuccess (usually 204 No Content)no body
4XXAn errorError
5XXAn errorError

A project's policy gates

GET /projects/{id}/gate-policies

Role: security on the project

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

ParameterInTypeDescription
id requiredpathstring

Responses

StatusMeaningBody
2XXSuccessobject
4XXAn errorError
5XXAn errorError

Add a policy gate of the project

POST /projects/{id}/gate-policies

Role: admin of the project

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

ParameterInTypeDescription
id requiredpathstring

Request body

application/json, required: object

Responses

StatusMeaningBody
2XXSuccessobject
4XXAn errorError
5XXAn errorError

Turn an inherited policy gate on, off, or edit it for the project

PUT /projects/{id}/gate-policies/inherited/{pid}

Role: admin of the project

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

ParameterInTypeDescription
id requiredpathstring
pid requiredpathstring

Request body

application/json, required: object

Responses

StatusMeaningBody
2XXSuccessobject
4XXAn errorError
5XXAn errorError

Replace a policy gate of the project

PUT /projects/{id}/gate-policies/{pid}

Role: admin of the project

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

ParameterInTypeDescription
id requiredpathstring
pid requiredpathstring

Request body

application/json, required: object

Responses

StatusMeaningBody
2XXSuccessobject
4XXAn errorError
5XXAn errorError

Delete a policy gate of the project

DELETE /projects/{id}/gate-policies/{pid}

Role: admin of the project

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

ParameterInTypeDescription
id requiredpathstring
pid requiredpathstring

Responses

StatusMeaningBody
2XXSuccess (usually 204 No Content)no body
4XXAn errorError
5XXAn errorError