Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,11 @@ GITDB_ENCRYPTION_KEY="development"
# Closed incidents older than this are deleted (default 365)
# MONITORING_INCIDENT_RETENTION_DAYS=365

# ─── MCP API keys (docs/adr/0005-mcp-server.md) ────────────────────────────────────────────────
# Requests per minute allowed to each personal API key created for MCP / AI agents (429 with
# Retry-After beyond it). Per process. Default 120.
# MCP_RATE_LIMIT_PER_MINUTE=120

# ─── CVE feed (/org/<org>/cves, "CVEs por tecnología" tab; docs/adr/0004-cve-feed.md) ─────────
# Follows the CVEs published in public sources (OSV.dev, NVD, CISA KEV, FIRST EPSS) for the
# technologies each organization chooses, and emits cve_feed.* events. OFF by default: with false
Expand Down
27 changes: 26 additions & 1 deletion CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -414,12 +414,13 @@ in `docs/adr/0001-event-bus-and-alerts.md`.
- `integration_disabled`: its type is off in the environment (Slack without `SLACK_CLIENT_ID`/`SECRET`), or the
organization disconnected it (e.g., last Slack workspace was removed)
- `unavailable`: no transport registered

It is computed, never stored. When an organization removes its last Slack workspace (`removeSlackWorkspace()`),
`disableForIntegration()` disables all enabled Slack channels with `disabledReason: 'integration'`; when Slack
is installed again, `restoreForIntegration()` enables only those back (ones manually disabled or failed stay
as they are). `deliver()` only sends to `connected` channels, the views (`toView()`, alert channel options)
carry it, and the settings list badges `integration_disabled`.

- Paused alerts and delivery status: `alertDelivery()` (`#lib/alerts/delivery.ts`, shared with the
client) says whether an alert is `live`: it has email recipients or at least one connected
channel. It computes `disconnectedTypes` (types of the alert's disconnected channels without repeats,
Expand Down Expand Up @@ -628,6 +629,11 @@ Making an event alertable:
monitors, monitors/new, monitors/[id], monitors/[id]/edit}`, thin routes over
`#lib/server/monitoring/page.ts`; components in `#lib/components/monitoring/`; the Code Report
service page shows its monitors (`service-monitors.ts`).
- Public API (`/api/monitoring/{monitors,monitors/[id],monitors/[id]/test,status}`, ADR 0005, logic in
`#lib/server/monitoring/api.ts`): permission-first (404 unreadable project/monitor, 403 no action,
409 `module_disabled`). Responses only carry `headerNames`/`hasHeaders`/`hasBody`, never header
values or the body, and URLs are the display URL. An `mcp` key sending `headers` or `body` on create
gets 400 `mcp_monitor_secrets_not_allowed`; other keys and sessions are unchanged.

## CVE feed

Expand Down Expand Up @@ -659,6 +665,11 @@ monitors, monitors/new, monitors/[id], monitors/[id]/edit}`, thin routes over
roles are not migrated). `read` sees the tab and the feed data of the detail (404 for others);
`update` edits the watchlist and runs "Sincronizar ahora". "Te afecta", the occurrences and the
suggestions additionally need `organization:projects:read`.
- Public API (`/api/cves/{watchlist,feed,[cve]}`, logic in `$lib/server/cve-feed/api.ts`, ADR 0005):
reads only `cveFeedQueryService` (GitDB, never a source). No `organization:cves:feed:read` or an
unknown organization is a 404; `affectsMe` (filter and field) needs `organization:projects:read`
too (the filter is a 403 without it, the field is omitted). With the feed off the feed and the
detail answer empty with `feedEnabled: false`; the watchlist is still read from GitDB.
- Events `cve_feed.advisory.published|escalated|fix_available|affects_project` (alertable,
`readPermission` `organization:cves:feed:read`): one per organization x CVE x change (x project
for `affects_project`), the dedup state is written before publishing.
Expand Down Expand Up @@ -739,6 +750,14 @@ Machine-to-machine requests authenticate with `Authorization: Bearer gvs_...`; `
resolves them into `locals.apiKey` and `cancanService.canApiKey()` confines a project key to its
own project.

API keys have an `audience` (`api` by default, or `mcp`). An `mcp` key is always personal (project
keys are always `api`) and is meant for AI agents (ADR 0005): `canApiKey()` (async) resolves it with
the permissions of its user in every organization and project (`canForUser`, most-specific-wins,
cluster admin included). Personal `api` keys still have no role and no permissions. Vault is closed
to `mcp` keys twice: `hooks.server.ts` answers 403 on `/api/vault/**` and `canApiKey()` denies any
`*:vault:*` permission. Calls run as actor `mcp:<key name>` and are rate limited per key
(`MCP_RATE_LIMIT_PER_MINUTE`, default 120; 429 + `Retry-After`). Always `await canApiKey()`.

`organization:notifications:read` and `organization:notifications:update` gate external email
recipients at the organization level; `project:notifications:update` lets project alerts add
them. Existing roles are not migrated: enable them from the role editor.
Expand All @@ -748,6 +767,12 @@ Unauthenticated public routes for external alert recipients: `/notifications/ver
They are allowed without a session in `hooks.server.ts` and validate their tokens rather than
checking permissions.

Read API for discovery and Code Report (`GET /api/projects`, `/api/code-report/services[/id[/vulnerabilities]]`,
logic in `#lib/server/code-report/api.ts`): permission-first through `callerCan` (sessions and keys). A project
or service the caller cannot read is a 404; 403 only when the project is readable (`project:project:read` or a
Code Report read) but the action (`reports:read`, `vulnerabilities:read`) is not. Lists use `limit`/`cursor`;
CVE titles are cut to 300 characters and the SBOM or raw scanner output is never returned.

`locals.user.role` is a session role object, not the string `admin`. Use `isAdmin()` or the `can*`
helpers. Keep authorization tests beside changes to permission behavior.

Expand Down
Loading
Loading