Files
sencho/docs/api-reference/security.mdx
T
Anso 865d792874 feat(pricing): collapse to two tiers (#1309)
* feat(pricing): collapse to two tiers (Community + Admiral)

Collapse Sencho's pricing from three tiers (Community / Skipper / Admiral)
to two: a generous free Community tier and a single paid Admiral tier. The
Skipper tier is removed.

Now free in Community: auto-heal, auto-update, scheduled operations,
webhooks, notification routing, Fleet Actions and bulk operations, SSO
preset providers (Google / GitHub / Okta), unlimited users with admin and
viewer roles, and deploy safety (atomic deploys, auto-rollback, and
one-click rollback).

Admiral (paid) is focused on running and governing a fleet: blueprints,
Fleet Secrets, deploy enforcement, vulnerability report export, audit log,
host console, private registries, mesh networking, node cordon, managed
cloud backup, LDAP / Active Directory SSO, and the advanced RBAC roles
(deployer, node-admin, auditor) with per-resource scoped assignments.

Internally the license variant distinction is removed so tier is binary
(community / paid). License validation still verifies the Lemon Squeezy
store and product before granting paid status.

Docs and the contributor guide are updated to the two-tier model.

* docs(pricing): correct licensing page to two-tier pricing and tidy stale tier wording

The licensing docs page kept the old Admiral pricing plus a Founder
Lifetime column and an Enterprise paragraph after the two-tier collapse.
Update it to $12/month or $99/year, drop the lifetime and Enterprise
content, and link to the pricing page for current pricing.

Also fix stale "Skipper" wording in CLA.md, SUPPORT.md, one test title,
and three test comments. Historical CHANGELOG entries and the
retired-Skipper license-guard test are intentionally left as-is.

* docs: align licensing and SSO pages with the two-tier model

Correct the SSO overview so the Google, GitHub, and Okta presets read as
available on every tier, matching the provider table; only LDAP and Active
Directory require Sencho Admiral. Remove the lifetime-plan references from the
licensing, settings, and troubleshooting pages so they reflect subscription-only
Admiral pricing.

* fix(rbac): omit scoped permissions from /me on the Community tier

Scoped role assignments only take effect on the paid tier, but GET /api/permissions/me returned them unconditionally, so a downgraded instance with leftover assignments rendered per-resource affordances the API then rejected with 403. The endpoint now mirrors the permission middleware and includes scoped permissions only on the paid tier. Adds a regression test covering the downgrade case.

* docs: use custom-pricing wording on the contact page

The two-tier model has no Enterprise tier; reword the contact page's enterprise pricing/deals to custom pricing/deals so it does not imply a tier that no longer exists.
2026-06-04 17:45:53 -04:00

284 lines
10 KiB
Plaintext

---
title: Security
description: Automate scan policies, CVE suppressions, and vulnerability scans from CI. Includes the deploy 409 response shape and admin bypass flow.
---
The Security API lets you manage scan policies, CVE suppressions, and trigger vulnerability scans from CI pipelines and automation scripts. Every endpoint in this reference is intended for external automation; internal frontend-only endpoints (finding listings, SARIF downloads) are not documented here.
All endpoints require [Bearer token authentication](/api-reference/overview#authentication). Manual scans, secret and misconfiguration results, scan comparison, and CVE suppressions are available on every tier. Scan policies (with `block_on_deploy` enforcement), SBOM, and SARIF require Admiral. See the per-endpoint **License** row for details.
## Scan policies
Scan policies define severity thresholds that Sencho evaluates on every post-deploy and scheduled scan. When a policy has `block_on_deploy=1`, a matching deploy is rejected at the pre-flight stage with an HTTP 409 response. See [Deploy Enforcement](/features/deploy-enforcement) for the full flow.
Writes are admin-only and rejected on replica nodes (policies are managed on the control instance and replicate fleet-wide).
### List policies
**`GET /api/security/policies`**
**License:** Admiral
```bash
curl -H "Authorization: Bearer YOUR_API_TOKEN" \
https://your-sencho-instance:1852/api/security/policies
```
**Response:**
```json
[
{
"id": 1,
"name": "prod-high-gate",
"node_id": null,
"node_identity": null,
"stack_pattern": "prod-*",
"max_severity": "HIGH",
"block_on_deploy": 1,
"enabled": 1,
"replicated_from_control": 0,
"created_at": 1745107200000,
"updated_at": 1745107200000
}
]
```
### Create policy
**`POST /api/security/policies`**
**License:** Admiral · **Role:** Admin
| Field | Type | Required | Description |
|-------|------|:--------:|-------------|
| `name` | string | yes | Human-readable name shown in the UI. |
| `stack_pattern` | string or `null` | no | Glob against stack names (e.g. `prod-*`). `null` matches every stack. |
| `max_severity` | string | yes | One of `CRITICAL`, `HIGH`, `MEDIUM`, `LOW`. A scan whose highest finding meets or exceeds this severity triggers the policy. |
| `block_on_deploy` | `0` or `1` | yes | When `1`, pre-flight violations reject deploys with HTTP 409. When `0`, post-deploy and scheduled scans dispatch warning alerts instead. |
| `enabled` | `0` or `1` | no | Defaults to `1`. Disabled policies are never evaluated. |
| `node_id` | number or `null` | no | Scope the policy to one node. `null` applies the policy fleet-wide. |
```bash
curl -X POST https://your-sencho-instance:1852/api/security/policies \
-H "Authorization: Bearer YOUR_API_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"name": "prod-high-gate",
"stack_pattern": "prod-*",
"max_severity": "HIGH",
"block_on_deploy": 1,
"enabled": 1
}'
```
**Response:** `201 Created` with the full policy object.
**Errors:**
- `400` `max_severity must be CRITICAL, HIGH, MEDIUM, or LOW`
- `400` `Policy name is required`
- `403` when called on a replica node
### Update policy
**`PUT /api/security/policies/{id}`**
**License:** Admiral · **Role:** Admin
Any of the create fields can be updated individually. Omitted fields are left unchanged.
```bash
curl -X PUT https://your-sencho-instance:1852/api/security/policies/1 \
-H "Authorization: Bearer YOUR_API_TOKEN" \
-H "Content-Type: application/json" \
-d '{ "block_on_deploy": 0 }'
```
**Response:** `200 OK` with the updated policy.
**Errors:** `400 Invalid policy id`, `404 Policy not found`, `403` on replicas.
### Delete policy
**`DELETE /api/security/policies/{id}`**
**License:** Admiral · **Role:** Admin
```bash
curl -X DELETE https://your-sencho-instance:1852/api/security/policies/1 \
-H "Authorization: Bearer YOUR_API_TOKEN"
```
**Response:** `200 OK` `{"success": true}`. The call is idempotent; deleting a non-existent id returns the same shape.
## CVE suppressions
Suppressions let you mark individual CVEs as acknowledged so scan reads, comparisons, and exports downgrade them to a dimmed state. See [CVE Suppressions](/features/cve-suppressions) for the full flow.
### List suppressions
**`GET /api/security/suppressions`**
**License:** Community
Response rows include an `active` boolean computed from the `expires_at` timestamp.
```json
[
{
"id": 3,
"cve_id": "CVE-2024-12345",
"pkg_name": "openssl",
"image_pattern": "alpine:*",
"reason": "Awaiting upstream patch. Reviewed by security on 2026-04-10.",
"created_by": "ops@example.com",
"created_at": 1744000000000,
"expires_at": 1746592000000,
"replicated_from_control": 0,
"active": true
}
]
```
### Create suppression
**`POST /api/security/suppressions`**
**License:** Community · **Role:** Admin
| Field | Type | Required | Description |
|-------|------|:--------:|-------------|
| `cve_id` | string | yes | `CVE-YYYY-NNNN` or `GHSA-xxxx-xxxx-xxxx` format. |
| `pkg_name` | string or `null` | no | Package name to narrow the scope (e.g. `openssl`). `null` suppresses every package match. |
| `image_pattern` | string or `null` | no | Glob against image references. `null` applies fleet-wide. |
| `reason` | string | yes | Required justification, up to 2000 characters. Surfaced on every dimmed row. |
| `expires_at` | number or `null` | no | Unix timestamp in milliseconds. `null` for an indefinite suppression. |
```bash
curl -X POST https://your-sencho-instance:1852/api/security/suppressions \
-H "Authorization: Bearer YOUR_API_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"cve_id": "CVE-2024-12345",
"pkg_name": "openssl",
"image_pattern": "alpine:*",
"reason": "Awaiting upstream patch.",
"expires_at": 1746592000000
}'
```
**Response:** `201 Created` with the full suppression.
**Errors:** `400` on invalid shape (missing `reason`, malformed `cve_id`, over-length fields), `409` when a suppression already exists for the same `(cve_id, pkg_name, image_pattern)` triple, `403` on replicas.
### Delete suppression
**`DELETE /api/security/suppressions/{id}`**
**License:** Community · **Role:** Admin
```bash
curl -X DELETE https://your-sencho-instance:1852/api/security/suppressions/3 \
-H "Authorization: Bearer YOUR_API_TOKEN"
```
## Vulnerability scans
### Trigger a scan
**`POST /api/security/scan`**
**License:** Community · **Role:** Admin
Accepts an image reference and starts an asynchronous scan. The response returns immediately with a `scanId` that you can poll.
| Field | Type | Required | Description |
|-------|------|:--------:|-------------|
| `imageRef` | string | yes | Image reference Trivy will scan (must match Sencho's validator; `/`, `:`, `@`, alphanumerics, `-`, `_`, `.`). |
| `stackName` | string | no | Associates the scan with a stack for display purposes. |
| `force` | boolean | no | Default `false`. When `true`, ignores the 24-hour digest cache and runs Trivy again. |
| `scanners` | `["vuln"]` or `["vuln","secret"]` | no | Omit for vuln-only. Pass `["vuln","secret"]` to include secret detection. |
```bash
curl -X POST https://your-sencho-instance:1852/api/security/scan \
-H "Authorization: Bearer YOUR_API_TOKEN" \
-H "Content-Type: application/json" \
-d '{ "imageRef": "nginx:1.27" }'
```
**Response:** `202 Accepted` `{ "scanId": 142 }`. The scan continues in the background.
**Errors:** `400 imageRef is required`, `400 Invalid imageRef format`, `409 Already scanning this image`, `503 Trivy is not available on this host`.
### List scans
**`GET /api/security/scans`**
**License:** Community
Supports filters: `imageRef`, `imageRefLike`, `status`, `limit`, `offset`. Response is paginated with `total` and `scans` fields.
```bash
curl -H "Authorization: Bearer YOUR_API_TOKEN" \
"https://your-sencho-instance:1852/api/security/scans?imageRefLike=nginx&limit=20"
```
## Stack deploy with policy
Every stack deploy endpoint evaluates the scan policy gate before `docker compose up` runs. When a policy blocks the deploy, the endpoint returns HTTP 409.
**Affected endpoints:** `POST /api/stacks/{stackName}/deploy`, `POST /api/stacks/{stackName}/update`, `POST /api/stacks/{stackName}/recreate`, `POST /api/stacks/from-git`, `POST /api/stacks/git-source/{sourceId}/apply`, `POST /api/stacks/deploy-template`.
### Blocked-deploy response
HTTP 409 Conflict. The response body is parseable JSON so CI pipelines can branch on it:
```json
{
"error": "Policy \"prod-high-gate\" blocked deploy: 2 image(s) exceed HIGH",
"policy": {
"id": 3,
"name": "prod-high-gate",
"maxSeverity": "HIGH"
},
"violations": [
{
"imageRef": "myapp:v1",
"severity": "CRITICAL",
"criticalCount": 2,
"highCount": 5,
"scanId": 142
},
{
"imageRef": "nginx:1.14",
"severity": "HIGH",
"criticalCount": 0,
"highCount": 3,
"scanId": 143
}
]
}
```
### Bypassing a block
Admins can bypass the gate on a per-deploy basis by passing `?ignorePolicy=true` on the deploy URL. The flag is only honored when the calling session resolves to an admin user; API tokens with read-only or deploy-only scope cannot bypass a policy.
```bash
curl -X POST "https://your-sencho-instance:1852/api/stacks/myapp/deploy?ignorePolicy=true" \
-H "Authorization: Bearer ADMIN_API_TOKEN"
```
Every bypass is recorded in the [Audit Log](/features/audit-log) with the originating path and method, the actor's username, the policy name, and the list of bypassed images.
**Response when bypass is honored:** `200 OK` with the normal deploy success payload and `bypassedPolicy: true`.
**Response when bypass is denied:** the original `409 Conflict` payload is returned (the caller was not admin, or the token scope disallowed bypass).
### Fail-open when Trivy is missing
If Trivy is not installed on the target node, the gate fails open: the deploy proceeds with an HTTP 200 response and Sencho dispatches a warning notification `Pre-deploy scan for "<stack>" skipped: Trivy not installed on this node`. This keeps teams from being locked out when the scanner binary is unavailable.
Install Trivy on the affected node to enforce the policy; see [Installing Trivy](/operations/trivy-setup).