# Policy packs

Built-in and signed policy packs, activation, advisories, and the protocol code points a policy allows. Aegis Core API, `PolicyService`: 7 operations, generated from the OpenAPI document of Aegis Core 0.13.0.

## List policy

`GET /v1/policy`

The packs, the one in force and whether imports can be verified.

- Role: `auditor` or higher
- gRPC: `/aegis.v1.PolicyService/ListPolicy`

Response `200` (`application/json`): [ListPolicyResponse](#schema-listpolicyresponse)

Errors: `400` · `401` · `403` · `404` · `409` · `413` · `500` · `503` ([what each means](https://docs.qblackbit.com/api/core/index.md#errors)).

## Activate policy

`POST /v1/policy/activate`

Puts a pack in force, with a reason.

- Role: `admin` or higher
- gRPC: `/aegis.v1.PolicyService/ActivatePolicy`

Request body, required (`application/json`):

| Field | Type | Description |
| --- | --- | --- |
| `id` | string | The pack's identifier. |
| `reason` | string | Why, on one line, at most 200 characters. |

Response `200` (`application/json`): [ActivatePolicyResponse](#schema-activatepolicyresponse)

Errors: `400` · `401` · `403` · `404` · `409` · `413` · `500` · `503` ([what each means](https://docs.qblackbit.com/api/core/index.md#errors)).

## List advisories

`GET /v1/policy/advisories`

The advisories accepted, with the sequence the next one must exceed.

- Role: `auditor` or higher
- gRPC: `/aegis.v1.PolicyService/ListAdvisories`

Response `200` (`application/json`): [ListAdvisoriesResponse](#schema-listadvisoriesresponse)

Errors: `400` · `401` · `403` · `404` · `409` · `413` · `500` · `503` ([what each means](https://docs.qblackbit.com/api/core/index.md#errors)).

## Import advisory

`POST /v1/policy/advisories`

Imports a signed advisory and puts it in force; it can only narrow.

- Role: `admin` or higher
- gRPC: `/aegis.v1.PolicyService/ImportAdvisory`

Request body, required (`application/json`):

| Field | Type | Description |
| --- | --- | --- |
| `document` | string | The signed document: the envelope's JSON as text, or base64 of it. |

Response `200` (`application/json`): [ImportAdvisoryResponse](#schema-importadvisoryresponse)

Errors: `400` · `401` · `403` · `404` · `409` · `413` · `500` · `503` ([what each means](https://docs.qblackbit.com/api/core/index.md#errors)).

## Import policy pack

`POST /v1/policy/packs`

Imports a signed pack from a file. It is not in force until activated.

- Role: `admin` or higher
- gRPC: `/aegis.v1.PolicyService/ImportPolicyPack`

Request body, required (`application/json`):

| Field | Type | Description |
| --- | --- | --- |
| `document` | string | The signed document: the envelope's JSON as text, or base64 of it. |

Response `200` (`application/json`): [ImportPolicyPackResponse](#schema-importpolicypackresponse)

Errors: `400` · `401` · `403` · `404` · `409` · `413` · `500` · `503` ([what each means](https://docs.qblackbit.com/api/core/index.md#errors)).

## Get policy pack

`GET /v1/policy/packs/{id}`

One pack in full: its rules with their sources, its hybrid rule and notes.

- Role: `auditor` or higher
- gRPC: `/aegis.v1.PolicyService/GetPolicyPack`

| Parameter | In | Type | Description |
| --- | --- | --- | --- |
| `id` | path | string, required |  |

Response `200` (`application/json`): [PolicyPack](#schema-policypack)

Errors: `400` · `401` · `403` · `404` · `409` · `413` · `500` · `503` ([what each means](https://docs.qblackbit.com/api/core/index.md#errors)).

## Protocol answers

`GET /v1/policy/protocols`

What the policy in force allows, as TLS, IKEv2, SSH, JOSE, COSE and X.509 code points.

- Role: `auditor` or higher
- gRPC: `/aegis.v1.PolicyService/ProtocolAnswers`

Response `200` (`application/json`): [ProtocolAnswersResponse](#schema-protocolanswersresponse)

Errors: `400` · `401` · `403` · `404` · `409` · `413` · `500` · `503` ([what each means](https://docs.qblackbit.com/api/core/index.md#errors)).

## Schemas

### ActivatePolicyResponse

The policy now in force.

| Field | Type | Description |
| --- | --- | --- |
| `policy` | string | The engine's name for it. |

### ImportAdvisoryResponse

The advisory now in force.

| Field | Type | Description |
| --- | --- | --- |
| `algorithm` | string | The algorithm it concerns. |
| `maturity` | string | The maturity it sets. |
| `sequence` | integer (int64) | Its sequence. |

### ImportPolicyPackResponse

The pack imported.

| Field | Type | Description |
| --- | --- | --- |
| `active` | boolean | Always false: a pack is in force only once activated. |
| `id` | string | Its identifier. |
| `version` | integer (int64) | Its version. |

### ListAdvisoriesResponse

The advisories accepted.

| Field | Type | Description |
| --- | --- | --- |
| `advisories` | array of [AlgorithmAdvisory](#schema-algorithmadvisory) | Each advisory as signed. |
| `last_sequence` | integer (int64) | The highest sequence accepted; the next advisory must exceed it. |

### ListPolicyResponse

The packs and the one in force.

| Field | Type | Description |
| --- | --- | --- |
| `active` | [PolicyActivation](#schema-policyactivation), nullable | The activation in force; absent while the baseline applies. |
| `packs` | array of [PolicyPackSummary](#schema-policypacksummary) | Every pack known, the newest version of each. |
| `policy` | string | The engine's name for the policy in force. |
| `trust` | boolean | Whether a policy trust is configured, so that signed documents can be imported. |

### PolicyPack

A policy pack, as signed.

| Field | Type | Description |
| --- | --- | --- |
| `built_in` | boolean | Whether it is built into this release. |
| `hybrid` | string | The hybrid rule: `required`, `allowed` or `forbidden`. |
| `hybrid_basis` | string | Why, with its source. |
| `id` | string | Stable identifier. |
| `issued` | string | When this version was issued. |
| `notes` | array of string | What was left out and why. |
| `rules` | array of [PolicyRule](#schema-policyrule) | The rules. |
| `sources` | array of [PolicySource](#schema-policysource) | Every document a rule cites. |
| `spec_version` | string | The pack format's version. |
| `title` | string | Its name for people. |
| `type` | string | Always `policy-pack`. |
| `version` | integer (int64) | Rises with every change of the pack. |

### ProtocolAnswersResponse

The code points the policy in force allows, protocol by protocol.

| Field | Type | Description |
| --- | --- | --- |
| `cose` | array of [ProtocolCodePoint](#schema-protocolcodepoint) | COSE algorithm values. |
| `ike_authentication` | array of [ProtocolCodePoint](#schema-protocolcodepoint) | IKEv2 authentication methods. |
| `ike_key_exchange` | array of [ProtocolCodePoint](#schema-protocolcodepoint) | IKEv2 key exchange methods (transform type 4). |
| `jose` | array of [ProtocolCodePoint](#schema-protocolcodepoint) | JOSE `alg` values. |
| `policy` | string | The policy that answered. |
| `ssh_key_exchange` | array of [ProtocolCodePoint](#schema-protocolcodepoint) | SSH key exchange methods. |
| `ssh_public_keys` | array of [ProtocolCodePoint](#schema-protocolcodepoint) | SSH public key algorithms. |
| `tls_groups` | array of [ProtocolCodePoint](#schema-protocolcodepoint) | TLS 1.3 supported groups. |
| `tls_signature_schemes` | array of [ProtocolCodePoint](#schema-protocolcodepoint) | TLS 1.3 signature schemes. |
| `x509_signatures` | array of [ProtocolCodePoint](#schema-protocolcodepoint) | X.509 and CMS signature algorithm identifiers. |

### AlgorithmAdvisory

An algorithm advisory, as signed.

| Field | Type | Description |
| --- | --- | --- |
| `algorithm` | string | The algorithm identifier. |
| `effective` | string | The first day it applies (ISO 8601). |
| `issued` | string | When it was issued. |
| `maturity` | string | The maturity from `effective` on. |
| `reason` | string | Why, in one or two sentences. |
| `sequence` | integer (int64) | Rises with every advisory, across all algorithms. |
| `source` | [AdvisorySource](#schema-advisorysource), nullable | The published finding. |
| `spec_version` | string | Always `1`. |
| `type` | string | Always `algorithm-advisory`. |

### PolicyActivation

Who put a pack in force, when and why.

| Field | Type | Description |
| --- | --- | --- |
| `by` | string | Who activated it. |
| `id` | string | The pack's identifier. |
| `reason` | string | Why. |
| `time` | integer (int64) | When, in seconds since the Unix epoch. |
| `version` | integer (int64) | Its version. |

### PolicyPackSummary

A pack, in short.

| Field | Type | Description |
| --- | --- | --- |
| `active` | boolean | Whether it is in force. |
| `built_in` | boolean | Whether it is built into this release. |
| `hybrid` | string | The hybrid rule: `required`, `allowed` or `forbidden`. |
| `id` | string | Stable identifier, for example `us-cnsa-2.0`. |
| `issued` | string | When this version was issued. |
| `sources` | array of [PolicySource](#schema-policysource) | The documents its rules cite. |
| `title` | string | Its name for people. |
| `version` | integer (int64) | Rises with every change of the pack. |

### PolicyRule

One rule of a pack.

| Field | Type | Description |
| --- | --- | --- |
| `algorithms` | array of string | Algorithm identifiers, `family:<key>`, or `*` for every algorithm. |
| `effect` | string | `allow` or `deny`. |
| `from` | string, nullable | First day it applies (ISO 8601), if not from the start. |
| `id` | string | Unique within the pack. |
| `keys` | array of string | Key names it applies to (`*` as a trailing wildcard); all when empty. |
| `min_category` | integer (int64), nullable | The lowest NIST security category it applies to. |
| `operations` | string | `any`, `apply` (new protection) or `process` (existing protection). |
| `roles` | array of string | Caller roles it applies to; all when empty. |
| `section` | string | Where in the source. |
| `source` | string | The source it comes from. |
| `until` | string, nullable | Last day it applies (ISO 8601, inclusive), if it ends. |
| `warning` | string, nullable | A warning shown with the algorithm from `warning_from` on, without refusing anything. |
| `warning_from` | string, nullable | When the warning starts. |

### PolicySource

A document a pack cites.

| Field | Type | Description |
| --- | --- | --- |
| `checked` | string | The date it was checked against the rules. |
| `date` | string | Its date of publication (in a full pack only). |
| `id` | string | How rules refer to it. |
| `title` | string | Its title. |
| `url` | string | Where it was read. |
| `version` | string | Its version. |

### ProtocolCodePoint

One code point in an answer.

| Field | Type | Description |
| --- | --- | --- |
| `algorithm` | string | The algorithm it stands for. |
| `name` | string | The registry's name. |
| `reference` | string | The document that assigns it. |
| `standing` | string | `published` or `draft` (a draft appears only in a laboratory). |
| `value` | string | The value on the wire. |

### AdvisorySource

Where an advisory's finding is published.

| Field | Type | Description |
| --- | --- | --- |
| `checked` | string | When it was checked. |
| `title` | string | The finding's title. |
| `url` | string | Where it is published. |
