mirror of
https://github.com/beenuar/AiSOC.git
synced 2026-11-26 02:05:36 +08:00
* docs: correct the statements recent work made false
A sweep of the 375 tracked Markdown/MDX files outside `plans/`, plus every
URL they ship. 50 files corrected, 0 deleted. The ranking is by how wrong a
statement was, not by how visible the page is.
Capabilities described as absent that now exist. The depth wave gave readers
to ABAC conditions, time-boxed elevation and workload identities, shipped
console TOTP, and made the playbook `approval` step a durable pause — and
five documents still said none of that existed. The buyer-facing security
questionnaire was the worst of them: four gap-list rows and two prose answers
telling a prospect that controls they were evaluating us on were absent. Its
own sibling page `access-governance.md` documented those controls and was
missing from the pack index, which is how the contradiction survived.
Capabilities described that do not exist. `faq.md` answered "can I delete a
user's data on request?" with "Yes" and a route — `DELETE
/api/v1/identity/{user_id}/data` — that appears nowhere in the code or in
`docs/openapi.yaml`, while `data-handling.md` says in as many words that no
such route is in the tree. `live-actions.md` called `POST
/api/v1/live-actions/dispatch` "one entry point" for the agent layer; the API
deliberately proxies only `/dry-run`, and its handler says so. The same page
documented `tenant_id` and `requested_by` as caller-supplied fields.
Counts re-derived from the tree, not carried over: executable detections
2,603 -> 2,529 (down, because rules that could not fire stopped being
counted), unreachable 119 -> 45, windowed 5 -> 72, YAML under `detections/`
7,016 -> 7,022, `/metrics` coverage 5-of-17 -> 5-of-19, connectors 69/84 ->
87, marketplace 7,155 -> 7,158, playbook step types 9 -> 25.
Links: every external URL fetched. `docs.tryaisoc.com` does not resolve at
all and was linked from two example pages — sentences rewritten, hostname
allow-list entries removed rather than re-counted, since the exemption had
claimed they were "accurate as written". Sigstore, Wazuh and MITRE CAR links
repointed at destinations that answer 200. Nine internal links fixed,
including two to `PROGRESS.md`, which is gitignored and has never been
committed.
Self-contradictions resolved in place: `observability.md` said both that the
Kafka spine's ends are instrumented and that they are not — the limitation is
real but its stated cause changed, and the bullet now gives the current one.
* docs: carry the corrected detection figure through every surface
#1226 landed the 3.3 corpus correction and the executable figure moved
again, 2529 -> 2511, for the same reason as the first move: rules that
cannot fire stopped being counted as capable of it.
Seventeen documents still carried the old number — the architecture page,
the glossary, the intro, the FAQ, the detections concept page, three
design briefs, two contributing guides, the repository-reality audit and
the claim matrix. A figure copied into prose goes stale silently, which is
why it is re-derived here rather than edited by hand in one place.
The dated DEPTH_PROGRESS log entry keeps 2,529: it records what was true
when 3.1 landed, and rewriting it would be revisionism. The
component-recipes file keeps its list of superseded literals for the same
reason — that list is the warning against hard-coding the figure at all.
readme-gates, the claim matrix, llms --check, comment-paths, merge-markers
and competitor-names all pass.
* docs: make AGENTS.md contributor guidance instead of a leaked session log
The file committed at the repository root was a verbatim session-memory
document. It opened with "Learned User Preferences", referred throughout to
"the user", and published things that have no business in a public
open-source repository: the commercial product's hostname, its Fly.io
hosting topology and internal app names, its billing and registration flow,
and the name of an archived private staging repository.
Most of it was also wrong. The Fly.io apps were reclaimed for non-payment
months ago, so the deployment section described infrastructure that does
not exist, and the service and package lists predated several waves of work.
Rewritten as what an `AGENTS.md` at a project root is for: guidance for
whoever is changing the code, human or agent. One command to get it
running, one event's journey through the services, where things live, the
conventions that are easy to guess wrong, the figures with the command that
re-derives each, and the rules that are not negotiable.
Three choices worth stating. The figures table gives the command rather than
only the number, because a number copied into prose goes stale silently and
several in this repository did. The "if you are an AI agent" section says
plainly that nothing here can make a third-party tool reach for this project
by default — that is registry publication, not documentation. And the Cyble
credit stays: `www.cyble.com` answers 403 to curl, but it is Cloudflare's
"Just a moment" interstitial over a live host, which is bot protection and
not absence.
Every other URL fetched at 200 before committing.
* Merge origin/main, and register AGENTS.md's two service counts
The new contributor guide publishes a CORE and a full service count in its
opening block, and the profile gate requires any published figure to be a
registered claim site — correctly, because an unregistered figure is one
nobody notices going stale, which is how three of them drifted before.
Registered rather than reworded. Proven by setting the CORE figure to 14
and watching the gate name all sixteen services; restored, and it passes at
28 published figures agreeing with docker-compose.yml.
466 lines
13 KiB
Markdown
466 lines
13 KiB
Markdown
# AiSOC API Reference
|
|
|
|
This document describes the REST endpoints exposed by AiSOC services. For the
|
|
auto-generated, exhaustive schema visit `/api/docs` (Swagger) on a running API
|
|
service — the app mounts it there, not at `/docs`.
|
|
|
|
> The maintained, published API reference is
|
|
> [`apps/docs/docs/api/rest.md`](../../apps/docs/docs/api/rest.md) on the docs
|
|
> portal. This page is the longer-form companion; where the two disagree, the
|
|
> generated OpenAPI schema at `/api/openapi.json` wins.
|
|
|
|
| Service | Base URL (local) |
|
|
|---------|-------------------|
|
|
| Core API | `http://localhost:8000` |
|
|
| Agents | `http://localhost:8001` |
|
|
| Actions | `http://localhost:8002` |
|
|
| Fusion | `http://localhost:8003` |
|
|
| Threat Intel | `http://localhost:8005` |
|
|
| Purple Team | `http://localhost:8006` |
|
|
| Connectors | `http://localhost:8088` |
|
|
|
|
All examples assume:
|
|
|
|
```bash
|
|
# AISOC_ADMIN_PASSWORD is the password `make bootstrap` printed. There is no
|
|
# default credential — each deployment generates its own at first run.
|
|
export AISOC_TOKEN="$(curl -sX POST http://localhost:8000/api/v1/auth/login \
|
|
-H 'content-type: application/json' \
|
|
-d "{\"email\":\"admin@aisoc.internal\",\"password\":\"$AISOC_ADMIN_PASSWORD\"}" \
|
|
| jq -r .access_token)"
|
|
export AISOC_TENANT="00000000-0000-0000-0000-000000000001"
|
|
```
|
|
|
|
---
|
|
|
|
## 1. Graph (Neo4j) — `/api/v1/graph`
|
|
|
|
Service: `services/api`.
|
|
|
|
### 1.1 `GET /api/v1/graph/attack-path/{case_id}`
|
|
|
|
Reconstructs the kill-chain for a case by traversing `(:Case)-[:CONTAINS]->(:Alert)-[:USES]->(:Technique)-[:PART_OF]->(:Tactic)`.
|
|
|
|
```bash
|
|
curl -H "authorization: Bearer $AISOC_TOKEN" \
|
|
http://localhost:8000/api/v1/graph/attack-path/$CASE_ID
|
|
```
|
|
|
|
**Response**
|
|
|
|
```json
|
|
{
|
|
"case_id": "…",
|
|
"tactics": [
|
|
{ "id": "TA0001", "name": "Initial Access" },
|
|
{ "id": "TA0002", "name": "Execution" }
|
|
],
|
|
"techniques": [
|
|
{ "id": "T1566", "name": "Phishing", "alert_id": "…" },
|
|
{ "id": "T1059.001", "name": "PowerShell", "alert_id": "…" }
|
|
]
|
|
}
|
|
```
|
|
|
|
### 1.2 `GET /api/v1/graph/blast-radius/{entity_type}/{entity_id}`
|
|
|
|
Returns 1-3 hop neighborhood of a node, used to gate high-impact actions.
|
|
`entity_type` and `entity_id` are **path** segments; only `max_hops` is a
|
|
query parameter.
|
|
|
|
| Parameter | Where | Description |
|
|
|-----------|-------|-------------|
|
|
| `entity_type` | path | One of `host`, `user`, `ioc` |
|
|
| `entity_id` | path | Node identifier |
|
|
| `max_hops` | query (default `2`) | 1-3 |
|
|
|
|
```bash
|
|
curl -H "authorization: Bearer $AISOC_TOKEN" \
|
|
"http://localhost:8000/api/v1/graph/blast-radius/host/HOST-42?max_hops=2"
|
|
```
|
|
|
|
**Response**
|
|
|
|
```json
|
|
{
|
|
"root": { "type": "Host", "id": "HOST-42" },
|
|
"nodes": 17,
|
|
"edges": 24,
|
|
"hosts": ["HOST-42", "HOST-71"],
|
|
"users": ["alice@corp"],
|
|
"iocs": ["1.2.3.4", "evil.tld"],
|
|
"alerts": ["A-1", "A-7"]
|
|
}
|
|
```
|
|
|
|
### 1.3 `GET /api/v1/graph/neighbors/{entity_type}/{entity_id}`
|
|
|
|
1-hop neighborhood for the SOC console "context" panel. Same path-parameter
|
|
shape as blast radius.
|
|
|
|
### 1.4 `GET /api/v1/graph/mitre-coverage`
|
|
|
|
Aggregated counts of distinct techniques observed per tenant.
|
|
|
|
| Query param | Default | Description |
|
|
|-------------|---------|-------------|
|
|
| `window` | `7d` | `1h`, `24h`, `7d`, `30d` |
|
|
|
|
---
|
|
|
|
## 2. Detection Rules — `/api/v1/rules`
|
|
|
|
Service: `services/api`.
|
|
|
|
### 2.1 `GET /api/v1/rules`
|
|
|
|
| Query param | Description |
|
|
|-------------|-------------|
|
|
| `language` | `sigma` · `yara` · `kql` · `lucene` · `regex` |
|
|
| `enabled` | `true`/`false` |
|
|
| `severity` | `low`-`critical` |
|
|
|
|
### 2.2 `POST /api/v1/rules`
|
|
|
|
```json
|
|
{
|
|
"name": "Suspicious PowerShell encoded command",
|
|
"language": "sigma",
|
|
"severity": "high",
|
|
"rule": "title: Suspicious PowerShell\n…",
|
|
"tags": ["attack.execution", "attack.t1059.001"],
|
|
"enabled": true
|
|
}
|
|
```
|
|
|
|
### 2.3 `POST /api/v1/rules/{id}/execute`
|
|
|
|
Run a single rule on demand against the last `lookback` of telemetry.
|
|
|
|
```json
|
|
{
|
|
"lookback": "1h",
|
|
"indices": ["events-*"],
|
|
"limit": 100
|
|
}
|
|
```
|
|
|
|
**Response**
|
|
|
|
```json
|
|
{
|
|
"rule_id": "…",
|
|
"matches": 7,
|
|
"duration_ms": 138,
|
|
"results": [
|
|
{ "event_id": "…", "host": "…", "user": "…", "ts": "…" }
|
|
]
|
|
}
|
|
```
|
|
|
|
### 2.4 `POST /api/v1/rules/hunt`
|
|
|
|
Multi-rule, time-bounded threat hunt.
|
|
|
|
```json
|
|
{
|
|
"rule_ids": ["rule-1", "rule-2"],
|
|
"from": "2026-04-25T00:00:00Z",
|
|
"to": "2026-05-01T00:00:00Z",
|
|
"limit_per_rule": 50
|
|
}
|
|
```
|
|
|
|
### 2.5 `PATCH /api/v1/rules/{id}` / `DELETE /api/v1/rules/{id}`
|
|
|
|
Standard CRUD with optimistic concurrency via `If-Match` ETag.
|
|
|
|
---
|
|
|
|
## 3. Detection Proposals (Detection-as-Code) — `/api/v1/detection-proposals`
|
|
|
|
Service: `services/api`.
|
|
|
|
The DAC lifecycle manages detection rule proposals from creation through eval-gated promotion into the live rule set. Every proposal carries an eval result from `scripts/run_evals.py`; candidates that regress MITRE accuracy by ≥ 1 pp cannot be promoted.
|
|
|
|
### 3.1 `GET /api/v1/detection-proposals`
|
|
|
|
| Query param | Description |
|
|
|-------------|-------------|
|
|
| `status` | `draft` · `in_review` · `approved` · `rejected` · `promoted` |
|
|
|
|
### 3.2 `POST /api/v1/detection-proposals`
|
|
|
|
```json
|
|
{
|
|
"title": "Detect rundll32 network connections",
|
|
"description": "Flags rundll32.exe making outbound connections — common LOLBin technique.",
|
|
"logic": "title: Rundll32 Outbound\nstatus: experimental\n…",
|
|
"mitre_tags": ["attack.defense_evasion", "attack.t1218.011"]
|
|
}
|
|
```
|
|
|
|
### 3.3 `GET /api/v1/detection-proposals/{id}`
|
|
|
|
Returns proposal detail including comments and attached eval results.
|
|
|
|
### 3.4 `POST /api/v1/detection-proposals/{id}/comment`
|
|
|
|
```json
|
|
{ "body": "Looks good — verified against last 30 days of telemetry." }
|
|
```
|
|
|
|
### 3.5 `POST /api/v1/detection-proposals/{id}/eval`
|
|
|
|
Attach eval result (metric deltas from `scripts/run_evals.py`).
|
|
|
|
```json
|
|
{
|
|
"mitre_accuracy_delta": 0.02,
|
|
"alert_reduction_delta": -0.01,
|
|
"investigation_completeness_delta": 0.0,
|
|
"response_quality_delta": 0.0
|
|
}
|
|
```
|
|
|
|
### 3.6 `POST /api/v1/detection-proposals/{id}/decide`
|
|
|
|
```json
|
|
{ "decision": "approve" }
|
|
```
|
|
|
|
Valid decisions: `approve`, `reject`.
|
|
|
|
### 3.7 `POST /api/v1/detection-proposals/{id}/promote`
|
|
|
|
Promotes an approved proposal into `detection_rules`. Returns the new rule ID.
|
|
|
|
### 3.8 `GET /api/v1/detection-proposals/baselines`
|
|
|
|
Current eval baseline metrics used as the promotion gate reference.
|
|
|
|
### 3.9 `POST /api/v1/detection-proposals/baselines`
|
|
|
|
Reset eval baseline to the latest harness run (admin-only).
|
|
|
|
---
|
|
|
|
## 4. Federated Search — `/api/v1/federated`
|
|
|
|
Service: `services/api` → `services/connectors`.
|
|
|
|
Fan out a single query to connected SIEMs. The API translates the query into each target's native dialect (SPL for Splunk, KQL for Sentinel, ES|QL for Elastic).
|
|
|
|
### 4.1 `POST /api/v1/federated/search`
|
|
|
|
```json
|
|
{
|
|
"query": "process.name = \"rundll32.exe\" AND network.direction = \"outbound\"",
|
|
"targets": ["splunk-prod", "sentinel-corp"],
|
|
"time_range": { "from": "2026-05-01T00:00:00Z", "to": "2026-05-06T00:00:00Z" }
|
|
}
|
|
```
|
|
|
|
**Response**
|
|
|
|
```json
|
|
{
|
|
"results": [
|
|
{ "target": "splunk-prod", "dialect": "spl", "hits": 14, "events": [ … ] },
|
|
{ "target": "sentinel-corp", "dialect": "kql", "hits": 3, "events": [ … ] }
|
|
]
|
|
}
|
|
```
|
|
|
|
---
|
|
|
|
## 5. Threat Intel IOC Search — `/api/v1/iocs`
|
|
|
|
Service: `services/threatintel` (port 8005). Note the full prefix: the route
|
|
is declared on the app, so it is `/api/v1/iocs/search` on the threat-intel
|
|
service, not on the core API.
|
|
|
|
### 5.1 `GET /api/v1/iocs/search`
|
|
|
|
| Query param | Description |
|
|
|-------------|-------------|
|
|
| `q` | Lexical query (OpenSearch) |
|
|
| `type` | `ip` · `domain` · `url` · `sha256` · `md5` |
|
|
| `actor` | Filter by named actor |
|
|
| `since` | ISO timestamp |
|
|
|
|
This is the only IOC route the service exposes. Earlier revisions of this page
|
|
also listed `POST /iocs/semantic`, `GET /iocs/{value}`, `GET /feeds/status` and
|
|
`POST /feeds/{name}/poll`; none of them was ever implemented. IOC records the
|
|
core API stores are at `GET`/`POST /api/v1/threat-intel/iocs`.
|
|
|
|
---
|
|
|
|
## 6. ML Fusion — `/api/v1/fusion`
|
|
|
|
Service: `services/fusion` (port 8003), proxied by the core API.
|
|
|
|
### 6.1 `GET /api/v1/fusion/ml/status`
|
|
|
|
```json
|
|
{
|
|
"anomaly_model": {
|
|
"trained": true,
|
|
"samples": 482,
|
|
"last_trained_at": "2026-04-30T12:00:00Z"
|
|
},
|
|
"ranker_model": {
|
|
"trained": false,
|
|
"feedback_buffer": 73,
|
|
"feedback_required": 100
|
|
}
|
|
}
|
|
```
|
|
|
|
`POST /ml/feedback` and `POST /ml/retrain` exist on the fusion service itself
|
|
(`services/fusion/app/api/router.py`) but are **not** proxied by the core API,
|
|
so they are reachable only from inside the compose network at
|
|
`http://fusion:8003/ml/feedback` and `http://fusion:8003/ml/retrain`.
|
|
|
|
---
|
|
|
|
## 7. Vulnerability Match Stream
|
|
|
|
Vulnerability matches are surfaced on the Kafka `vulnerability.matches` topic.
|
|
There is no `GET /api/v1/vulnerabilities` route; this page previously claimed
|
|
one. KEV exposure is read through the posture surface
|
|
(`services/api/app/api/v1/endpoints/posture.py`).
|
|
|
|
---
|
|
|
|
## 8. Cases — `/api/v1/cases`
|
|
|
|
Standard CRUD. The attack path for a case is read from the graph surface —
|
|
`GET /api/v1/graph/attack-path/{case_id}` (§1.1) — not from a route under
|
|
`/cases`.
|
|
|
|
---
|
|
|
|
## 9. Hunt-as-Code — `/api/v1/hunts`
|
|
|
|
Service: `services/api` (`app/api/v1/endpoints/hunts.py`).
|
|
|
|
YAML hunt definitions live in `hunts/`. Each file declares a hypothesis,
|
|
MITRE ATT&CK tags, log sources, indicators, expected outcomes, and an
|
|
optional schedule. The agents service loads the corpus at startup and
|
|
exposes it via these endpoints.
|
|
|
|
### 9.1 `GET /api/v1/hunts`
|
|
|
|
List all hunts in the YAML corpus.
|
|
|
|
### 9.2 `GET /api/v1/hunts/{hunt_id}`
|
|
|
|
Single hunt definition (hypothesis, MITRE tags, indicators, schedule).
|
|
|
|
### 9.3 `POST /api/v1/hunts/{hunt_id}/run`
|
|
|
|
Run a hunt on demand. Returns run output including findings.
|
|
|
|
### 9.4 `GET /api/v1/hunts/{hunt_id}/runs`
|
|
|
|
Recent runs for one hunt (DB-backed). Query param: `limit`.
|
|
|
|
### 9.5 `GET /api/v1/hunts/{hunt_id}/findings`
|
|
|
|
Recent findings for one hunt. Query params: `status`, `limit`.
|
|
|
|
Both are scoped to a single hunt; there are no corpus-wide `/hunts/runs` or
|
|
`/hunts/findings` routes, and no `POST /hunts/reload`. The corpus is loaded at
|
|
startup.
|
|
|
|
---
|
|
|
|
## 10. Entity Risk (Risk-Based Alerting)
|
|
|
|
Service: `services/fusion`.
|
|
|
|
Time-decayed risk scores per entity (user, host, src_ip, domain).
|
|
Alerts contribute severity-weighted points that decay with a configurable
|
|
half-life. When an entity crosses `rba_promotion_threshold` it is
|
|
promoted to an incident with contributing alerts attached.
|
|
|
|
The entity-centric queue surfaces the top-N highest-risk entities to
|
|
analysts instead of raw alert lists, supporting alert-to-incident
|
|
ratios of ≥ 50:1.
|
|
|
|
Entity risk data is stored in Redis hashes (per entity, namespaced by
|
|
tenant) with ZSET-backed top-N sorted queues for O(log N) reads.
|
|
|
|
> Entity risk is accessed internally by the fusion engine. The web console
|
|
> reads the queue through the API's fusion proxy:
|
|
> `GET /api/v1/fusion/entity-risk/queue`, `/entity-risk/stats` and
|
|
> `/entity-risk/{entity_type}/{entity_value}`.
|
|
|
|
---
|
|
|
|
## 11. Authentication
|
|
|
|
* JWT issued by `POST /api/v1/auth/login`.
|
|
* API keys via `Authorization: ApiKey *** header.
|
|
* All requests must specify a tenant context — either implicit (from JWT) or explicit (`X-Tenant-Id` header for service-to-service calls).
|
|
* SSO (feature-flagged `SSO_ENABLED`): `GET /api/v1/auth/sso/status` advertises
|
|
enabled connections; the OIDC callback lands the session on `/login?next=…`
|
|
with tokens in the URL fragment (never in query strings or server logs).
|
|
JIT provisioning defaults to `viewer`; `admin` is unreachable from SSO by
|
|
construction unless an explicit allowlisted admin group mapping exists.
|
|
|
|
## 11a. Users Administration — `/api/v1/admin/users`
|
|
|
|
Admin only (`roles:write`); every mutation requires a `reason`, writes an
|
|
audit row, and revokes the target's active sessions. See
|
|
[Roles & Permissions](../roles-and-permissions.md) for the full model.
|
|
|
|
| Method | Path | Purpose |
|
|
|--------|------|---------|
|
|
| `GET` | `/api/v1/admin/users` | Paginated list (`q`, `role`, `status`, `sort`, `dir`, `page`, `size`) — server-side only |
|
|
| `GET` | `/api/v1/admin/users/{id}` | Detail incl. roles, provider, last login |
|
|
| `PUT` | `/api/v1/admin/users/{id}/roles` | Replace role set (catalog-validated, last-admin guard) |
|
|
| `POST` | `/api/v1/admin/users/{id}/roles` | Add one role |
|
|
| `DELETE` | `/api/v1/admin/users/{id}/roles/{role}` | Remove one role |
|
|
| `PATCH` | `/api/v1/admin/users/{id}` | Enable/disable (`{"is_active": bool}`) |
|
|
| `DELETE` | `/api/v1/admin/users/{id}?reason=…` | Permanent delete; audit retains identity snapshot |
|
|
|
|
Errors: `401` unauthenticated · `403`/`401` insufficient role (fail-closed)
|
|
· `404` unknown or cross-tenant id · `409` self-delete or last-admin
|
|
violation · `422` missing/oversized reason.
|
|
|
|
---
|
|
|
|
## 12. Errors
|
|
|
|
All endpoints return RFC 7807 Problem Details:
|
|
|
|
```json
|
|
{
|
|
"type": "https://example.com/errors/rule-validation",
|
|
"title": "Sigma rule failed validation",
|
|
"status": 422,
|
|
"detail": "Unknown field 'EventID' in selection 'sel_powershell'",
|
|
"instance": "/api/v1/rules"
|
|
}
|
|
```
|
|
|
|
---
|
|
|
|
## 13. Rate Limits
|
|
|
|
| Tier | Requests/min |
|
|
|------|--------------|
|
|
| Default | 600 |
|
|
| `/api/v1/rules/hunt` | 30 |
|
|
|
|
Limits are tenant-scoped and enforced by Redis.
|
|
|
|
---
|
|
|
|
## 14. Versioning
|
|
|
|
The API follows semver via the URL prefix `/api/v1`. Breaking changes will move
|
|
to `/api/v2` and the previous version remains supported for at least 6 months.
|