{
  "name": "Vulnerability-Lookup",
  "description": "Key layout of Vulnerability-Lookup (CIRCL): records stored as JSON strings, index sorted sets, vendor/product/CWE/CNA sets.",
  "detect": ["index", "last_updates"],
  "missingHint": "Load the sample data: docker compose --profile seed run --rm seed (in demo/vulnerability-lookup)",
  "indexPattern": "^index(:|$)",
  "indexLabel": "Indexes",
  "keyPattern": "^(cve|ghsa|pysec|fkie_cve|jvndb|cnvd|certfr|cisco|gsd|mal|rustsec)-",
  "dateScoreKeys": "^index(:(?!.*(cvss|score)).*)?$",
  "describe": [
    ["^index$", "All records: id → last-modified time"],
    ["^index:(published|reserved|rejected)$", "All records in that event: id → event time"],
    ["^index:state:", "All records currently in that state"],
    ["^index:epss$", "EPSS meta UUIDs → import time"],
    ["^index:epss:score$", "CVE → EPSS probability"],
    ["^index:[^:]+:cvss$", "Source records: id → highest CVSS base score"],
    ["^index:[^:]+:(published|reserved|rejected)$", "Source records: id → event time"],
    ["^index:[^:]+:state:", "Source records currently in that state"],
    ["^index:[^:]+$", "Source records: id → last-modified time"],
    ["^(cve|ghsa|pysec|fkie_cve|jvndb|cnvd|certfr|cisco|gsd|mal|rustsec|go|osv)-\\*$", "Vulnerability record (raw JSON)"],
    ["^(cve|ghsa|pysec|fkie_cve|jvndb|cnvd|certfr|cisco|gsd|mal|rustsec|go|osv)-\\*:link$", "Related ids (aliases, referenced CVEs)"],
    ["^(cve|ghsa|pysec|fkie_cve|jvndb|cnvd|certfr|cisco|gsd|mal|rustsec|go|osv)-\\*:cwe$", "CWE ids of the record"],
    ["^(cve|ghsa|pysec|fkie_cve|jvndb|cnvd|certfr|cisco|gsd|mal|rustsec|go|osv)-\\*:assigner$", "CNA short name of the record"],
    ["^(cve|ghsa|pysec|fkie_cve|jvndb|cnvd|certfr|cisco|gsd|mal|rustsec|go|osv)-\\*:meta$", "Pointers to metadata (field epss → epss:<uuid>)"],
    [":link$", "Related ids (aliases, referenced CVEs)"],
    ["^epss:\\*$", "EPSS score, percentile and date of one CVE"],
    ["^vendors$", "All vendor names"],
    ["^products$", "All product names"],
    ["^assigners$", "All CNA short names"],
    ["^\\*:products$", "Products of a vendor"],
    ["^product:\\*:vulnerabilities$", "Records affecting a product (any vendor)"],
    ["^assigner:\\*:vulnerabilities$", "Records assigned by a CNA"],
    ["^assigner:\\*:vulnerabilities:counted$", "Records already counted in the CNA rankings"],
    ["^assignerOrgId:\\*:vulnerabilities$", "Records assigned by a CNA org UUID"],
    ["^cwe:index$", "All CWE ids seen"],
    ["^cwe:CWE-\\*:vulnerabilities$", "Records with that CWE"],
    ["^cwe:ranking", "CWE → number of records (ranking)"],
    ["^vendors:ranking", "Vendor → number of records (ranking)"],
    ["^assigners:ranking", "CNA → number of records (ranking)"],
    ["^\\*:vulnerabilities:counted$", "Records already counted in the vendor rankings"],
    ["^\\*:\\*:vulnerabilities$", "Records affecting vendor:product"],
    ["^[a-z]+:count:", "Counter behind /api/stats (state:count:source[:period])"],
    ["^imported:seen:", "Ids a feeder has already imported"],
    ["^adp:shortName:", "Records enriched by that ADP (CISA, Red Hat, …)"],
    ["^last_updates$", "Source → last feeder run"],
    ["^stats:sources$", "Sources with data"]
  ],
  "params": [
    {
      "name": "source",
      "label": "Source",
      "default": "cvelistv5",
      "options": ["cvelistv5", "github", "pysec", "fkie_nvd", "csaf_cisco", "jvndb", "cnvd", "certfr_avis"]
    },
    { "name": "cve", "label": "CVE id", "from": ["zrevrange", "index:cvelistv5", "0", "0"] },
    { "name": "nvd", "label": "NVD record", "from": ["zrevrange", "index:fkie_nvd", "0", "0"] },
    { "name": "ghsa", "label": "GitHub advisory", "from": ["zrevrange", "index:github", "0", "0"] },
    { "name": "epss_cve", "label": "CVE with EPSS", "from": ["zrevrange", "index:epss:score", "0", "0"] },
    { "name": "vendor", "label": "Vendor", "from": ["zrevrange", "vendors:ranking:cvelistv5", "0", "0"] },
    { "name": "product", "label": "Product", "from": ["srandmember", "{vendor}:products"] },
    { "name": "assigner", "label": "CNA", "from": ["zrevrange", "assigners:ranking:cvelistv5", "0", "0"] },
    { "name": "cwe", "label": "CWE", "from": ["zrevrange", "cwe:ranking", "0", "0"] },
    { "name": "days", "label": "Days", "default": "7" },
    { "name": "year", "label": "Year", "default": "{currentYear}" },
    { "name": "month", "label": "Month", "default": "{currentMonth}" }
  ],
  "queries": [
    {
      "group": "Latest and time windows",
      "title": "Latest records, all sources",
      "desc": "`index` holds every record id scored by its last-modified time (Unix seconds).",
      "steps": [["ZREVRANGE", "index", "0", "9", "WITHSCORES"]]
    },
    {
      "group": "Latest and time windows",
      "title": "Latest records of one source",
      "desc": "Each feeder keeps its own `index:<source>`.",
      "steps": [["ZREVRANGE", "index:{source}", "0", "9", "WITHSCORES"]]
    },
    {
      "group": "Latest and time windows",
      "title": "Published in the last {days} days",
      "desc": "Range query on the publication-time index; `{since}` is now minus {days} days.",
      "steps": [
        ["ZCOUNT", "index:{source}:published", "{since}", "+inf"],
        ["ZREVRANGEBYSCORE", "index:{source}:published", "+inf", "{since}", "WITHSCORES", "LIMIT", "0", "20"]
      ]
    },
    {
      "group": "Latest and time windows",
      "title": "Reserved, not yet published",
      "desc": "CVE ids in RESERVED state, newest first.",
      "steps": [["ZREVRANGE", "index:reserved", "0", "9", "WITHSCORES"]]
    },
    {
      "group": "Latest and time windows",
      "title": "Records per source",
      "desc": "ZCARD of each source index.",
      "steps": [
        ["ZCARD", "index:cvelistv5"],
        ["ZCARD", "index:github"],
        ["ZCARD", "index:pysec"],
        ["ZCARD", "index:fkie_nvd"],
        ["ZCARD", "index:csaf_cisco"],
        ["ZCARD", "index:jvndb"],
        ["ZCARD", "index:cnvd"],
        ["ZCARD", "index:certfr_avis"]
      ]
    },
    {
      "group": "Latest and time windows",
      "title": "When each source was last updated",
      "steps": [["HGETALL", "last_updates"]]
    },
    {
      "group": "One vulnerability",
      "title": "Get a record",
      "desc": "Records are plain strings holding the JSON exactly as the source publishes it.",
      "steps": [["GET", "{cve}"]]
    },
    {
      "group": "One vulnerability",
      "title": "An NVD record",
      "desc": "NVD (FKIE mirror) records are stored with an `fkie_` prefix, so they do not overwrite the CVE record of the same id.",
      "steps": [["GET", "{nvd}"], ["SMEMBERS", "{nvd}:link"]]
    },
    {
      "group": "One vulnerability",
      "title": "Related ids, CWE and CNA",
      "desc": "Small sets next to each record.",
      "steps": [["SMEMBERS", "{cve}:link"], ["SMEMBERS", "{cve}:cwe"], ["SMEMBERS", "{cve}:assigner"]]
    },
    {
      "group": "One vulnerability",
      "title": "GitHub advisory and its aliases",
      "steps": [["SMEMBERS", "{ghsa}:link"], ["GET", "{ghsa}"]]
    },
    {
      "group": "One vulnerability",
      "title": "Last modified and published",
      "desc": "Scores of the record in the indexes (Unix seconds).",
      "steps": [["ZSCORE", "index", "{cve}"], ["ZSCORE", "index:published", "{cve}"]]
    },
    {
      "group": "One vulnerability",
      "title": "EPSS score through the meta hash",
      "desc": "`<cve>:meta` points to an `epss:<uuid>` hash: two lookups.",
      "steps": [["HGET", "{epss_cve}:meta", "epss"], ["HGETALL", "epss:{prev}"]]
    },
    {
      "group": "Vendors, products and CNAs",
      "title": "Top vendors",
      "desc": "Ranking zset: vendor → number of records.",
      "steps": [["ZREVRANGE", "vendors:ranking:cvelistv5", "0", "9", "WITHSCORES"]]
    },
    {
      "group": "Vendors, products and CNAs",
      "title": "Products of a vendor",
      "steps": [["SCARD", "{vendor}:products"], ["SMEMBERS", "{vendor}:products"]]
    },
    {
      "group": "Vendors, products and CNAs",
      "title": "Records for a vendor and product",
      "steps": [["SMEMBERS", "{vendor}:{product}:vulnerabilities"]]
    },
    {
      "group": "Vendors, products and CNAs",
      "title": "How many vendors, products and CNAs",
      "steps": [["SCARD", "vendors"], ["SCARD", "products"], ["SCARD", "assigners"]]
    },
    {
      "group": "Vendors, products and CNAs",
      "title": "Top CNAs in {year}",
      "steps": [["ZREVRANGE", "assigners:ranking:cvelistv5:{year}", "0", "9", "WITHSCORES"]]
    },
    {
      "group": "Vendors, products and CNAs",
      "title": "Records assigned by a CNA",
      "steps": [
        ["SCARD", "assigner:{assigner}:vulnerabilities"],
        ["SRANDMEMBER", "assigner:{assigner}:vulnerabilities", "10"]
      ]
    },
    {
      "group": "Weaknesses and scores",
      "title": "Top CWEs, all time and this month",
      "steps": [
        ["ZREVRANGE", "cwe:ranking", "0", "9", "WITHSCORES"],
        ["ZREVRANGE", "cwe:ranking:cvelistv5:{month}", "0", "9", "WITHSCORES"]
      ]
    },
    {
      "group": "Weaknesses and scores",
      "title": "Records with a CWE",
      "steps": [["SCARD", "cwe:{cwe}:vulnerabilities"], ["SRANDMEMBER", "cwe:{cwe}:vulnerabilities", "10"]]
    },
    {
      "group": "Weaknesses and scores",
      "title": "Highest CVSS and how many are critical",
      "desc": "`index:<source>:cvss` scores each record by its highest CVSS base score.",
      "steps": [
        ["ZCOUNT", "index:{source}:cvss", "9", "+inf"],
        ["ZREVRANGE", "index:{source}:cvss", "0", "9", "WITHSCORES"]
      ]
    },
    {
      "group": "Weaknesses and scores",
      "title": "Highest EPSS probability",
      "steps": [["ZREVRANGE", "index:epss:score", "0", "9", "WITHSCORES"]]
    },
    {
      "group": "Weaknesses and scores",
      "title": "EPSS above 10 %",
      "steps": [["ZRANGEBYSCORE", "index:epss:score", "0.1", "+inf", "WITHSCORES"]]
    },
    {
      "group": "Combining indexes",
      "title": "A vendor's records with a given CWE",
      "desc": "Set intersection of the vendor and CWE indexes.",
      "steps": [["SINTER", "{vendor}:vulnerabilities", "cwe:{cwe}:vulnerabilities"]]
    },
    {
      "group": "Combining indexes",
      "title": "A CNA's records with a given CWE",
      "steps": [
        ["SINTERCARD", "2", "assigner:{assigner}:vulnerabilities", "cwe:{cwe}:vulnerabilities"],
        ["SINTER", "assigner:{assigner}:vulnerabilities", "cwe:{cwe}:vulnerabilities"]
      ]
    },
    {
      "group": "Combining indexes",
      "title": "CVEs with an EPSS score, ranked by CVSS",
      "desc": "ZINTER keeps members present in both zsets; WEIGHTS 1 0 keeps only the CVSS score.",
      "steps": [["ZINTER", "2", "index:cvelistv5:cvss", "index:epss:score", "WEIGHTS", "1", "0", "WITHSCORES"]]
    },
    {
      "group": "Combining indexes",
      "title": "Published counters for {source}",
      "desc": "The counters behind `/api/stats`: total, this year, this month.",
      "steps": [
        ["MGET", "published:count:{source}", "published:count:{source}:{year}", "published:count:{source}:{month}"]
      ]
    },
    {
      "group": "Keys and kvrocks",
      "title": "Find keys by pattern",
      "desc": "SCAN is incremental: repeat with the returned cursor until it is 0.",
      "steps": [["SCAN", "0", "MATCH", "ghsa-*", "COUNT", "200"]]
    },
    {
      "group": "Keys and kvrocks",
      "title": "Search ids inside an index",
      "desc": "ZSCAN with MATCH filters the members of one sorted set.",
      "steps": [["ZSCAN", "index:{source}", "0", "MATCH", "*-2026-1*", "COUNT", "500"]]
    },
    {
      "group": "Keys and kvrocks",
      "title": "Type, size and TTL of a key",
      "steps": [["TYPE", "{cve}"], ["STRLEN", "{cve}"], ["MEMORY", "USAGE", "{cve}"], ["TTL", "{cve}"]]
    },
    {
      "group": "Keys and kvrocks",
      "title": "Key count",
      "desc": "kvrocks keeps an estimate; `DBSIZE SCAN` recounts it in the background.",
      "steps": [["DBSIZE"], ["INFO", "keyspace"]]
    }
  ]
}
