FLUID_SBOM_JSON_SCHEMA = {
    "type": "object",
    "additionalProperties": False,
    "properties": {
        "sbom_details": {
            "type": "object",
            "additionalProperties": False,
            "properties": {
                "name": {"type": "string"},
                "timestamp": {"type": "string", "format": "date-time"},
                "tool": {"type": "string"},
                "organization": {"type": "string"},
                "version": {"type": ["string", "null"]},
            },
            "required": [
                "name",
                "version",
                "timestamp",
                "tool",
                "organization",
            ],
        },
        "packages": {
            "type": "array",
            "items": {
                "type": "object",
                "additionalProperties": False,
                "properties": {
                    "id": {"type": "string"},
                    "name": {"type": "string"},
                    "version": {"type": "string"},
                    "locations": {
                        "type": "array",
                        "items": {
                            "type": "object",
                            "additionalProperties": False,
                            "properties": {
                                "path": {"type": "string"},
                                "line": {"type": ["integer", "null"]},
                                "layer": {"type": ["string", "null"]},
                                "dependency_type": {"type": "string"},
                                "scope": {"type": "string"},
                                "reachable_cves": {"type": "array", "items": {"type": ["string"]}},
                                "location_id": {"type": "string"},
                                "top_parents": {
                                    "type": ["array", "null"],
                                    "items": {"type": "string"},
                                },
                                "dependency_chains": {
                                    "type": ["array", "null"],
                                    "items": {"type": "object"},
                                },
                                "package_manager": {"type": "string"},
                            },
                            "required": ["path", "line", "layer", "package_manager"],
                        },
                    },
                    "language": {"type": "string"},
                    "found_by": {"type": "string"},
                    "package_url": {"type": "string"},
                    "ecosystem": {"type": "string"},
                    "health_metadata": {
                        "type": ["object", "null"],
                        "additionalProperties": False,
                        "properties": {
                            "artifact": {
                                "type": ["object", "null"],
                                "properties": {
                                    "integrity": {
                                        "type": ["object", "null"],
                                        "additionalProperties": False,
                                        "properties": {
                                            "algorithm": {"type": ["string", "null"]},
                                            "value": {"type": ["string", "null"]},
                                        },
                                        "required": ["algorithm", "value"],
                                    },
                                },
                            },
                        },
                    },
                    "safe_versions": {
                        "type": ["array", "null"],
                        "items": {"type": "string"},
                    },
                    "advisories": {
                        "type": "array",
                        "items": {
                            "type": "object",
                            "additionalProperties": False,
                            "properties": {
                                "cpes": {
                                    "type": "array",
                                    "items": {"type": "string"},
                                },
                                "description": {"type": ["string", "null"]},
                                "epss": {"type": "number"},
                                "id": {"type": "string"},
                                "percentile": {"type": "number"},
                                "severity": {"type": "string"},
                                "urls": {
                                    "type": "array",
                                    "items": {"type": "string"},
                                },
                                "version_constraint": {"type": "string"},
                                "platform_version": {"type": ["string", "null"]},
                                "cvss4": {"type": ["string", "null"]},
                                "cwe_ids": {
                                    "type": ["array", "null"],
                                    "items": {"type": "string"},
                                },
                                "fixed_versions": {
                                    "type": ["array", "null"],
                                    "items": {"type": "string"},
                                },
                                "fix_metadata_new": {
                                    "type": ["object", "null"],
                                    "additionalProperties": False,
                                    "properties": {
                                        "closest_min_fix": {
                                            "type": ["object"],
                                            "additionalProperties": False,
                                            "properties": {
                                                "fix_version": {"type": "string"},
                                                "upgrade_type": {
                                                    "type": "string",
                                                    "enum": ["unknown", "major", "minor", "patch"],
                                                },
                                                "breaking_change": {"type": "boolean"},
                                                "residual_cves": {
                                                    "type": ["object", "null"],
                                                    "additionalProperties": False,
                                                    "properties": {
                                                        "remedied": {
                                                            "type": ["object", "null"],
                                                            "properties": {
                                                                "critical": {
                                                                    "type": ["array", "null"],
                                                                    "items": {"type": "string"},
                                                                },
                                                                "high": {
                                                                    "type": ["array", "null"],
                                                                    "items": {"type": "string"},
                                                                },
                                                                "medium": {
                                                                    "type": ["array", "null"],
                                                                    "items": {"type": "string"},
                                                                },
                                                                "low": {
                                                                    "type": ["array", "null"],
                                                                    "items": {"type": "string"},
                                                                },
                                                                "total": {"type": "integer"},
                                                            },
                                                            "required": ["total"],
                                                        },
                                                        "maintained": {
                                                            "type": ["object", "null"],
                                                            "properties": {
                                                                "critical": {
                                                                    "type": ["array", "null"],
                                                                    "items": {"type": "string"},
                                                                },
                                                                "high": {
                                                                    "type": ["array", "null"],
                                                                    "items": {"type": "string"},
                                                                },
                                                                "medium": {
                                                                    "type": ["array", "null"],
                                                                    "items": {"type": "string"},
                                                                },
                                                                "low": {
                                                                    "type": ["array", "null"],
                                                                    "items": {"type": "string"},
                                                                },
                                                                "total": {"type": "integer"},
                                                            },
                                                            "required": ["total"],
                                                        },
                                                        "introduced": {
                                                            "type": ["object", "null"],
                                                            "properties": {
                                                                "critical": {
                                                                    "type": ["array", "null"],
                                                                    "items": {"type": "string"},
                                                                },
                                                                "high": {
                                                                    "type": ["array", "null"],
                                                                    "items": {"type": "string"},
                                                                },
                                                                "medium": {
                                                                    "type": ["array", "null"],
                                                                    "items": {"type": "string"},
                                                                },
                                                                "low": {
                                                                    "type": ["array", "null"],
                                                                    "items": {"type": "string"},
                                                                },
                                                                "total": {"type": "integer"},
                                                            },
                                                            "required": ["total"],
                                                        },
                                                    },
                                                },
                                            },
                                            "required": [
                                                "fix_version",
                                                "upgrade_type",
                                                "breaking_change",
                                            ],
                                        },
                                        "closest_safe_fix": {
                                            "type": ["object", "null"],
                                            "additionalProperties": False,
                                            "properties": {
                                                "fix_version": {"type": "string"},
                                                "upgrade_type": {
                                                    "type": "string",
                                                    "enum": ["unknown", "major", "minor", "patch"],
                                                },
                                                "breaking_change": {"type": "boolean"},
                                                "residual_cves": {
                                                    "type": ["object", "null"],
                                                    "additionalProperties": False,
                                                    "properties": {
                                                        "remedied": {
                                                            "type": ["object", "null"],
                                                            "properties": {
                                                                "critical": {
                                                                    "type": ["array", "null"],
                                                                    "items": {"type": "string"},
                                                                },
                                                                "high": {
                                                                    "type": ["array", "null"],
                                                                    "items": {"type": "string"},
                                                                },
                                                                "medium": {
                                                                    "type": ["array", "null"],
                                                                    "items": {"type": "string"},
                                                                },
                                                                "low": {
                                                                    "type": ["array", "null"],
                                                                    "items": {"type": "string"},
                                                                },
                                                                "total": {"type": "integer"},
                                                            },
                                                            "required": ["total"],
                                                        },
                                                        "maintained": {
                                                            "type": ["object", "null"],
                                                            "properties": {
                                                                "critical": {
                                                                    "type": ["array", "null"],
                                                                    "items": {"type": "string"},
                                                                },
                                                                "high": {
                                                                    "type": ["array", "null"],
                                                                    "items": {"type": "string"},
                                                                },
                                                                "medium": {
                                                                    "type": ["array", "null"],
                                                                    "items": {"type": "string"},
                                                                },
                                                                "low": {
                                                                    "type": ["array", "null"],
                                                                    "items": {"type": "string"},
                                                                },
                                                                "total": {"type": "integer"},
                                                            },
                                                            "required": ["total"],
                                                        },
                                                        "introduced": {
                                                            "type": ["object", "null"],
                                                            "properties": {
                                                                "critical": {
                                                                    "type": ["array", "null"],
                                                                    "items": {"type": "string"},
                                                                },
                                                                "high": {
                                                                    "type": ["array", "null"],
                                                                    "items": {"type": "string"},
                                                                },
                                                                "medium": {
                                                                    "type": ["array", "null"],
                                                                    "items": {"type": "string"},
                                                                },
                                                                "low": {
                                                                    "type": ["array", "null"],
                                                                    "items": {"type": "string"},
                                                                },
                                                                "total": {"type": "integer"},
                                                            },
                                                            "required": ["total"],
                                                        },
                                                    },
                                                },
                                            },
                                            "required": [
                                                "fix_version",
                                                "upgrade_type",
                                                "breaking_change",
                                            ],
                                        },
                                        "closest_complete_fix": {
                                            "type": ["object", "null"],
                                            "additionalProperties": False,
                                            "properties": {
                                                "fix_version": {"type": "string"},
                                                "upgrade_type": {
                                                    "type": "string",
                                                    "enum": ["unknown", "major", "minor", "patch"],
                                                },
                                                "breaking_change": {"type": "boolean"},
                                                "residual_cves": {
                                                    "type": ["object", "null"],
                                                    "additionalProperties": False,
                                                    "properties": {
                                                        "remedied": {
                                                            "type": ["object", "null"],
                                                            "properties": {
                                                                "critical": {
                                                                    "type": ["array", "null"],
                                                                    "items": {"type": "string"},
                                                                },
                                                                "high": {
                                                                    "type": ["array", "null"],
                                                                    "items": {"type": "string"},
                                                                },
                                                                "medium": {
                                                                    "type": ["array", "null"],
                                                                    "items": {"type": "string"},
                                                                },
                                                                "low": {
                                                                    "type": ["array", "null"],
                                                                    "items": {"type": "string"},
                                                                },
                                                                "total": {"type": "integer"},
                                                            },
                                                            "required": ["total"],
                                                        },
                                                        "maintained": {
                                                            "type": ["object", "null"],
                                                            "properties": {
                                                                "critical": {
                                                                    "type": ["array", "null"],
                                                                    "items": {"type": "string"},
                                                                },
                                                                "high": {
                                                                    "type": ["array", "null"],
                                                                    "items": {"type": "string"},
                                                                },
                                                                "medium": {
                                                                    "type": ["array", "null"],
                                                                    "items": {"type": "string"},
                                                                },
                                                                "low": {
                                                                    "type": ["array", "null"],
                                                                    "items": {"type": "string"},
                                                                },
                                                                "total": {"type": "integer"},
                                                            },
                                                            "required": ["total"],
                                                        },
                                                        "introduced": {
                                                            "type": ["object", "null"],
                                                            "properties": {
                                                                "critical": {
                                                                    "type": ["array", "null"],
                                                                    "items": {"type": "string"},
                                                                },
                                                                "high": {
                                                                    "type": ["array", "null"],
                                                                    "items": {"type": "string"},
                                                                },
                                                                "medium": {
                                                                    "type": ["array", "null"],
                                                                    "items": {"type": "string"},
                                                                },
                                                                "low": {
                                                                    "type": ["array", "null"],
                                                                    "items": {"type": "string"},
                                                                },
                                                                "total": {"type": "integer"},
                                                            },
                                                            "required": ["total"],
                                                        },
                                                    },
                                                },
                                            },
                                            "required": [
                                                "fix_version",
                                                "upgrade_type",
                                                "breaking_change",
                                            ],
                                        },
                                    },
                                    "required": [
                                        "closest_min_fix",
                                    ],
                                },
                                "fix_metadata": {
                                    "type": ["object", "null"],
                                    "additionalProperties": False,
                                    "properties": {
                                        "closest_fix_version": {"type": ["string", "null"]},
                                        "upgrade_type": {
                                            "type": ["string", "null"],
                                            "enum": ["unknown", "major", "minor", "patch"],
                                        },
                                        "breaking_change": {"type": "boolean"},
                                        "closest_safe_version": {"type": ["string", "null"]},
                                    },
                                    "required": [
                                        "closest_fix_version",
                                        "upgrade_type",
                                        "breaking_change",
                                    ],
                                },
                                "cve_finding": {"type": ["string", "null"]},
                                "auto_approve": {"type": "boolean"},
                                "upstream_package": {"type": ["string", "null"]},
                                "kev_catalog": {"type": "boolean"},
                            },
                            "required": [
                                "cpes",
                                "description",
                                "id",
                                "severity",
                                "urls",
                                "version_constraint",
                            ],
                        },
                    },
                },
                "required": [
                    "id",
                    "name",
                    "version",
                    "locations",
                    "language",
                    "ecosystem",
                    "package_url",
                    "found_by",
                    "health_metadata",
                    "advisories",
                ],
            },
        },
        "relationships": {
            "type": "array",
            "items": {
                "type": "object",
                "additionalProperties": False,
                "properties": {
                    "from": {"type": "string"},
                    "to": {"type": "array", "items": {"type": "string"}},
                    "type": {"type": "string"},
                },
                "required": ["from", "to"],
            },
        },
    },
    "required": ["sbom_details", "packages", "relationships"],
}
