# Vulnerability-Lookup demo

Kvrocks preloaded with sample data and indexes laid out the way
[Vulnerability-Lookup](https://github.com/vulnerability-lookup/vulnerability-lookup) stores them, with the
Kvrocks GUI and a query preset for that layout.

| Path | What |
|---|---|
| `docker-compose.yml` | kvrocks 2.17.0 (stock configuration, port 10002 as in Vulnerability-Lookup), the GUI on 8484 with the preset mounted, `seed` and `cluster` profiles |
| `seed/seed_vl.py` | Loads real records from the public Vulnerability-Lookup API and builds the same indexes as its feeders |
| `presets/vulnerability-lookup.json` | GUI preset: 31 sample queries, key descriptions, the `index*` sorted sets as indexes |
| `cluster/init.sh` | Pushes the demo cluster topology with `CLUSTERX SETNODEID/SETNODES` (kvrocks has no gossip) |

## Run it

From this folder:

```powershell
docker compose up -d --build
```

```powershell
docker compose --profile seed run --rm seed
```

Open http://127.0.0.1:8484 and click **kvrocks (Vulnerability-Lookup)**. The Key statistics and Sample queries
tabs detect the layout (keys `index` and `last_updates`) and switch to the preset.

Optional two-shard cluster on ports 30001 and 30002, offered in the GUI as **kvrocks cluster (demo)**:

```powershell
docker compose --profile cluster up -d
```

The cluster advertises its nodes on `127.0.0.1`, so seed it from this machine (Python 3.10+) rather than from the
seed container:

```powershell
cd seed; python -m venv .venv; .venv\Scripts\pip install -r requirements.txt; .venv\Scripts\python seed_vl.py --cluster --port 30001 --flush
```

## The data

No data is stored in this repository. `seed/seed_vl.py` pulls the latest N records per source from
`https://vulnerability.circl.lu/api` (cvelistv5, github, pysec, fkie_nvd, csaf_cisco, jvndb, cnvd, certfr_avis,
plus EPSS) and writes them with the same keys as the upstream feeders (`vulnerabilitylookup/feeders/*.py`,
`docs/architecture.md`):

| Key | Type | Content |
|---|---|---|
| `cve-2026-1234`, `ghsa-…`, `pysec-…`, `fkie_cve-…`, `jvndb-…` | string | Raw JSON record, lowercase id (NVD records are prefixed `fkie_`) |
| `<id>:link` | set | Related ids (aliases, CVEs referenced by advisories) |
| `<id>:cwe`, `<id>:assigner` | set | CWE ids / CNA short name |
| `<cve>:meta` → `epss:<uuid>` | hash → hash | EPSS score through a meta UUID |
| `index`, `index:<source>` | zset | id → last-modified timestamp |
| `index[:<source>]:published\|reserved\|rejected` | zset | id → event timestamp |
| `index[:<source>]:state:<state>` | zset | Records currently in that state |
| `index:<source>:cvss`, `index:epss:score` | zset | id → max CVSS base score / EPSS probability |
| `vendors`, `products`, `<vendor>:products`, `<vendor>:<product>:vulnerabilities`, `product:<p>:vulnerabilities` | set | Vendor/product browse indexes |
| `assigners`, `assigner:<a>:vulnerabilities`, `assignerOrgId:<uuid>:vulnerabilities` | set | CNA indexes |
| `cwe:index`, `cwe:<CWE>:vulnerabilities`, `cwe:ranking[:<source>[:<period>]]` | set / zset | CWE indexes and rankings |
| `<state>:count:<source>[:YYYY\|:YYYY-MM]` | string | Counters behind `/api/stats` |
| `vendors:ranking:<source>[:<period>]`, `assigners:ranking:<source>[:<period>]` | zset | Rankings |
| `last_updates` | hash | Per-source update marker |

Seed options: `--per-source N` (default 100), `--sources a b`, `--epss N`, `--flush`, `--cluster`,
`--host/--port/--password`. Without Docker:
`cd seed; python -m venv .venv; .venv\Scripts\pip install -r requirements.txt; .venv\Scripts\python seed_vl.py --flush`.

This is a sample for exploring the schema, not a mirror: Vulnerability-Lookup's prepared statistics
(`stats:*` scorecards, KEV tables) and its PostgreSQL/Valkey parts are not reproduced.

## Using the preset elsewhere

The GUI reads presets from `KVGUI_PRESETS_DIR` (in Docker: mount a folder on `/app/presets`). To use this preset
against a real Vulnerability-Lookup kvrocks, copy `presets/vulnerability-lookup.json` there and connect the GUI to
it; ideally as a read-only connection.
