From daf9ec03ea0b7706079c834bef62d978caed29b1 Mon Sep 17 00:00:00 2001 From: J08nY Date: Thu, 25 Sep 2025 16:28:49 +0200 Subject: Make a JSON schema for CC Certificate and Dataset objects. --- src/sec_certs/serialization/schemas/__init__.py | 0 .../serialization/schemas/cc_certificate.json | 735 +++++++++++++++++++++ .../serialization/schemas/cc_dataset.json | 61 ++ 3 files changed, 796 insertions(+) create mode 100644 src/sec_certs/serialization/schemas/__init__.py create mode 100644 src/sec_certs/serialization/schemas/cc_certificate.json create mode 100644 src/sec_certs/serialization/schemas/cc_dataset.json (limited to 'src') diff --git a/src/sec_certs/serialization/schemas/__init__.py b/src/sec_certs/serialization/schemas/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/src/sec_certs/serialization/schemas/cc_certificate.json b/src/sec_certs/serialization/schemas/cc_certificate.json new file mode 100644 index 00000000..ec34cdf5 --- /dev/null +++ b/src/sec_certs/serialization/schemas/cc_certificate.json @@ -0,0 +1,735 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "$id": "http://sec-certs.org/schemas/cc_certificate.json", + "title": "CC Certificate", + "description": "Schema for a Common Criteria (CC) certificate.", + "type": "object", + "definitions": { + "cc_dgst": { + "type": "string", + "pattern": "^[0-9a-fA-F]{16}$", + "title": "Certificate Digest", + "description": "A hex string representing 8 bytes." + }, + "cc_id": { + "type": "string", + "title": "Certificate ID", + "description": "The unique identifier of the Common Criteria certificate." + }, + "cc_document_state": { + "type": "object", + "properties": { + "_type": { + "const": "sec_certs.sample.document_state.DocumentState" + }, + "convert_garbage": { + "type": "boolean", + "description": "Whether the document was converted to garbage (e.g., empty or invalid content)." + }, + "convert_ok": { + "type": "boolean", + "description": "Whether the document was successfully converted from PDF to text." + }, + "download_ok": { + "type": "boolean", + "description": "Whether the document was successfully downloaded." + }, + "extract_ok": { + "type": "boolean", + "description": "Whether keyword extraction from the document was successful." + }, + "pdf_hash": { + "type": [ + "string", + "null" + ], + "description": "SHA256 hash of the PDF document, if available." + }, + "txt_hash": { + "type": [ + "string", + "null" + ], + "description": "SHA256 hash of the text document, if available." + } + }, + "additionalProperties": false, + "title": "Certificate Document State (cert, report, st)", + "description": "State of the document processing pipeline for cert, report, or st document." + }, + "cc_document_metadata": { + "type": "object", + "properties": { + "pdf_file_size_bytes": { + "type": "integer" + }, + "pdf_is_encrypted": { + "type": "boolean" + }, + "pdf_number_of_pages": { + "type": "integer" + }, + "pdf_hyperlinks": { + "type": [ + "object", + "null" + ], + "properties": { + "_type": { + "const": "Set" + }, + "elements": { + "type": "array", + "items": { + "type": "string", + "format": "uri" + }, + "uniqueItems": true + } + } + } + }, + "additionalProperties": true + }, + "cc_document_frontpage_body": { + "type": "object", + "properties": { + "match_rules": { + "type": "array", + "items": { + "type": "string" + }, + "description": "List of matching rules that were triggered to identify the front page." + }, + "cert_id": { + "$ref": "#/definitions/cc_id", + "type": [ + "string", + "null" + ], + "title": "Certificate ID", + "description": "The unique identifier of the Common Criteria certificate." + }, + "cert_item": { + "type": [ + "string", + "null" + ], + "title": "Certified Item", + "description": "The certified item as extracted from the front page." + }, + "developer": { + "type": [ + "string", + "null" + ], + "title": "Developer", + "description": "The developer of the certified item as extracted from the front page." + }, + "cert_lab": { + "type": [ + "string", + "null" + ], + "title": "Certification Lab", + "description": "The lab/scheme that issued the certificate as extracted from the front page." + }, + "ref_protection_profiles": { + "type": [ + "string", + "null" + ] + }, + "cc_version": { + "type": [ + "string", + "null" + ], + "title": "CC Version", + "description": "The version of the Common Criteria standard as extracted from the front page." + }, + "cc_security_level": { + "type": [ + "string", + "null" + ], + "title": "CC Security Level", + "description": "The security level (e.g., EAL) as extracted from the front page." + } + }, + "additionalProperties": false + }, + "cc_document_frontpage": { + "type": "object", + "properties": { + "AU": { + "$ref": "#/definitions/cc_document_frontpage_body" + }, + "CA": { + "$ref": "#/definitions/cc_document_frontpage_body" + }, + "FR": { + "$ref": "#/definitions/cc_document_frontpage_body" + }, + "DE": { + "$ref": "#/definitions/cc_document_frontpage_body" + }, + "IN": { + "$ref": "#/definitions/cc_document_frontpage_body" + }, + "IT": { + "$ref": "#/definitions/cc_document_frontpage_body" + }, + "JP": { + "$ref": "#/definitions/cc_document_frontpage_body" + }, + "MY": { + "$ref": "#/definitions/cc_document_frontpage_body" + }, + "NL": { + "$ref": "#/definitions/cc_document_frontpage_body" + }, + "NO": { + "$ref": "#/definitions/cc_document_frontpage_body" + }, + "KR": { + "$ref": "#/definitions/cc_document_frontpage_body" + }, + "PL": { + "$ref": "#/definitions/cc_document_frontpage_body" + }, + "SG": { + "$ref": "#/definitions/cc_document_frontpage_body" + }, + "ES": { + "$ref": "#/definitions/cc_document_frontpage_body" + }, + "SE": { + "$ref": "#/definitions/cc_document_frontpage_body" + }, + "TR": { + "$ref": "#/definitions/cc_document_frontpage_body" + }, + "US": { + "$ref": "#/definitions/cc_document_frontpage_body" + } + }, + "additionalProperties": false + }, + "cc_document_keywords": { + "type": "object", + "additionalProperties": true, + "title": "Certificate Document Keywords", + "description": "Extracted keywords from the certification documents.", + "$comment": "Consult the rules.yaml for the list of possible keywords and their structure." + }, + "cc_references": { + "type": "object", + "properties": { + "_type": { + "const": "sec_certs.sample.certificate.References" + }, + "directly_referenced_by": { + "type": [ + "object", + "null" + ], + "properties": { + "_type": { + "const": "Set" + }, + "elements": { + "type": "array", + "items": { + "$ref": "#/definitions/cc_id" + }, + "uniqueItems": true + } + }, + "description": "Certificates that directly reference this certificate." + }, + "directly_referencing": { + "type": [ + "object", + "null" + ], + "properties": { + "_type": { + "const": "Set" + }, + "elements": { + "type": "array", + "items": { + "$ref": "#/definitions/cc_id" + }, + "uniqueItems": true + } + }, + "description": "Certificates that are directly referenced by this certificate." + }, + "indirectly_referenced_by": { + "type": [ + "object", + "null" + ], + "properties": { + "_type": { + "const": "Set" + }, + "elements": { + "type": "array", + "items": { + "$ref": "#/definitions/cc_id" + }, + "uniqueItems": true + } + }, + "description": "Certificates that indirectly reference this certificate." + }, + "indirectly_referencing": { + "type": [ + "object", + "null" + ], + "properties": { + "_type": { + "const": "Set" + }, + "elements": { + "type": "array", + "items": { + "$ref": "#/definitions/cc_id" + }, + "uniqueItems": true + } + }, + "description": "Certificates that are indirectly referenced by this certificate." + } + }, + "additionalProperties": false, + "title": "Certificate References (report, st)", + "description": "References to and from other certificates, based on a document." + }, + "cc_sar": { + "type": "object", + "properties": { + "_type": { + "const": "sec_certs.sample.sar.SAR" + }, + "family": { + "type": "string", + "title": "SAR Family", + "description": "The family of the Security Assurance Requirement (SAR)." + }, + "level": { + "type": "integer", + "title": "SAR Level", + "description": "The level of the Security Assurance Requirement (SAR)." + } + }, + "additionalProperties": false, + "title": "SAR", + "description": "Security Assurance Requirement (SAR) as defined in Common Criteria." + }, + "cve": { + "type": "string", + "pattern": "^CVE-\\d{4}-\\d{4,}$", + "title": "CVE", + "description": "Common Vulnerabilities Enumeration (CVE) identifier" + }, + "cpe": { + "type": "string", + "title": "CPE", + "description": "Common Platform Enumeration (CPE) identifier" + } + }, + "properties": { + "_type": { + "const": "sec_certs.sample.cc.CCCertificate" + }, + "name": { + "type": "string", + "title": "Certificate Name", + "description": "The name of the Common Criteria certificate." + }, + "category": { + "enum": [ + "Access Control Devices and Systems", + "Boundary Protection Devices and Systems", + "Data Protection", + "Databases", + "Detection Devices and Systems", + "ICs, Smart Cards and Smart Card-Related Devices and Systems", + "Key Management Systems", + "Mobility", + "Multi-Function Devices", + "Network and Network-Related Devices and Systems", + "Operating Systems", + "Other Devices and Systems", + "Products for Digital Signatures", + "Trusted Computing", + "Biometric Systems and Devices" + ], + "title": "Certificate Category", + "description": "The category of the Common Criteria certificate." + }, + "scheme": { + "enum": [ + "AU", + "CA", + "FR", + "DE", + "IN", + "IT", + "JP", + "MY", + "NL", + "NO", + "KR", + "PL", + "SG", + "ES", + "SE", + "TR", + "US" + ], + "title": "Certification Scheme", + "description": "The certification scheme under which the certificate was issued." + }, + "status": { + "enum": [ + "active", + "archived" + ], + "title": "Certificate Status", + "description": "The current status of the Common Criteria certificate." + }, + "not_valid_after": { + "type": "string", + "format": "date", + "title": "Expiry Date", + "description": "The date until which the certificate is valid (expiry date)." + }, + "not_valid_before": { + "type": "string", + "format": "date", + "title": "Certification Date", + "description": "The date from which the certificate is valid (certification date)." + }, + "cert_link": { + "type": [ + "string", + "null" + ], + "format": "uri", + "title": "Certificate Link", + "description": "A URL linking to the official certificate document." + }, + "report_link": { + "type": [ + "string", + "null" + ], + "format": "uri", + "title": "Certification Report Link", + "description": "A URL linking to the certification report document." + }, + "st_link": { + "type": [ + "string", + "null" + ], + "format": "uri", + "title": "Security Target Link", + "description": "A URL linking to the security target document." + }, + "manufacturer": { + "type": "string", + "title": "Manufacturer", + "description": "The name of the manufacturer of the certified product." + }, + "manufacturer_web": { + "type": "string", + "format": "uri", + "title": "Manufacturer Website", + "description": "The website URL of the manufacturer." + }, + "security_level": { + "type": "object", + "properties": { + "_type": { + "const": "Set" + }, + "elements": { + "type": "array", + "items": { + "type": "string" + }, + "uniqueItems": true + } + }, + "title": "Security Level", + "description": "The security levels associated with the certificate." + }, + "dgst": { + "$ref": "#/definitions/cc_dgst" + }, + "heuristics": { + "type": "object", + "properties": { + "_type": { + "const": "sec_certs.sample.cc.CCCertificate.Heuristics" + }, + "eal": { + "type": [ + "string", + "null" + ] + }, + "annotated_references": { + "type": "null" + }, + "cert_id": { + "$ref": "#/definitions/cc_id", + "type": [ + "string", + "null" + ], + "title": "Certificate ID", + "description": "The unique identifier of the Common Criteria certificate." + }, + "cert_lab": { + "type": [ + "array", + "null" + ], + "items": { + "type": "string" + }, + "title": "Certification Lab", + "description": "The lab/scheme that issued the certificate." + }, + "cpe_matches": { + "type": [ + "array", + "null" + ], + "items": { + "$ref": "#/definitions/cve" + }, + "uniqueItems": true, + "title": "CPE Matches", + "description": "List of CPEs (Common Platform Enumerations) associated with the certificate." + }, + "verified_cpe_matches": { + "type": [ + "array", + "null" + ], + "items": { + "$ref": "#/definitions/cve" + }, + "uniqueItems": true, + "title": "Verified CPE Matches", + "description": "List of verified CPEs (Common Platform Enumerations) associated with the certificate." + }, + "related_cves": { + "type": [ + "array", + "null" + ], + "items": { + "$ref": "#/definitions/cve" + }, + "uniqueItems": true, + "title": "Related CVEs", + "description": "List of CVEs (Common Vulnerabilities and Exposures) likely associated with the certificate." + }, + "direct_transitive_cves": { + "type": [ + "array", + "null" + ], + "items": { + "$ref": "#/definitions/cve" + }, + "uniqueItems": true + }, + "indirect_transitive_cves": { + "type": [ + "array", + "null" + ], + "items": { + "$ref": "#/definitions/cve" + }, + "uniqueItems": true + }, + "extracted_sars": { + "type": [ + "object", + "null" + ], + "properties": { + "_type": { + "const": "Set" + }, + "elements": { + "type": "array", + "items": { + "$ref": "#/definitions/cc_sar" + }, + "uniqueItems": true + } + }, + "title": "Extracted SARs", + "description": "Security Assurance Requirements (SARs) extracted from the certification documents." + }, + "extracted_versions": { + "type": [ + "object", + "null" + ], + "properties": { + "_type": { + "const": "Set" + }, + "elements": { + "type": "array", + "items": { + "type": "string" + }, + "uniqueItems": true + } + }, + "title": "Extracted Versions", + "description": "Product versions extracted from the certification documents." + }, + "prev_certificates": { + "type": [ + "array", + "null" + ], + "items": { + "$ref": "#/definitions/cc_id" + }, + "title": "Previous Certificates", + "description": "List of previous versions of the certificate in a series, if applicable." + }, + "next_certificates": { + "type": [ + "array", + "null" + ], + "items": { + "$ref": "#/definitions/cc_id" + }, + "title": "Next Certificates", + "description": "List of next versions of the certificate in a series, if applicable." + }, + "report_references": { + "$ref": "#/definitions/cc_references", + "title": "Report References", + "description": "References to and from other certificates, based on the certification report document." + }, + "scheme_data": { + "type": [ + "object", + "null" + ], + "title": "Scheme Data", + "description": "Scheme-specific data extracted from the scheme websites.", + "$comment": "This is a free-form object and can contain any properties." + }, + "st_references": { + "$ref": "#/definitions/cc_references", + "title": "ST References", + "description": "References to and from other certificates, based on the security target document." + }, + "protection_profiles": { + "type": [ + "array", + "null" + ], + "items": { + "type": "string" + }, + "uniqueItems": true + } + }, + "additionalProperties": false, + "title": "Certificate Heuristics", + "description": "Heuristic data extracted from the certification documents." + }, + "maintenance_updates": { + "type": "object" + }, + "protection_profile_links": { + "type": "object", + "properties": { + "_type": { + "const": "Set" + }, + "elements": { + "type": "array", + "items": { + "type": "string", + "format": "uri" + }, + "uniqueItems": true + } + } + }, + "pdf_data": { + "type": "object", + "properties": { + "_type": { + "const": "sec_certs.sample.cc.CCCertificate.PdfData" + }, + "report_metadata": { + "$ref": "#/definitions/cc_document_metadata", + "title": "Report Metadata", + "description": "Metadata extracted from the certification report PDF document file." + }, + "st_metadata": { + "$ref": "#/definitions/cc_document_metadata", + "title": "ST Metadata", + "description": "Metadata extracted from the security target PDF document file." + }, + "report_keywords": { + "$ref": "#/definitions/cc_document_keywords", + "title": "Report Keywords", + "description": "Keywords extracted from the certification report document." + }, + "st_keywords": { + "$ref": "#/definitions/cc_document_keywords", + "title": "ST Keywords", + "description": "Keywords extracted from the security target document." + } + }, + "title": "Extracted PDF Data", + "description": "Data extracted from the certification PDF documents." + }, + "state": { + "type": "object", + "properties": { + "_type": { + "const": "sec_certs.sample.cc.CCCertificate.InternalState" + }, + "cert": { + "$ref": "#/definitions/cc_document_state" + }, + "report": { + "$ref": "#/definitions/cc_document_state" + }, + "st": { + "$ref": "#/definitions/cc_document_state" + } + }, + "additionalProperties": false, + "title": "Certificate Document States", + "description": "State of the document processing pipeline for cert, report, and st documents." + } + }, + "additionalProperties": false +} \ No newline at end of file diff --git a/src/sec_certs/serialization/schemas/cc_dataset.json b/src/sec_certs/serialization/schemas/cc_dataset.json new file mode 100644 index 00000000..51a07b72 --- /dev/null +++ b/src/sec_certs/serialization/schemas/cc_dataset.json @@ -0,0 +1,61 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "$id": "http://sec-certs.org/schemas/cc_dataset.json", + "title": "CC Dataset", + "description": "Schema for a Common Criteria (CC) dataset.", + "type": "object", + "properties": { + "_type": { + "const": "sec_certs.dataset.cc.CCDataset" + }, + "state": { + "type": "object", + "properties": { + "_type": { + "const": "sec_certs.dataset.dataset.Dataset.DatasetInternalState" + }, + "meta_sources_parsed": { + "type": "boolean" + }, + "artifacts_downloaded": { + "type": "boolean" + }, + "pdfs_converted": { + "type": "boolean" + }, + "auxiliary_datasets_processed": { + "type": "boolean" + }, + "certs_analyzed": { + "type": "boolean" + } + }, + "title": "Dataset internal state" + }, + "timestamp": { + "type": "string", + "format": "date-time", + "title": "Timestamp of the dataset creation" + }, + "name": { + "type": "string", + "title": "Name of the dataset" + }, + "description": { + "type": "string", + "title": "Description of the dataset" + }, + "n_certs": { + "type": "integer", + "minimum": 0, + "title": "Number of certificates in the dataset" + }, + "certs": { + "type": "array", + "items": { + "$ref": "/schemas/cc_certificate.json" + }, + "title": "List of certificates in the dataset" + } + } +} \ No newline at end of file -- cgit v1.3.1 From 1bca21fc1d4f6b0f78b70cb2fcfa979a898da5d2 Mon Sep 17 00:00:00 2001 From: J08nY Date: Thu, 25 Sep 2025 16:59:46 +0200 Subject: Fix CC schema validation tests. --- src/sec_certs/serialization/schemas/cc_certificate.json | 16 +++++++++------- .../serialization/schemas/fips_certificate.json | 0 tests/cc/conftest.py | 4 ++-- tests/data/cc/certificate/fictional_cert.json | 4 ++-- 4 files changed, 13 insertions(+), 11 deletions(-) create mode 100644 src/sec_certs/serialization/schemas/fips_certificate.json (limited to 'src') diff --git a/src/sec_certs/serialization/schemas/cc_certificate.json b/src/sec_certs/serialization/schemas/cc_certificate.json index ec34cdf5..750b4a00 100644 --- a/src/sec_certs/serialization/schemas/cc_certificate.json +++ b/src/sec_certs/serialization/schemas/cc_certificate.json @@ -12,7 +12,7 @@ "description": "A hex string representing 8 bytes." }, "cc_id": { - "type": "string", + "type": ["string", "null"], "title": "Certificate ID", "description": "The unique identifier of the Common Criteria certificate." }, @@ -58,7 +58,10 @@ "description": "State of the document processing pipeline for cert, report, or st document." }, "cc_document_metadata": { - "type": "object", + "type": [ + "object", + "null" + ], "properties": { "pdf_file_size_bytes": { "type": "integer" @@ -217,7 +220,10 @@ "additionalProperties": false }, "cc_document_keywords": { - "type": "object", + "type": [ + "object", + "null" + ], "additionalProperties": true, "title": "Certificate Document Keywords", "description": "Extracted keywords from the certification documents.", @@ -491,10 +497,6 @@ }, "cert_id": { "$ref": "#/definitions/cc_id", - "type": [ - "string", - "null" - ], "title": "Certificate ID", "description": "The unique identifier of the Common Criteria certificate." }, diff --git a/src/sec_certs/serialization/schemas/fips_certificate.json b/src/sec_certs/serialization/schemas/fips_certificate.json new file mode 100644 index 00000000..e69de29b diff --git a/tests/cc/conftest.py b/tests/cc/conftest.py index 8651b92e..12fbc2db 100644 --- a/tests/cc/conftest.py +++ b/tests/cc/conftest.py @@ -74,10 +74,10 @@ def cert_two() -> CCCertificate: return CCCertificate( "archived", - "Sample category", + "Access Control Devices and Systems", "Sample certificate name", "Sample manufacturer", - "Sample scheme", + "DE", {"Sample security level"}, date(1900, 1, 2), date(1900, 1, 3), diff --git a/tests/data/cc/certificate/fictional_cert.json b/tests/data/cc/certificate/fictional_cert.json index 15b7f507..5206c811 100644 --- a/tests/data/cc/certificate/fictional_cert.json +++ b/tests/data/cc/certificate/fictional_cert.json @@ -1,8 +1,8 @@ { "_type": "sec_certs.sample.cc.CCCertificate", - "dgst": "8049938203b26f7b", + "dgst": "265b6e29d58940b7", "status": "archived", - "category": "Sample category", + "category": "Access Control Devices and Systems", "name": "Sample certificate name", "manufacturer": "Sample manufacturer", "scheme": "DE", -- cgit v1.3.1 From e3a498262e62d4b24413c9f24e1249886c27e2ea Mon Sep 17 00:00:00 2001 From: J08nY Date: Thu, 25 Sep 2025 22:56:46 +0200 Subject: Add FIPS certificate JSON schema. --- src/sec_certs/serialization/schemas/__init__.py | 17 + src/sec_certs/serialization/schemas/base.json | 146 ++++++++ .../serialization/schemas/cc_certificate.json | 141 +------- .../serialization/schemas/cc_dataset.json | 5 +- .../serialization/schemas/fips_certificate.json | 387 +++++++++++++++++++++ .../serialization/schemas/fips_dataset.json | 62 ++++ tests/cc/test_cc_analysis.py | 34 +- tests/cc/test_cc_certificate.py | 11 +- tests/cc/test_cc_dataset.py | 19 +- tests/data/fips/__init__.py | 0 tests/fips/test_fips_analysis.py | 21 ++ tests/fips/test_fips_certificate.py | 7 + tests/fips/test_fips_dataset.py | 17 + 13 files changed, 696 insertions(+), 171 deletions(-) create mode 100644 src/sec_certs/serialization/schemas/base.json create mode 100644 src/sec_certs/serialization/schemas/fips_dataset.json create mode 100644 tests/data/fips/__init__.py (limited to 'src') diff --git a/src/sec_certs/serialization/schemas/__init__.py b/src/sec_certs/serialization/schemas/__init__.py index e69de29b..31fd252e 100644 --- a/src/sec_certs/serialization/schemas/__init__.py +++ b/src/sec_certs/serialization/schemas/__init__.py @@ -0,0 +1,17 @@ +import json +from importlib import resources + +from jsonschema import Draft7Validator +from referencing import Registry, Resource + +_schemas = ["base.json", "cc_certificate.json", "cc_dataset.json", "fips_certificate.json", "fips_dataset.json"] + + +def validator(for_schema: str) -> Draft7Validator: + registry = Registry() + for schema in _schemas: + with resources.open_text("sec_certs.serialization.schemas", schema) as f: + schema_json = json.load(f) + resource = Resource.from_contents(schema_json) + registry = resource @ registry + return Draft7Validator(schema={"$ref": for_schema}, registry=registry) diff --git a/src/sec_certs/serialization/schemas/base.json b/src/sec_certs/serialization/schemas/base.json new file mode 100644 index 00000000..77fb21fd --- /dev/null +++ b/src/sec_certs/serialization/schemas/base.json @@ -0,0 +1,146 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "$id": "http://sec-certs.org/schemas/base.json", + "title": "Base sec-certs definitions", + "description": "Common definitions used across sec-certs schemas.", + "definitions": { + "cve": { + "type": "string", + "pattern": "^CVE-\\d{4}-\\d{4,}$", + "title": "CVE", + "description": "Common Vulnerabilities Enumeration (CVE) identifier" + }, + "cpe": { + "type": "string", + "title": "CPE", + "description": "Common Platform Enumeration (CPE) identifier" + }, + "cpe_matches": { + "type": [ + "array", + "null" + ], + "items": { + "$ref": "#/definitions/cpe" + }, + "uniqueItems": true, + "title": "CPE Matches", + "description": "List of CPEs (Common Platform Enumerations) associated with the certificate." + }, + "verified_cpe_matches": { + "type": [ + "array", + "null" + ], + "items": { + "$ref": "#/definitions/cpe" + }, + "uniqueItems": true, + "title": "Verified CPE Matches", + "description": "List of verified CPEs (Common Platform Enumerations) associated with the certificate." + }, + "related_cves": { + "type": [ + "array", + "null" + ], + "items": { + "$ref": "#/definitions/cve" + }, + "uniqueItems": true, + "title": "Related CVEs", + "description": "List of CVEs (Common Vulnerabilities and Exposures) likely associated with the certificate." + }, + "direct_transitive_cves": { + "type": [ + "array", + "null" + ], + "items": { + "$ref": "#/definitions/cve" + }, + "uniqueItems": true + }, + "indirect_transitive_cves": { + "type": [ + "array", + "null" + ], + "items": { + "$ref": "#/definitions/cve" + }, + "uniqueItems": true + }, + "extracted_versions": { + "type": [ + "object", + "null" + ], + "properties": { + "_type": { + "const": "Set" + }, + "elements": { + "type": "array", + "items": { + "type": "string" + }, + "uniqueItems": true + } + }, + "title": "Extracted Versions", + "description": "Product versions extracted from the certification documents." + }, + "document_metadata": { + "type": [ + "object", + "null" + ], + "properties": { + "pdf_file_size_bytes": { + "type": "integer", + "description": "Size of the PDF document in bytes." + }, + "pdf_is_encrypted": { + "type": "boolean", + "description": "Indicates if the PDF document is encrypted." + }, + "pdf_number_of_pages": { + "type": "integer", + "description": "Number of pages in the PDF document." + }, + "pdf_hyperlinks": { + "type": [ + "object", + "null" + ], + "properties": { + "_type": { + "const": "Set" + }, + "elements": { + "type": "array", + "items": { + "type": "string", + "format": "uri" + }, + "uniqueItems": true + } + }, + "description": "Set of hyperlinks found in the PDF document." + } + }, + "additionalProperties": true + }, + "document_keywords": { + "type": [ + "object", + "null" + ], + "additionalProperties": true, + "title": "Certificate Document Keywords", + "description": "Extracted keywords from the certification documents.", + "$comment": "Consult the rules.yaml for the list of possible keywords and their structure." + } + } +} diff --git a/src/sec_certs/serialization/schemas/cc_certificate.json b/src/sec_certs/serialization/schemas/cc_certificate.json index 750b4a00..bb6791a1 100644 --- a/src/sec_certs/serialization/schemas/cc_certificate.json +++ b/src/sec_certs/serialization/schemas/cc_certificate.json @@ -12,7 +12,10 @@ "description": "A hex string representing 8 bytes." }, "cc_id": { - "type": ["string", "null"], + "type": [ + "string", + "null" + ], "title": "Certificate ID", "description": "The unique identifier of the Common Criteria certificate." }, @@ -57,43 +60,6 @@ "title": "Certificate Document State (cert, report, st)", "description": "State of the document processing pipeline for cert, report, or st document." }, - "cc_document_metadata": { - "type": [ - "object", - "null" - ], - "properties": { - "pdf_file_size_bytes": { - "type": "integer" - }, - "pdf_is_encrypted": { - "type": "boolean" - }, - "pdf_number_of_pages": { - "type": "integer" - }, - "pdf_hyperlinks": { - "type": [ - "object", - "null" - ], - "properties": { - "_type": { - "const": "Set" - }, - "elements": { - "type": "array", - "items": { - "type": "string", - "format": "uri" - }, - "uniqueItems": true - } - } - } - }, - "additionalProperties": true - }, "cc_document_frontpage_body": { "type": "object", "properties": { @@ -219,16 +185,6 @@ }, "additionalProperties": false }, - "cc_document_keywords": { - "type": [ - "object", - "null" - ], - "additionalProperties": true, - "title": "Certificate Document Keywords", - "description": "Extracted keywords from the certification documents.", - "$comment": "Consult the rules.yaml for the list of possible keywords and their structure." - }, "cc_references": { "type": "object", "properties": { @@ -336,17 +292,6 @@ "additionalProperties": false, "title": "SAR", "description": "Security Assurance Requirement (SAR) as defined in Common Criteria." - }, - "cve": { - "type": "string", - "pattern": "^CVE-\\d{4}-\\d{4,}$", - "title": "CVE", - "description": "Common Vulnerabilities Enumeration (CVE) identifier" - }, - "cpe": { - "type": "string", - "title": "CPE", - "description": "Common Platform Enumeration (CPE) identifier" } }, "properties": { @@ -512,60 +457,19 @@ "description": "The lab/scheme that issued the certificate." }, "cpe_matches": { - "type": [ - "array", - "null" - ], - "items": { - "$ref": "#/definitions/cve" - }, - "uniqueItems": true, - "title": "CPE Matches", - "description": "List of CPEs (Common Platform Enumerations) associated with the certificate." + "$ref": "/schemas/base.json#/definitions/cpe_matches" }, "verified_cpe_matches": { - "type": [ - "array", - "null" - ], - "items": { - "$ref": "#/definitions/cve" - }, - "uniqueItems": true, - "title": "Verified CPE Matches", - "description": "List of verified CPEs (Common Platform Enumerations) associated with the certificate." + "$ref": "/schemas/base.json#/definitions/verified_cpe_matches" }, "related_cves": { - "type": [ - "array", - "null" - ], - "items": { - "$ref": "#/definitions/cve" - }, - "uniqueItems": true, - "title": "Related CVEs", - "description": "List of CVEs (Common Vulnerabilities and Exposures) likely associated with the certificate." + "$ref": "/schemas/base.json#/definitions/related_cves" }, "direct_transitive_cves": { - "type": [ - "array", - "null" - ], - "items": { - "$ref": "#/definitions/cve" - }, - "uniqueItems": true + "$ref": "/schemas/base.json#/definitions/direct_transitive_cves" }, "indirect_transitive_cves": { - "type": [ - "array", - "null" - ], - "items": { - "$ref": "#/definitions/cve" - }, - "uniqueItems": true + "$ref": "/schemas/base.json#/definitions/indirect_transitive_cves" }, "extracted_sars": { "type": [ @@ -588,24 +492,7 @@ "description": "Security Assurance Requirements (SARs) extracted from the certification documents." }, "extracted_versions": { - "type": [ - "object", - "null" - ], - "properties": { - "_type": { - "const": "Set" - }, - "elements": { - "type": "array", - "items": { - "type": "string" - }, - "uniqueItems": true - } - }, - "title": "Extracted Versions", - "description": "Product versions extracted from the certification documents." + "$ref": "/schemas/base.json#/definitions/extracted_versions" }, "prev_certificates": { "type": [ @@ -689,22 +576,22 @@ "const": "sec_certs.sample.cc.CCCertificate.PdfData" }, "report_metadata": { - "$ref": "#/definitions/cc_document_metadata", + "$ref": "/schemas/base.json#/definitions/document_metadata", "title": "Report Metadata", "description": "Metadata extracted from the certification report PDF document file." }, "st_metadata": { - "$ref": "#/definitions/cc_document_metadata", + "$ref": "/schemas/base.json#/definitions/document_metadata", "title": "ST Metadata", "description": "Metadata extracted from the security target PDF document file." }, "report_keywords": { - "$ref": "#/definitions/cc_document_keywords", + "$ref": "/schemas/base.json#/definitions/document_keywords", "title": "Report Keywords", "description": "Keywords extracted from the certification report document." }, "st_keywords": { - "$ref": "#/definitions/cc_document_keywords", + "$ref": "/schemas/base.json#/definitions/document_keywords", "title": "ST Keywords", "description": "Keywords extracted from the security target document." } diff --git a/src/sec_certs/serialization/schemas/cc_dataset.json b/src/sec_certs/serialization/schemas/cc_dataset.json index 51a07b72..3e57b349 100644 --- a/src/sec_certs/serialization/schemas/cc_dataset.json +++ b/src/sec_certs/serialization/schemas/cc_dataset.json @@ -53,9 +53,10 @@ "certs": { "type": "array", "items": { - "$ref": "/schemas/cc_certificate.json" + "$ref": "/schemas/cc_certificate.json#" }, "title": "List of certificates in the dataset" } - } + }, + "additionalProperties": false } \ No newline at end of file diff --git a/src/sec_certs/serialization/schemas/fips_certificate.json b/src/sec_certs/serialization/schemas/fips_certificate.json index e69de29b..9356fd27 100644 --- a/src/sec_certs/serialization/schemas/fips_certificate.json +++ b/src/sec_certs/serialization/schemas/fips_certificate.json @@ -0,0 +1,387 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "$id": "http://sec-certs.org/schemas/fips_certificate.json", + "title": "FIPS 140 Certificate", + "description": "Schema for a FIPS 140 certificate.", + "type": "object", + "definitions": { + "fips_dgst": { + "type": "string", + "pattern": "^[0-9a-fA-F]{16}$", + "title": "Certificate Digest", + "description": "A hex string representing 8 bytes." + }, + "fips_id": { + "type": "integer", + "minimum": 0, + "title": "Certificate ID", + "description": "A non-negative integer representing the certificate ID." + }, + "fips_references": { + "type": "object", + "properties": { + "_type": { + "const": "sec_certs.sample.certificate.References" + }, + "directly_referenced_by": { + "type": [ + "array", + "null" + ], + "items": { + "$ref": "#/definitions/fips_id" + }, + "uniqueItems": true, + "description": "Certificates that directly reference this certificate." + }, + "indirectly_referenced_by": { + "type": [ + "array", + "null" + ], + "items": { + "$ref": "#/definitions/fips_id" + }, + "uniqueItems": true, + "description": "Certificates that indirectly reference this certificate." + }, + "directly_referencing": { + "type": [ + "array", + "null" + ], + "items": { + "$ref": "#/definitions/fips_id" + }, + "uniqueItems": true, + "description": "Certificates that are directly referenced by this certificate." + }, + "indirectly_referencing": { + "type": [ + "array", + "null" + ], + "items": { + "$ref": "#/definitions/fips_id" + }, + "uniqueItems": true, + "description": "Certificates that are indirectly referenced by this certificate." + } + } + } + }, + "properties": { + "_type": { + "const": "sec_certs.sample.fips.FIPSCertificate" + }, + "dgst": { + "$ref": "#/definitions/fips_dgst" + }, + "cert_id": { + "$ref": "#/definitions/fips_id" + }, + "web_data": { + "type": "object", + "properties": { + "_type": { + "const": "sec_certs.sample.fips.FIPSCertificate.WebData" + }, + "module_name": { + "type": [ + "string", + "null" + ], + "title": "Module Name", + "description": "The name of the certified module." + }, + "validation_history": { + "type": [ + "array", + "null" + ], + "items": { + "type": "object", + "properties": { + "_type": { + "const": "sec_certs.sample.fips.FIPSCertificate.ValidationHistoryEntry" + }, + "date": { + "type": "string", + "format": "date", + "description": "The date of the validation event in YYYY-MM-DD format." + }, + "validation_type": { + "enum": [ + "Initial", + "Update" + ], + "description": "The type of validation event." + }, + "lab": { + "type": "string", + "description": "The name of the lab that performed the validation." + } + }, + "additionalProperties": false + } + }, + "vendor_url": { + "type": [ + "string", + "null" + ] + }, + "vendor": { + "type": [ + "string", + "null" + ] + }, + "certificate_pdf_url": { + "type": [ + "string", + "null" + ] + }, + "module_type": { + "type": [ + "string", + "null" + ] + }, + "standard": { + "type": [ + "string", + "null" + ] + }, + "status": { + "type": [ + "string", + "null" + ] + }, + "level": { + "type": [ + "string", + "null" + ] + }, + "caveat": { + "type": [ + "string", + "null" + ] + }, + "exceptions": { + "type": [ + "string", + "null" + ] + }, + "embodiment": { + "type": [ + "string", + "null" + ] + }, + "description": { + "type": [ + "string", + "null" + ] + }, + "tested_conf": { + "type": [ + "string", + "null" + ] + }, + "hw_versions": { + "type": [ + "string", + "null" + ] + }, + "fw_versions": { + "type": [ + "string", + "null" + ] + }, + "sw_versions": { + "type": [ + "string", + "null" + ] + }, + "mentioned_certs": { + "type": [ + "string", + "null" + ] + }, + "historical_reason": { + "type": [ + "string", + "null" + ] + }, + "date_sunset": { + "type": [ + "string", + "null" + ] + }, + "revoked_reason": { + "type": [ + "string", + "null" + ] + }, + "revoked_link": { + "type": [ + "string", + "null" + ] + } + } + }, + "pdf_data": { + "type": "object", + "properties": { + "_type": { + "const": "sec_certs.sample.fips.FIPSCertificate.PdfData" + }, + "keywords": { + "$ref": "/schemas/base.json#/definitions/document_keywords", + "title": "Security Policy Keywords", + "description": "Keywords extracted from the security policy document." + }, + "policy_metadata": { + "$ref": "/schemas/base.json#/definitions/document_metadata", + "title": "Security Policy Metadata", + "description": "Metadata extracted from the security policy document." + } + } + }, + "heuristics": { + "type": "object", + "properties": { + "_type": { + "const": "sec_certs.sample.fips.FIPSCertificate.Heuristics" + }, + "algorithms": { + "type": "object", + "properties": { + "_type": { + "const": "Set" + }, + "elements": { + "type": "array", + "items": { + "type": "string" + } + } + } + }, + "extracted_versions": { + "$ref": "/schemas/base.json#/definitions/extracted_versions" + }, + "cpe_matches": { + "$ref": "/schemas/base.json#/definitions/cpe_matches" + }, + "verified_cpe_matches": { + "$ref": "/schemas/base.json#/definitions/verified_cpe_matches" + }, + "related_cves": { + "$ref": "/schemas/base.json#/definitions/related_cves" + }, + "policy_prunned_references": { + "type": "object", + "properties": { + "_type": { + "const": "Set" + }, + "elements": { + "type": "array", + "items": { + "$ref": "#/definitions/fips_id" + }, + "uniqueItems": true + } + } + }, + "module_prunned_references": { + "type": "object", + "properties": { + "_type": { + "const": "Set" + }, + "elements": { + "type": "array", + "items": { + "$ref": "#/definitions/fips_id" + }, + "uniqueItems": true + } + } + }, + "policy_processed_references": { + "$ref": "#/definitions/fips_references", + "description": "References to and from other certificates, based on the security policy document." + }, + "module_processed_references": { + "$ref": "#/definitions/fips_references", + "description": "References to and from other certificates, based on the module page." + }, + "direct_transitive_cves": { + "$ref": "/schemas/base.json#/definitions/direct_transitive_cves" + }, + "indirect_transitive_cves": { + "$ref": "/schemas/base.json#/definitions/indirect_transitive_cves" + } + }, + "additionalProperties": false, + "title": "Certificate Heuristics", + "description": "Heuristic data extracted from the certification documents." + }, + "state": { + "type": "object", + "properties": { + "_type": { + "const": "sec_certs.sample.fips.FIPSCertificate.InternalState" + }, + "module_download_ok": { + "type": "boolean" + }, + "policy_download_ok": { + "type": "boolean" + }, + "policy_convert_garbage": { + "type": "boolean" + }, + "policy_convert_ok": { + "type": "boolean" + }, + "module_extract_ok": { + "type": "boolean" + }, + "policy_extract_ok": { + "type": "boolean" + }, + "policy_pdf_hash": { + "type": "string", + "pattern": "^[0-9a-fA-F]{64}$", + "description": "SHA256 hash of the policy PDF file." + }, + "policy_txt_hash": { + "type": "string", + "pattern": "^[0-9a-fA-F]{64}$", + "description": "SHA256 hash of the policy txt file." + } + } + } + }, + "additionalProperties": false +} \ No newline at end of file diff --git a/src/sec_certs/serialization/schemas/fips_dataset.json b/src/sec_certs/serialization/schemas/fips_dataset.json new file mode 100644 index 00000000..c488bce6 --- /dev/null +++ b/src/sec_certs/serialization/schemas/fips_dataset.json @@ -0,0 +1,62 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "$id": "http://sec-certs.org/schemas/fips_dataset.json", + "title": "FIPS 140 Dataset", + "description": "Schema for a FIPS 140 dataset.", + "type": "object", + "properties": { + "_type": { + "const": "sec_certs.dataset.fips.FIPSDataset" + }, + "state": { + "type": "object", + "properties": { + "_type": { + "const": "sec_certs.dataset.dataset.Dataset.DatasetInternalState" + }, + "meta_sources_parsed": { + "type": "boolean" + }, + "artifacts_downloaded": { + "type": "boolean" + }, + "pdfs_converted": { + "type": "boolean" + }, + "auxiliary_datasets_processed": { + "type": "boolean" + }, + "certs_analyzed": { + "type": "boolean" + } + }, + "title": "Dataset internal state" + }, + "timestamp": { + "type": "string", + "format": "date-time", + "title": "Timestamp of the dataset creation" + }, + "name": { + "type": "string", + "title": "Name of the dataset" + }, + "description": { + "type": "string", + "title": "Description of the dataset" + }, + "n_certs": { + "type": "integer", + "minimum": 0, + "title": "Number of certificates in the dataset" + }, + "certs": { + "type": "array", + "items": { + "$ref": "/schemas/fips_certificate.json#" + }, + "title": "List of certificates in the dataset" + } + }, + "additionalProperties": false +} \ No newline at end of file diff --git a/tests/cc/test_cc_analysis.py b/tests/cc/test_cc_analysis.py index 42c97bac..f210287a 100644 --- a/tests/cc/test_cc_analysis.py +++ b/tests/cc/test_cc_analysis.py @@ -10,10 +10,7 @@ from tempfile import TemporaryDirectory import pytest import tests.data.cc.analysis import tests.data.common -from jsonschema import Draft7Validator, validate -from referencing import Registry, Resource -import sec_certs.serialization.schemas from sec_certs.cert_rules import SARS_IMPLIED_FROM_EAL from sec_certs.dataset.auxiliary_dataset_handling import ( CPEDatasetHandler, @@ -29,6 +26,7 @@ from sec_certs.heuristics.common import compute_related_cves, compute_transitive from sec_certs.model.references_nlp.segment_extractor import ReferenceSegmentExtractor from sec_certs.sample.cc import CCCertificate from sec_certs.sample.sar import SAR +from sec_certs.serialization.schemas import validator @pytest.fixture(scope="module") @@ -265,33 +263,17 @@ def test_segment_extractor(reference_dataset: CCDataset): assert not df.empty -def test_schema_validate_single(reference_dataset: CCDataset): - with ( - resources.open_text(sec_certs.serialization.schemas, "cc_certificate.json") as schema_file, - TemporaryDirectory() as tmp_dir, - ): - schema = json.load(schema_file) +def test_schema_validate(reference_dataset: CCDataset): + with TemporaryDirectory() as tmp_dir: + single_v = validator("http://sec-certs.org/schemas/cc_certificate.json") for cert in reference_dataset: fname = Path(tmp_dir) / (cert.dgst + ".json") cert.to_json(fname) with fname.open("r") as handle: - validate(instance=json.load(handle), schema=schema) - + single_v.validate(json.load(handle)) -def test_schema_validate_full(reference_dataset: CCDataset): - registry = Registry() - with ( - resources.open_text(sec_certs.serialization.schemas, "cc_certificate.json") as cert_schema_file, - resources.open_text(sec_certs.serialization.schemas, "cc_dataset.json") as dataset_schema_file, - ): - cert_schema = json.load(cert_schema_file) - registry = Resource.from_contents(cert_schema) @ registry - dataset_schema = json.load(dataset_schema_file) - registry = Resource.from_contents(dataset_schema) @ registry - validator = Draft7Validator(schema={"$ref": "http://sec-certs.org/schemas/cc_dataset.json"}, registry=registry) - - with TemporaryDirectory() as tmp_dir: - fname = Path(tmp_dir) / "dataset.json" + dset_v = validator("http://sec-certs.org/schemas/cc_dataset.json") + fname = Path(tmp_dir) / "dset.json" reference_dataset.to_json(fname) with fname.open("r") as handle: - validator.validate(instance=json.load(handle)) + dset_v.validate(json.load(handle)) diff --git a/tests/cc/test_cc_certificate.py b/tests/cc/test_cc_certificate.py index d53663dd..83c65dc4 100644 --- a/tests/cc/test_cc_certificate.py +++ b/tests/cc/test_cc_certificate.py @@ -7,11 +7,10 @@ from pathlib import Path import pytest import tests.data.cc.analysis import tests.data.cc.certificate -from jsonschema import validate -import sec_certs.serialization.schemas from sec_certs.dataset import CCDataset from sec_certs.sample import CCCertificate +from sec_certs.serialization.schemas import validator @pytest.fixture(scope="module") @@ -105,8 +104,6 @@ def test_cert_older_dgst(cert_one: CCCertificate): def test_schema_validation(data_dir: Path): - with ( - (data_dir / "fictional_cert.json").open("r") as cert, - resources.open_text(sec_certs.serialization.schemas, "cc_certificate.json") as schema, - ): - validate(json.load(cert), json.load(schema)) + with (data_dir / "fictional_cert.json").open("r") as cert: + v = validator("http://sec-certs.org/schemas/cc_certificate.json") + v.validate(json.load(cert)) diff --git a/tests/cc/test_cc_dataset.py b/tests/cc/test_cc_dataset.py index 071f5330..cd967000 100644 --- a/tests/cc/test_cc_dataset.py +++ b/tests/cc/test_cc_dataset.py @@ -1,17 +1,15 @@ import json import shutil -from importlib import resources from pathlib import Path from tempfile import TemporaryDirectory import pytest -from jsonschema import validate -import sec_certs.serialization.schemas from sec_certs import constants from sec_certs.configuration import config from sec_certs.dataset.cc import CCDataset from sec_certs.sample.cc import CCCertificate +from sec_certs.serialization.schemas import validator from sec_certs.utils import helpers @@ -172,13 +170,16 @@ def test_to_pandas(toy_dataset: CCDataset): def test_schema_validate(toy_dataset: CCDataset): - with ( - resources.open_text(sec_certs.serialization.schemas, "cc_certificate.json") as schema_file, - TemporaryDirectory() as tmp_dir, - ): - schema = json.load(schema_file) + with TemporaryDirectory() as tmp_dir: + single_v = validator("http://sec-certs.org/schemas/cc_certificate.json") for cert in toy_dataset: fname = Path(tmp_dir) / (cert.dgst + ".json") cert.to_json(fname) with fname.open("r") as handle: - validate(instance=json.load(handle), schema=schema) + single_v.validate(json.load(handle)) + + dset_v = validator("http://sec-certs.org/schemas/cc_dataset.json") + fname = Path(tmp_dir) / "dset.json" + toy_dataset.to_json(fname) + with fname.open("r") as handle: + dset_v.validate(json.load(handle)) diff --git a/tests/data/fips/__init__.py b/tests/data/fips/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/tests/fips/test_fips_analysis.py b/tests/fips/test_fips_analysis.py index 54954c41..53bd97cb 100644 --- a/tests/fips/test_fips_analysis.py +++ b/tests/fips/test_fips_analysis.py @@ -1,10 +1,15 @@ from __future__ import annotations +import json +from pathlib import Path +from tempfile import TemporaryDirectory + import pytest from sec_certs.dataset.auxiliary_dataset_handling import CPEDatasetHandler, CVEDatasetHandler from sec_certs.dataset.fips import FIPSDataset from sec_certs.heuristics.common import compute_related_cves +from sec_certs.serialization.schemas import validator @pytest.mark.parametrize( @@ -140,3 +145,19 @@ def test_keywords_heuristics(processed_dataset: FIPSDataset): assert not keywords["pq_crypto"] assert keywords["crypto_library"]["OpenSSL"]["OpenSSL"] == 83 assert keywords["side_channel_analysis"]["SCA"]["timing attacks"] == 1 + + +def test_schema_validate(processed_dataset: FIPSDataset): + with TemporaryDirectory() as tmp_dir: + single_v = validator("http://sec-certs.org/schemas/fips_certificate.json") + for cert in processed_dataset: + fname = Path(tmp_dir) / (cert.dgst + ".json") + cert.to_json(fname) + with fname.open("r") as handle: + single_v.validate(json.load(handle)) + + dset_v = validator("http://sec-certs.org/schemas/fips_dataset.json") + fname = Path(tmp_dir) / "dset.json" + processed_dataset.to_json(fname) + with fname.open("r") as handle: + dset_v.validate(json.load(handle)) diff --git a/tests/fips/test_fips_certificate.py b/tests/fips/test_fips_certificate.py index 8b326365..f6adb74d 100644 --- a/tests/fips/test_fips_certificate.py +++ b/tests/fips/test_fips_certificate.py @@ -12,6 +12,7 @@ import tests.data.fips.dataset from sec_certs.dataset.fips import FIPSDataset from sec_certs.sample.fips import FIPSCertificate +from sec_certs.serialization.schemas import validator @pytest.fixture(scope="module") @@ -70,3 +71,9 @@ def test_cert_to_json(certificate: FIPSCertificate, tmp_path: Path, data_dir: Pa def test_cert_from_json(certificate: FIPSCertificate, data_dir: Path): crt = FIPSCertificate.from_json(data_dir / "fictional_cert.json") assert certificate == crt + + +def test_schema_validation(data_dir: Path): + with (data_dir / "fictional_cert.json").open("r") as cert: + v = validator("http://sec-certs.org/schemas/fips_certificate.json") + v.validate(json.load(cert)) diff --git a/tests/fips/test_fips_dataset.py b/tests/fips/test_fips_dataset.py index f66a363c..93a82c9f 100644 --- a/tests/fips/test_fips_dataset.py +++ b/tests/fips/test_fips_dataset.py @@ -14,6 +14,7 @@ from sec_certs import constants from sec_certs.configuration import config from sec_certs.dataset.fips import FIPSDataset from sec_certs.sample.fips import FIPSCertificate +from sec_certs.serialization.schemas import validator from sec_certs.utils import helpers @@ -129,3 +130,19 @@ def test_to_pandas(toy_dataset: FIPSDataset): assert df.shape == (len(toy_dataset), len(FIPSCertificate.pandas_columns)) assert df.index.name == "dgst" assert set(df.columns) == set(FIPSCertificate.pandas_columns).union({"year_from"}) - {"dgst"} + + +def test_schema_validate(toy_dataset: FIPSDataset): + with TemporaryDirectory() as tmp_dir: + single_v = validator("http://sec-certs.org/schemas/fips_certificate.json") + for cert in toy_dataset: + fname = Path(tmp_dir) / (cert.dgst + ".json") + cert.to_json(fname) + with fname.open("r") as handle: + single_v.validate(json.load(handle)) + + dset_v = validator("http://sec-certs.org/schemas/fips_dataset.json") + fname = Path(tmp_dir) / "dset.json" + toy_dataset.to_json(fname) + with fname.open("r") as handle: + dset_v.validate(json.load(handle)) -- cgit v1.3.1 From 530ca32a88454a6f9878ae0d933aa1eaa2a1714e Mon Sep 17 00:00:00 2001 From: J08nY Date: Fri, 26 Sep 2025 12:19:57 +0200 Subject: Fix schemas using full dataset. --- src/sec_certs/serialization/schemas/base.json | 90 ++++++++++++---- .../serialization/schemas/cc_certificate.json | 42 +++++--- .../serialization/schemas/fips_certificate.json | 119 ++++++++++++++------- 3 files changed, 174 insertions(+), 77 deletions(-) (limited to 'src') diff --git a/src/sec_certs/serialization/schemas/base.json b/src/sec_certs/serialization/schemas/base.json index 77fb21fd..6d5861d8 100644 --- a/src/sec_certs/serialization/schemas/base.json +++ b/src/sec_certs/serialization/schemas/base.json @@ -17,59 +17,105 @@ }, "cpe_matches": { "type": [ - "array", + "object", "null" ], - "items": { - "$ref": "#/definitions/cpe" + "properties": { + "_type": { + "const": "Set" + }, + "elements": { + "type": "array", + "items": { + "$ref": "#/definitions/cpe" + }, + "uniqueItems": true + } }, - "uniqueItems": true, "title": "CPE Matches", "description": "List of CPEs (Common Platform Enumerations) associated with the certificate." }, "verified_cpe_matches": { "type": [ - "array", + "object", "null" ], - "items": { - "$ref": "#/definitions/cpe" + "properties": { + "_type": { + "const": "Set" + }, + "elements": { + "type": "array", + "items": { + "$ref": "#/definitions/cpe" + }, + "uniqueItems": true + } }, - "uniqueItems": true, "title": "Verified CPE Matches", "description": "List of verified CPEs (Common Platform Enumerations) associated with the certificate." }, "related_cves": { "type": [ - "array", + "object", "null" ], - "items": { - "$ref": "#/definitions/cve" + "properties": { + "_type": { + "const": "Set" + }, + "elements": { + "type": "array", + "items": { + "$ref": "#/definitions/cve" + }, + "uniqueItems": true + } }, - "uniqueItems": true, "title": "Related CVEs", "description": "List of CVEs (Common Vulnerabilities and Exposures) likely associated with the certificate." }, "direct_transitive_cves": { "type": [ - "array", + "object", "null" ], - "items": { - "$ref": "#/definitions/cve" - }, - "uniqueItems": true + "properties": { + "_type": { + "const": "Set" + }, + "elements": { + "type": "array", + "items": { + "$ref": "#/definitions/cve" + }, + "uniqueItems": true + } + } }, "indirect_transitive_cves": { "type": [ - "array", + "object", "null" ], - "items": { - "$ref": "#/definitions/cve" - }, - "uniqueItems": true + "properties": { + "_type": { + "const": "Set" + }, + "elements": { + "type": "array", + "items": { + "$ref": "#/definitions/cve" + }, + "uniqueItems": true + } + } + }, + "dgst": { + "type": "string", + "pattern": "^[0-9a-fA-F]{16}$", + "title": "Certificate Digest", + "description": "A hex string representing 8 bytes." }, "extracted_versions": { "type": [ diff --git a/src/sec_certs/serialization/schemas/cc_certificate.json b/src/sec_certs/serialization/schemas/cc_certificate.json index bb6791a1..23556008 100644 --- a/src/sec_certs/serialization/schemas/cc_certificate.json +++ b/src/sec_certs/serialization/schemas/cc_certificate.json @@ -5,12 +5,6 @@ "description": "Schema for a Common Criteria (CC) certificate.", "type": "object", "definitions": { - "cc_dgst": { - "type": "string", - "pattern": "^[0-9a-fA-F]{16}$", - "title": "Certificate Digest", - "description": "A hex string representing 8 bytes." - }, "cc_id": { "type": [ "string", @@ -342,7 +336,9 @@ "ES", "SE", "TR", - "US" + "US", + "UK", + "QA" ], "title": "Certification Scheme", "description": "The certification scheme under which the certificate was issued." @@ -395,12 +391,18 @@ "description": "A URL linking to the security target document." }, "manufacturer": { - "type": "string", + "type": [ + "string", + "null" + ], "title": "Manufacturer", "description": "The name of the manufacturer of the certified product." }, "manufacturer_web": { - "type": "string", + "type": [ + "string", + "null" + ], "format": "uri", "title": "Manufacturer Website", "description": "The website URL of the manufacturer." @@ -423,7 +425,7 @@ "description": "The security levels associated with the certificate." }, "dgst": { - "$ref": "#/definitions/cc_dgst" + "$ref": "/schemas/base.json#/definitions/dgst" }, "heuristics": { "type": "object", @@ -537,13 +539,21 @@ }, "protection_profiles": { "type": [ - "array", + "object", "null" ], - "items": { - "type": "string" - }, - "uniqueItems": true + "properties": { + "_type": { + "const": "Set" + }, + "elements": { + "type": "array", + "items": { + "$ref": "/schemas/base.json#/definitions/dgst" + }, + "uniqueItems": true + } + } } }, "additionalProperties": false, @@ -554,7 +564,7 @@ "type": "object" }, "protection_profile_links": { - "type": "object", + "type": ["object", "null"], "properties": { "_type": { "const": "Set" diff --git a/src/sec_certs/serialization/schemas/fips_certificate.json b/src/sec_certs/serialization/schemas/fips_certificate.json index 9356fd27..de38a455 100644 --- a/src/sec_certs/serialization/schemas/fips_certificate.json +++ b/src/sec_certs/serialization/schemas/fips_certificate.json @@ -17,6 +17,12 @@ "title": "Certificate ID", "description": "A non-negative integer representing the certificate ID." }, + "fips_str_id": { + "type": "string", + "pattern": "^[0-9]+$", + "title": "Certificate ID", + "description": "A non-negative integer representing the certificate ID, in string form." + }, "fips_references": { "type": "object", "properties": { @@ -24,47 +30,67 @@ "const": "sec_certs.sample.certificate.References" }, "directly_referenced_by": { - "type": [ - "array", - "null" - ], - "items": { - "$ref": "#/definitions/fips_id" + "type": ["object", "null"], + "properties": { + "_type": { + "const": "Set" + }, + "elements": { + "type": "array", + "items": { + "$ref": "#/definitions/fips_str_id" + }, + "uniqueItems": true + } }, - "uniqueItems": true, "description": "Certificates that directly reference this certificate." }, "indirectly_referenced_by": { - "type": [ - "array", - "null" - ], - "items": { - "$ref": "#/definitions/fips_id" + "type": ["object", "null"], + "properties": { + "_type": { + "const": "Set" + }, + "elements": { + "type": "array", + "items": { + "$ref": "#/definitions/fips_str_id" + }, + "uniqueItems": true + } }, - "uniqueItems": true, "description": "Certificates that indirectly reference this certificate." }, "directly_referencing": { - "type": [ - "array", - "null" - ], - "items": { - "$ref": "#/definitions/fips_id" + "type": ["object", "null"], + "properties": { + "_type": { + "const": "Set" + }, + "elements": { + "type": "array", + "items": { + "$ref": "#/definitions/fips_str_id" + }, + "uniqueItems": true + } }, - "uniqueItems": true, "description": "Certificates that are directly referenced by this certificate." }, "indirectly_referencing": { - "type": [ - "array", - "null" - ], - "items": { - "$ref": "#/definitions/fips_id" + "type": ["object", "null"], + "properties": { + "_type": { + "const": "Set" + }, + "elements": { + "type": "array", + "items": { + "$ref": "#/definitions/fips_str_id" + }, + "uniqueItems": true + } }, - "uniqueItems": true, "description": "Certificates that are indirectly referenced by this certificate." } } @@ -163,7 +189,7 @@ }, "level": { "type": [ - "string", + "integer", "null" ] }, @@ -175,9 +201,12 @@ }, "exceptions": { "type": [ - "string", + "array", "null" - ] + ], + "items": { + "type": "string" + } }, "embodiment": { "type": [ @@ -193,9 +222,12 @@ }, "tested_conf": { "type": [ - "string", + "array", "null" - ] + ], + "items": { + "type": "string" + } }, "hw_versions": { "type": [ @@ -216,10 +248,19 @@ ] }, "mentioned_certs": { - "type": [ - "string", - "null" - ] + "type": ["object", "null"], + "properties": { + "_type": { + "const": "Set" + }, + "elements": { + "type": "array", + "items": { + "$ref": "#/definitions/fips_str_id" + }, + "uniqueItems": true + } + } }, "historical_reason": { "type": [ @@ -306,7 +347,7 @@ "elements": { "type": "array", "items": { - "$ref": "#/definitions/fips_id" + "$ref": "#/definitions/fips_str_id" }, "uniqueItems": true } @@ -321,7 +362,7 @@ "elements": { "type": "array", "items": { - "$ref": "#/definitions/fips_id" + "$ref": "#/definitions/fips_str_id" }, "uniqueItems": true } -- cgit v1.3.1 From f2e934d0bed8a89dbb9e753de5cb13e98df2f74e Mon Sep 17 00:00:00 2001 From: J08nY Date: Fri, 26 Sep 2025 12:55:22 +0200 Subject: More descriptions for FIPS certificate schema. --- .../serialization/schemas/fips_certificate.json | 166 ++++++++++++++++----- 1 file changed, 127 insertions(+), 39 deletions(-) (limited to 'src') diff --git a/src/sec_certs/serialization/schemas/fips_certificate.json b/src/sec_certs/serialization/schemas/fips_certificate.json index de38a455..23005f3d 100644 --- a/src/sec_certs/serialization/schemas/fips_certificate.json +++ b/src/sec_certs/serialization/schemas/fips_certificate.json @@ -30,7 +30,10 @@ "const": "sec_certs.sample.certificate.References" }, "directly_referenced_by": { - "type": ["object", "null"], + "type": [ + "object", + "null" + ], "properties": { "_type": { "const": "Set" @@ -46,7 +49,10 @@ "description": "Certificates that directly reference this certificate." }, "indirectly_referenced_by": { - "type": ["object", "null"], + "type": [ + "object", + "null" + ], "properties": { "_type": { "const": "Set" @@ -62,7 +68,10 @@ "description": "Certificates that indirectly reference this certificate." }, "directly_referencing": { - "type": ["object", "null"], + "type": [ + "object", + "null" + ], "properties": { "_type": { "const": "Set" @@ -78,7 +87,10 @@ "description": "Certificates that are directly referenced by this certificate." }, "indirectly_referencing": { - "type": ["object", "null"], + "type": [ + "object", + "null" + ], "properties": { "_type": { "const": "Set" @@ -155,49 +167,82 @@ "type": [ "string", "null" - ] + ], + "format": "uri", + "title": "Vendor URL", + "description": "The URL of the vendor's website." }, "vendor": { "type": [ "string", "null" - ] + ], + "title": "Vendor Name", + "description": "The name of the vendor of the module." }, "certificate_pdf_url": { "type": [ "string", "null" - ] + ], + "format": "uri", + "title": "Certificate PDF URL", + "description": "The URL of the certificate PDF document." }, "module_type": { - "type": [ - "string", - "null" - ] + "anyOf": [ + { + "enum": [ + "Firmware", + "Firmware-Hybrid", + "Hardware", + "Software", + "Software-Hybrid", + "Hybrid" + ] + }, + { + "type": "null" + } + ], + "title": "Certified Module Type", + "description": "The type of the certified module." }, "standard": { - "type": [ - "string", - "null" - ] + "enum": [ + "FIPS 140-1", + "FIPS 140-2", + "FIPS 140-3" + ], + "title": "FIPS Standard", + "description": "The FIPS standard under which the module was certified." }, "status": { - "type": [ - "string", - "null" - ] + "enum": [ + "active", + "historical", + "revoked" + ], + "title": "Certificate Status", + "description": "The current status of the certificate." }, "level": { "type": [ "integer", "null" - ] + ], + "minimum": 1, + "maximum": 4, + "title": "Security Level", + "description": "The security level of the certified module (1 to 4)." }, "caveat": { "type": [ "string", "null" - ] + ], + "title": "Caveat", + "description": "Any caveats associated with the certification." }, "exceptions": { "type": [ @@ -206,19 +251,34 @@ ], "items": { "type": "string" - } + }, + "title": "Exceptions", + "description": "Any exceptions associated with the certification." }, "embodiment": { - "type": [ - "string", - "null" - ] + "anyOf": [ + { + "enum": [ + "Multi-Chip Stand Alone", + "Multi-Chip Embedded", + "Single Chip", + "*" + ] + }, + { + "type": "null" + } + ], + "title": "Embodiment", + "description": "The embodiment of the certified module." }, "description": { "type": [ "string", "null" - ] + ], + "title": "Module Description", + "description": "A brief description of the certified module." }, "tested_conf": { "type": [ @@ -227,28 +287,39 @@ ], "items": { "type": "string" - } + }, + "title": "Tested Configurations", + "description": "The tested configuration(s) of the certified module." }, "hw_versions": { "type": [ "string", "null" - ] + ], + "title": "Hardware Versions", + "description": "The hardware version(s) of the certified module." }, "fw_versions": { "type": [ "string", "null" - ] + ], + "title": "Firmware Versions", + "description": "The firmware version(s) of the certified module." }, "sw_versions": { "type": [ "string", "null" - ] + ], + "title": "Software Versions", + "description": "The software version(s) of the certified module." }, "mentioned_certs": { - "type": ["object", "null"], + "type": [ + "object", + "null" + ], "properties": { "_type": { "const": "Set" @@ -260,31 +331,43 @@ }, "uniqueItems": true } - } + }, + "title": "Mentioned Certificates", + "description": "Other FIPS certificates mentioned in the module page." }, "historical_reason": { "type": [ "string", "null" - ] + ], + "title": "Historical Reason", + "description": "The reason why the certificate is marked as historical (if any)." }, "date_sunset": { "type": [ "string", "null" - ] + ], + "format": "date", + "title": "Sunset Date", + "description": "The date when the certificate was sunsetted/revoked/archived (YYYY-MM-DD)." }, "revoked_reason": { "type": [ "string", "null" - ] + ], + "title": "Revocation Reason", + "description": "The reason why the certificate was revoked (if any)." }, "revoked_link": { "type": [ "string", "null" - ] + ], + "format": "uri", + "title": "Revocation Link", + "description": "A link to more information about the revocation (if any)." } } }, @@ -304,7 +387,9 @@ "title": "Security Policy Metadata", "description": "Metadata extracted from the security policy document." } - } + }, + "title": "Extracted PDF Data", + "description": "Data extracted from the certification PDF document (security policy)." }, "heuristics": { "type": "object", @@ -421,7 +506,10 @@ "pattern": "^[0-9a-fA-F]{64}$", "description": "SHA256 hash of the policy txt file." } - } + }, + "additionalProperties": false, + "title": "Certificate Document States", + "description": "State of the document processing pipeline for policy and module documents." } }, "additionalProperties": false -- cgit v1.3.1 From aed01539ed00d4173ba4e28e126a5dcff9bcee31 Mon Sep 17 00:00:00 2001 From: J08nY Date: Fri, 26 Sep 2025 13:24:16 +0200 Subject: Fix FIPS schema nulls. --- .../serialization/schemas/fips_certificate.json | 29 +++++++++------------- 1 file changed, 12 insertions(+), 17 deletions(-) (limited to 'src') diff --git a/src/sec_certs/serialization/schemas/fips_certificate.json b/src/sec_certs/serialization/schemas/fips_certificate.json index 23005f3d..0eeffa8b 100644 --- a/src/sec_certs/serialization/schemas/fips_certificate.json +++ b/src/sec_certs/serialization/schemas/fips_certificate.json @@ -190,21 +190,15 @@ "description": "The URL of the certificate PDF document." }, "module_type": { - "anyOf": [ - { - "enum": [ - "Firmware", - "Firmware-Hybrid", - "Hardware", - "Software", - "Software-Hybrid", - "Hybrid" - ] - }, - { - "type": "null" - } - ], + "enum": [ + "Firmware", + "Firmware-Hybrid", + "Hardware", + "Software", + "Software-Hybrid", + "Hybrid", + null + ] "title": "Certified Module Type", "description": "The type of the certified module." }, @@ -212,7 +206,8 @@ "enum": [ "FIPS 140-1", "FIPS 140-2", - "FIPS 140-3" + "FIPS 140-3", + null ], "title": "FIPS Standard", "description": "The FIPS standard under which the module was certified." @@ -513,4 +508,4 @@ } }, "additionalProperties": false -} \ No newline at end of file +} -- cgit v1.3.1 From ea6869d52a212db75661d9652fdf4f16bf7954d5 Mon Sep 17 00:00:00 2001 From: J08nY Date: Fri, 26 Sep 2025 13:31:58 +0200 Subject: Fix schema error. --- src/sec_certs/serialization/schemas/fips_certificate.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/sec_certs/serialization/schemas/fips_certificate.json b/src/sec_certs/serialization/schemas/fips_certificate.json index 0eeffa8b..71b4715a 100644 --- a/src/sec_certs/serialization/schemas/fips_certificate.json +++ b/src/sec_certs/serialization/schemas/fips_certificate.json @@ -198,7 +198,7 @@ "Software-Hybrid", "Hybrid", null - ] + ], "title": "Certified Module Type", "description": "The type of the certified module." }, -- cgit v1.3.1 From c67c8195837cff22f52443c24b1db5688026d657 Mon Sep 17 00:00:00 2001 From: J08nY Date: Fri, 26 Sep 2025 13:45:32 +0200 Subject: Fix FIPS schema status. --- src/sec_certs/serialization/schemas/fips_certificate.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/sec_certs/serialization/schemas/fips_certificate.json b/src/sec_certs/serialization/schemas/fips_certificate.json index 71b4715a..1159ffc4 100644 --- a/src/sec_certs/serialization/schemas/fips_certificate.json +++ b/src/sec_certs/serialization/schemas/fips_certificate.json @@ -216,7 +216,8 @@ "enum": [ "active", "historical", - "revoked" + "revoked", + null ], "title": "Certificate Status", "description": "The current status of the certificate." -- cgit v1.3.1 From d3453b01074a8bd1329f4feafb924939064311ad Mon Sep 17 00:00:00 2001 From: J08nY Date: Fri, 26 Sep 2025 15:07:53 +0200 Subject: Make schema refs relative. --- .../serialization/schemas/cc_certificate.json | 26 +++++++++++----------- .../serialization/schemas/cc_dataset.json | 4 ++-- .../serialization/schemas/fips_certificate.json | 16 ++++++------- .../serialization/schemas/fips_dataset.json | 4 ++-- 4 files changed, 25 insertions(+), 25 deletions(-) (limited to 'src') diff --git a/src/sec_certs/serialization/schemas/cc_certificate.json b/src/sec_certs/serialization/schemas/cc_certificate.json index 23556008..1bba5b6f 100644 --- a/src/sec_certs/serialization/schemas/cc_certificate.json +++ b/src/sec_certs/serialization/schemas/cc_certificate.json @@ -425,7 +425,7 @@ "description": "The security levels associated with the certificate." }, "dgst": { - "$ref": "/schemas/base.json#/definitions/dgst" + "$ref": "base.json#/definitions/dgst" }, "heuristics": { "type": "object", @@ -459,19 +459,19 @@ "description": "The lab/scheme that issued the certificate." }, "cpe_matches": { - "$ref": "/schemas/base.json#/definitions/cpe_matches" + "$ref": "base.json#/definitions/cpe_matches" }, "verified_cpe_matches": { - "$ref": "/schemas/base.json#/definitions/verified_cpe_matches" + "$ref": "base.json#/definitions/verified_cpe_matches" }, "related_cves": { - "$ref": "/schemas/base.json#/definitions/related_cves" + "$ref": "base.json#/definitions/related_cves" }, "direct_transitive_cves": { - "$ref": "/schemas/base.json#/definitions/direct_transitive_cves" + "$ref": "base.json#/definitions/direct_transitive_cves" }, "indirect_transitive_cves": { - "$ref": "/schemas/base.json#/definitions/indirect_transitive_cves" + "$ref": "base.json#/definitions/indirect_transitive_cves" }, "extracted_sars": { "type": [ @@ -494,7 +494,7 @@ "description": "Security Assurance Requirements (SARs) extracted from the certification documents." }, "extracted_versions": { - "$ref": "/schemas/base.json#/definitions/extracted_versions" + "$ref": "base.json#/definitions/extracted_versions" }, "prev_certificates": { "type": [ @@ -549,7 +549,7 @@ "elements": { "type": "array", "items": { - "$ref": "/schemas/base.json#/definitions/dgst" + "$ref": "base.json#/definitions/dgst" }, "uniqueItems": true } @@ -586,22 +586,22 @@ "const": "sec_certs.sample.cc.CCCertificate.PdfData" }, "report_metadata": { - "$ref": "/schemas/base.json#/definitions/document_metadata", + "$ref": "base.json#/definitions/document_metadata", "title": "Report Metadata", "description": "Metadata extracted from the certification report PDF document file." }, "st_metadata": { - "$ref": "/schemas/base.json#/definitions/document_metadata", + "$ref": "base.json#/definitions/document_metadata", "title": "ST Metadata", "description": "Metadata extracted from the security target PDF document file." }, "report_keywords": { - "$ref": "/schemas/base.json#/definitions/document_keywords", + "$ref": "base.json#/definitions/document_keywords", "title": "Report Keywords", "description": "Keywords extracted from the certification report document." }, "st_keywords": { - "$ref": "/schemas/base.json#/definitions/document_keywords", + "$ref": "base.json#/definitions/document_keywords", "title": "ST Keywords", "description": "Keywords extracted from the security target document." } @@ -631,4 +631,4 @@ } }, "additionalProperties": false -} \ No newline at end of file +} diff --git a/src/sec_certs/serialization/schemas/cc_dataset.json b/src/sec_certs/serialization/schemas/cc_dataset.json index 3e57b349..1544c619 100644 --- a/src/sec_certs/serialization/schemas/cc_dataset.json +++ b/src/sec_certs/serialization/schemas/cc_dataset.json @@ -53,10 +53,10 @@ "certs": { "type": "array", "items": { - "$ref": "/schemas/cc_certificate.json#" + "$ref": "cc_certificate.json#" }, "title": "List of certificates in the dataset" } }, "additionalProperties": false -} \ No newline at end of file +} diff --git a/src/sec_certs/serialization/schemas/fips_certificate.json b/src/sec_certs/serialization/schemas/fips_certificate.json index 1159ffc4..e9961262 100644 --- a/src/sec_certs/serialization/schemas/fips_certificate.json +++ b/src/sec_certs/serialization/schemas/fips_certificate.json @@ -374,12 +374,12 @@ "const": "sec_certs.sample.fips.FIPSCertificate.PdfData" }, "keywords": { - "$ref": "/schemas/base.json#/definitions/document_keywords", + "$ref": "base.json#/definitions/document_keywords", "title": "Security Policy Keywords", "description": "Keywords extracted from the security policy document." }, "policy_metadata": { - "$ref": "/schemas/base.json#/definitions/document_metadata", + "$ref": "base.json#/definitions/document_metadata", "title": "Security Policy Metadata", "description": "Metadata extracted from the security policy document." } @@ -408,16 +408,16 @@ } }, "extracted_versions": { - "$ref": "/schemas/base.json#/definitions/extracted_versions" + "$ref": "base.json#/definitions/extracted_versions" }, "cpe_matches": { - "$ref": "/schemas/base.json#/definitions/cpe_matches" + "$ref": "base.json#/definitions/cpe_matches" }, "verified_cpe_matches": { - "$ref": "/schemas/base.json#/definitions/verified_cpe_matches" + "$ref": "base.json#/definitions/verified_cpe_matches" }, "related_cves": { - "$ref": "/schemas/base.json#/definitions/related_cves" + "$ref": "base.json#/definitions/related_cves" }, "policy_prunned_references": { "type": "object", @@ -458,10 +458,10 @@ "description": "References to and from other certificates, based on the module page." }, "direct_transitive_cves": { - "$ref": "/schemas/base.json#/definitions/direct_transitive_cves" + "$ref": "base.json#/definitions/direct_transitive_cves" }, "indirect_transitive_cves": { - "$ref": "/schemas/base.json#/definitions/indirect_transitive_cves" + "$ref": "base.json#/definitions/indirect_transitive_cves" } }, "additionalProperties": false, diff --git a/src/sec_certs/serialization/schemas/fips_dataset.json b/src/sec_certs/serialization/schemas/fips_dataset.json index c488bce6..f9a5caa6 100644 --- a/src/sec_certs/serialization/schemas/fips_dataset.json +++ b/src/sec_certs/serialization/schemas/fips_dataset.json @@ -53,10 +53,10 @@ "certs": { "type": "array", "items": { - "$ref": "/schemas/fips_certificate.json#" + "$ref": "fips_certificate.json#" }, "title": "List of certificates in the dataset" } }, "additionalProperties": false -} \ No newline at end of file +} -- cgit v1.3.1