{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://holemonitor.live/schemas/webhook-v1.json",
  "title": "Hole Monitor webhook body",
  "description": "An OSV 1.9.2 record with Hole Monitor facts under database_specific. Structured bodies omit summary, details and credits.",
  "type": "object",
  "required": ["schema_version", "id", "modified", "database_specific"],
  "properties": {
    "schema_version": { "const": "1.9.2" },
    "id": { "type": "string", "pattern": "^(CVE-\\d{4}-\\d{4,}|GHSA(-[23456789cfghjmpqrvwx]{4}){3}|DRUPAL-[A-Z]+-\\d{4}-\\d{3,}|x_WORDFENCE-[0-9a-f-]{36})$" },
    "modified": { "type": "string", "format": "date-time" },
    "published": { "type": "string", "format": "date-time" },
    "withdrawn": { "type": "string", "format": "date-time" },
    "aliases": { "type": "array", "items": { "type": "string" } },
    "summary": { "type": "string", "description": "Third-party text. Full content only." },
    "details": { "type": "string", "description": "Third-party text. Full content only." },
    "severity": {
      "type": "array",
      "items": {
        "type": "object",
        "required": ["type", "score"],
        "properties": { "type": { "enum": ["CVSS_V2", "CVSS_V3", "CVSS_V4"] }, "score": { "type": "string" } }
      }
    },
    "affected": { "type": "array", "items": { "$ref": "#/$defs/affected" } },
    "references": {
      "type": "array",
      "items": { "type": "object", "required": ["type", "url"], "properties": { "type": { "type": "string" }, "url": { "type": "string" } } }
    },
    "credits": { "type": "array", "items": { "type": "object", "properties": { "name": { "type": "string" }, "type": { "type": "string" } } } },
    "database_specific": { "$ref": "#/$defs/databaseSpecific" }
  },
  "$defs": {
    "affected": {
      "type": "object",
      "properties": {
        "package": {
          "type": "object",
          "required": ["ecosystem", "name"],
          "properties": { "ecosystem": { "type": "string" }, "name": { "type": "string" }, "purl": { "type": "string" } }
        },
        "ranges": {
          "type": "array",
          "items": {
            "type": "object",
            "required": ["type", "events"],
            "properties": {
              "type": { "enum": ["SEMVER", "ECOSYSTEM", "GIT"] },
              "repo": { "type": "string" },
              "events": {
                "type": "array",
                "items": {
                  "type": "object",
                  "minProperties": 1,
                  "maxProperties": 1,
                  "properties": {
                    "introduced": { "type": "string" },
                    "fixed": { "type": "string" },
                    "last_affected": { "type": "string" },
                    "limit": { "type": "string" }
                  }
                }
              }
            }
          }
        },
        "versions": { "type": "array", "items": { "type": "string" } },
        "database_specific": {
          "type": "object",
          "properties": {
            "vendor": { "type": "string" },
            "product": { "type": "string" },
            "cpes": { "type": "array", "items": { "type": "string" } },
            "versions": { "type": "array", "description": "CVE record version entries, unconverted." }
          }
        },
        "ecosystem_specific": { "type": "object" }
      }
    },
    "date": { "type": ["string", "null"] },
    "databaseSpecific": {
      "type": "object",
      "required": ["sources", "cvss", "max_base_score", "content", "event"],
      "properties": {
        "sources": { "type": "array", "items": { "enum": ["cve", "nvd", "ghsa", "drupal", "drupal_osv", "kev", "wordfence", "epss"] } },
        "cvss": {
          "type": "array",
          "items": {
            "type": "object",
            "required": ["version", "vector", "base_score", "source"],
            "properties": {
              "version": { "type": "string" },
              "vector": { "type": "string" },
              "base_score": { "type": ["number", "null"] },
              "source": { "type": "string" }
            }
          }
        },
        "max_base_score": { "type": ["number", "null"] },
        "epss": {
          "type": "object",
          "properties": { "score": { "type": "number" }, "percentile": { "type": "number" }, "date": { "$ref": "#/$defs/date" } }
        },
        "kev": {
          "type": "object",
          "properties": {
            "date_added": { "$ref": "#/$defs/date" },
            "due_date": { "$ref": "#/$defs/date" },
            "ransomware_use": { "type": ["string", "null"] }
          }
        },
        "drupal": { "type": "object", "properties": { "advisory_id": { "type": ["string", "null"] }, "risk": { "type": ["string", "null"] } } },
        "wordfence": { "type": "object", "properties": { "id": { "type": "string" }, "url": { "type": "string" } } },
        "cwes": { "type": "array", "items": { "type": "string" } },
        "cve_state": { "type": "string" },
        "nvd_status": { "type": "string" },
        "previous_id": { "type": "string" },
        "attribution": { "type": "array", "items": { "type": "object", "required": ["source"] } },
        "content": { "enum": ["structured", "full"] },
        "omitted": { "type": "integer", "minimum": 0 },
        "untrusted_fields": { "type": "array", "items": { "type": "string" } },
        "sanitized": { "const": true },
        "event": {
          "type": "object",
          "required": ["id", "type", "changed", "created"],
          "properties": {
            "id": { "type": "string" },
            "type": { "enum": ["published", "updated", "kev_added", "withdrawn"] },
            "changed": { "type": "array", "items": { "type": "string" } },
            "created": { "type": "string", "format": "date-time" },
            "previous_id": { "type": "string" },
            "test": { "const": true }
          }
        }
      }
    }
  }
}
