ntia_conformance_checker package¶
Subpackages¶
- ntia_conformance_checker.adapters package
- Submodules
- ntia_conformance_checker.adapters.adapter_interface module
SbomAdapterSbomAdapter.check_author()SbomAdapter.check_doc_version()SbomAdapter.check_timestamp()SbomAdapter.get_components_without_concluded_licenses()SbomAdapter.get_components_without_copyright_texts()SbomAdapter.get_components_without_identifiers()SbomAdapter.get_components_without_names()SbomAdapter.get_components_without_suppliers()SbomAdapter.get_components_without_versions()SbomAdapter.get_doc_spec_version()SbomAdapter.get_sbom_name()SbomAdapter.get_sbom_types()SbomAdapter.get_total_number_components()
is_blank_string()
- ntia_conformance_checker.adapters.null_adapter module
NullAdapterNullAdapter.check_author()NullAdapter.check_timestamp()NullAdapter.get_components_without_concluded_licenses()NullAdapter.get_components_without_copyright_texts()NullAdapter.get_components_without_identifiers()NullAdapter.get_components_without_names()NullAdapter.get_components_without_suppliers()NullAdapter.get_components_without_versions()NullAdapter.get_doc_spec_version()NullAdapter.get_sbom_name()NullAdapter.get_sbom_types()NullAdapter.get_total_number_components()
- ntia_conformance_checker.adapters.spdx2_adapter module
Spdx2AdapterSpdx2Adapter.check_author()Spdx2Adapter.check_timestamp()Spdx2Adapter.get_components_without_concluded_licenses()Spdx2Adapter.get_components_without_copyright_texts()Spdx2Adapter.get_components_without_identifiers()Spdx2Adapter.get_components_without_names()Spdx2Adapter.get_components_without_suppliers()Spdx2Adapter.get_components_without_versions()Spdx2Adapter.get_doc_spec_version()Spdx2Adapter.get_sbom_name()Spdx2Adapter.get_sbom_types()Spdx2Adapter.get_total_number_components()
- ntia_conformance_checker.adapters.spdx3_adapter module
Spdx3AdapterSpdx3Adapter.check_author()Spdx3Adapter.check_timestamp()Spdx3Adapter.get_components_without_concluded_licenses()Spdx3Adapter.get_components_without_copyright_texts()Spdx3Adapter.get_components_without_identifiers()Spdx3Adapter.get_components_without_names()Spdx3Adapter.get_components_without_suppliers()Spdx3Adapter.get_components_without_versions()Spdx3Adapter.get_doc_spec_version()Spdx3Adapter.get_sbom_name()Spdx3Adapter.get_sbom_types()Spdx3Adapter.get_total_number_components()
is_blank_license_expression()
- Module contents
NullAdapterNullAdapter.check_author()NullAdapter.check_timestamp()NullAdapter.get_components_without_concluded_licenses()NullAdapter.get_components_without_copyright_texts()NullAdapter.get_components_without_identifiers()NullAdapter.get_components_without_names()NullAdapter.get_components_without_suppliers()NullAdapter.get_components_without_versions()NullAdapter.get_doc_spec_version()NullAdapter.get_sbom_name()NullAdapter.get_sbom_types()NullAdapter.get_total_number_components()
SbomAdapterSbomAdapter.check_author()SbomAdapter.check_doc_version()SbomAdapter.check_timestamp()SbomAdapter.get_components_without_concluded_licenses()SbomAdapter.get_components_without_copyright_texts()SbomAdapter.get_components_without_identifiers()SbomAdapter.get_components_without_names()SbomAdapter.get_components_without_suppliers()SbomAdapter.get_components_without_versions()SbomAdapter.get_doc_spec_version()SbomAdapter.get_sbom_name()SbomAdapter.get_sbom_types()SbomAdapter.get_total_number_components()
Spdx2AdapterSpdx2Adapter.check_author()Spdx2Adapter.check_timestamp()Spdx2Adapter.get_components_without_concluded_licenses()Spdx2Adapter.get_components_without_copyright_texts()Spdx2Adapter.get_components_without_identifiers()Spdx2Adapter.get_components_without_names()Spdx2Adapter.get_components_without_suppliers()Spdx2Adapter.get_components_without_versions()Spdx2Adapter.get_doc_spec_version()Spdx2Adapter.get_sbom_name()Spdx2Adapter.get_sbom_types()Spdx2Adapter.get_total_number_components()
Spdx3AdapterSpdx3Adapter.check_author()Spdx3Adapter.check_timestamp()Spdx3Adapter.get_components_without_concluded_licenses()Spdx3Adapter.get_components_without_copyright_texts()Spdx3Adapter.get_components_without_identifiers()Spdx3Adapter.get_components_without_names()Spdx3Adapter.get_components_without_suppliers()Spdx3Adapter.get_components_without_versions()Spdx3Adapter.get_doc_spec_version()Spdx3Adapter.get_sbom_name()Spdx3Adapter.get_sbom_types()Spdx3Adapter.get_total_number_components()
- ntia_conformance_checker.probes package
Submodules¶
ntia_conformance_checker.base_checker module¶
Base checking functionality.
- class ntia_conformance_checker.base_checker.BaseChecker(file: str, validate: bool = True, compliance: str = '', sbom_spec: str = 'spdx2')[source]¶
Bases:
ABCBase class for all compliance/conformance checkers.
This base class contains methods for common tasks like file parsing and information extractions from the SBOM.
Any class inheriting from BaseChecker must implement its abstract methods, such as check_compliance and output_json.
- MIN_ELEMENTS: list[str] = []¶
- all_components_without_info: list[tuple[str, list[tuple[str, str]]]]¶
- check_dependency_relationships() bool[source]¶
Check if a reachable element declares a dependency relationship.
- compliance_standard: str = ''¶
- compliant: bool = False¶
- components_evaluated: bool = False¶
- components_without_concluded_licenses: list[tuple[str, str]]¶
- components_without_copyright_texts: list[tuple[str, str]]¶
- components_without_identifiers: list[tuple[str, str]]¶
- components_without_names: list[tuple[str, str]]¶
- components_without_suppliers: list[tuple[str, str]]¶
- components_without_versions: list[tuple[str, str]]¶
- property conformance_messages: list[ValidationMessage]¶
Conformance messages from compliance/conformance checks.
- dependency_relationships: bool = False¶
- doc: Document | spdx3.SHACLObjectSet | None = None¶
- doc_author: bool = False¶
- doc_timestamp: bool = False¶
- doc_version: bool = False¶
- file: str = ''¶
- get_components_without_concluded_licenses() list[tuple[str, str]][source]¶
Retrieve components missing a concluded license.
- Returns:
A list of tuples of the form (component_name, spdx_id). Consumers should extract the preferred value (name or SPDX ID) as needed.
- Return type:
list[tuple[str, str]]
- get_components_without_copyright_texts() list[tuple[str, str]][source]¶
Retrieve components missing a copyright text.
- Returns:
A list of tuples of the form (component_name, spdx_id). Consumers should extract the preferred value (name or SPDX ID) as needed.
- Return type:
list[tuple[str, str]]
- get_components_without_identifiers() list[tuple[str, str]][source]¶
Retrieve components missing unique identifiers (SPDX IDs).
- Returns:
A list of tuples of the form (component_name, spdx_id). Consumers should extract the preferred value (name or SPDX ID) as needed.
- Return type:
list[tuple[str, str]]
- get_components_without_names() list[tuple[str, str]][source]¶
Retrieve components missing a name.
- Returns:
A list of tuples of the form (component_name, spdx_id). Consumers should extract the preferred value (name or SPDX ID) as needed.
- Return type:
list[tuple[str, str]]
- get_components_without_suppliers() list[tuple[str, str]][source]¶
Retrieve components missing supplier information.
- Returns:
A list of tuples of the form (component_name, spdx_id). Consumers should extract the preferred value (name or SPDX ID) as needed.
- Return type:
list[tuple[str, str]]
- get_components_without_versions() list[tuple[str, str]][source]¶
Retrieve components missing version information.
- Returns:
A list of tuples of the form (component_name, spdx_id). Consumers should extract the preferred value (name or SPDX ID) as needed.
- Return type:
list[tuple[str, str]]
- get_sbom_types() list[str][source]¶
Get SBOM types (generation context) from the document.
CISA Framing Software Component Transparency (2024) listed “SBOM type” as one of baseline attributes, see Table 1 (p. 22) in: https://www.cisa.gov/resources-tools/resources/framing-software-component-transparency-2024
- get_total_number_components() int[source]¶
Retrieve total number of components.
- Returns:
The total number of components.
- Return type:
int
- property ntia_minimum_elements_compliant: bool¶
use
compliantinstead.- Type:
Deprecated
- output_html() str[source]¶
Create element-by-element result table in HTML.
- Returns:
The HTML representation of the results.
- Return type:
str
- output_json() dict[str, Any][source]¶
Create a JSON-serializable result dict.
Subclasses may override to provide custom fields.
- parse_file() Document | None[source]¶
Parse SPDX 2 SBOM document.
- Returns:
An SPDX 2 SBOM document if successful, otherwise None.
- Return type:
Document | None
- property parsing_error: list[str]¶
use
parsing_errorsinstead.- Type:
Deprecated
- property parsing_errors: list[str]¶
Parsing errors encountered during file parsing.
- print_components_missing_info() None[source]¶
Print information about components that are missing required details.
What is considered “missing” is determined by a compliance standard. Subclasses may override this method to provide custom behavior.
- Returns:
None
- print_table_output(verbose: bool = False) None[source]¶
Print element-by-element result table.
- Parameters:
verbose (bool) – If True, print detailed information.
- Returns:
None
- sbom_gen_context: list[str]¶
- sbom_name: str = ''¶
- sbom_spec: str = ''¶
- property validation_messages: list[ValidationMessage]¶
Validation messages from SPDX document validation.
ntia_conformance_checker.bsi_checker module¶
BSI Minimum Elements checking functionality.
- class ntia_conformance_checker.bsi_checker.BSIChecker(file: str, validate: bool = True, compliance: str = 'bsi', sbom_spec: str = 'spdx3')[source]¶
Bases:
BaseCheckerBSI Minimum Elements check according to BSI TR-03183-2 v2.1.0.
- MIN_ELEMENTS = ['creator', 'name', 'version', 'filename', 'distribution_licenses', 'sha512_hash', 'executable_property', 'archive_property', 'structured_property']¶
- check_dependency_completeness() bool[source]¶
Check if dependency enumerations clearly indicate their completeness.
- get_components_without_archive_prop() list[tuple[str, str]][source]¶
BSI Requirement: Omit ‘archive’ if non-archive. Since omission represents ‘False’, a static checker cannot fail a component for missing this tag. Always compliant.
- get_components_without_bom_references() list[tuple[str, str]][source]¶
Check if the component references another BOM. BSI Requirement: MAY be included (Optional Data Field).
- get_components_without_concluded_licenses() list[tuple[str, str]][source]¶
Overrides BaseChecker to enforce BSI document Table 9 and Section 6.1 rules: 1. Target MUST be simplelicensing_LicenseExpression. 2. Must use valid SPDX license expressions, Scancode, or custom LicenseRefs.
- get_components_without_creators() list[tuple[str, str]][source]¶
Check if each component creator has a valid email or URL.
- get_components_without_deployable_uris() list[tuple[str, str]][source]¶
Check if the component has a URI of the deployable form. BSI Requirement: MUST be included IF it exists (Additional Data Field).
- get_components_without_effective_licenses() list[tuple[str, str]][source]¶
Check if the effective licence is included. BSI Requirement: MAY be included (Optional Data Field).
- get_components_without_executable_prop() list[tuple[str, str]][source]¶
BSI Requirement: Omit ‘executable’ if non-executable. Since omission represents ‘False’, a static checker cannot fail a component for missing this tag. Always compliant.
- get_components_without_filenames() list[tuple[str, str]][source]¶
Check if each package has a linked software_File with a valid name.
- get_components_without_original_licenses() list[tuple[str, str]][source]¶
Check if original licences are included. BSI Requirement: MUST be included IF they exist (Additional Data Field).
- get_components_without_security_txt() list[tuple[str, str]][source]¶
Check if the component contains a URL to security.txt. BSI Requirement: MAY be included (Optional Data Field).
- get_components_without_sha512_hashes() list[tuple[str, str]][source]¶
Check if the deployable component has a SHA-512 hash.
- get_components_without_source_code_hashes() list[tuple[str, str]][source]¶
Check if the source code of the component has a SHA-512 hash. BSI Requirement: MAY be included (Optional Data Field).
- get_components_without_source_code_uris() list[tuple[str, str]][source]¶
Check if the component has a Source code URI. BSI Requirement: MUST be included IF it exists (Additional Data Field).
ntia_conformance_checker.cli_utils module¶
Utilities for CLI.
- ntia_conformance_checker.cli_utils.get_parsed_args() Namespace[source]¶
Parse command line arguments.
- ntia_conformance_checker.cli_utils.get_sbom_spec(file: str, sbom_spec: str) str[source]¶
Detect SBOM specification from file content.
- ntia_conformance_checker.cli_utils.get_spdx_version(file: str, sbom_spec: str = 'spdx2') tuple[int, int] | None[source]¶
Detect the SPDX version of the SBOM file.
XLS file format is not supported.
- Parameters:
file (str) – The name of the file to be checked.
sbom_spec (str) – The SBOM specification hint, the function will try to use the appropriate parser first.
- Returns:
- The SPDX major.minor version of the SBOM.
E.g. (2, 3) for version 2.3. Returns None if the version cannot be determined.
- Return type:
tuple[int, int] | None
- ntia_conformance_checker.cli_utils.print_output(sbom: BaseChecker, *, output_type: str, output_file: str | None, verbose: bool) None[source]¶
Print or save the output report.
A JSON report saved to a file is RFC 8785 canonical. A JSON report printed to stdout is indented, with keys sorted.
- Parameters:
sbom – The checker with results to report.
output_type – The report format, e.g.
jsonorhtml.output_file – The file to save the report to, or None to print it.
verbose – Whether to include more details in a printed report.
ntia_conformance_checker.constants module¶
Constants.
- class ntia_conformance_checker.constants.TraversalDirection(*values)[source]¶
Bases:
EnumHow traversal walks a relationship type, from parent to child.
ALONGwalks it as written, from source (SPDX 2spdxElementId, SPDX 3from) to target (relatedSpdxElement,to);AGAINSTwalks it from target to source. This is the checker’s choice, not a property of the type: e.g.generatesis not a reverse type.- AGAINST = 'against'¶
- ALONG = 'along'¶
ntia_conformance_checker.fsct_checker module¶
FSCT Common BOM checking functionality.
- class ntia_conformance_checker.fsct_checker.FSCT3Checker(file: str, validate: bool = True, compliance: str = 'fsct3-min', sbom_spec: str = 'spdx2')[source]¶
Bases:
BaseCheckerFSCTv3 checker.
A set of Baseline Attributes is defined in Section 2.2 of Framing Software Component Transparency: Establishing a Common Software Bill of Materials (SBOM) Third Edition.
There are three maturity levels (Minimum Expected, Recommended Practice, and Aspirational Goal) for content provided in Attribute entries.
This checker currently only checks for Minimum Expected maturity level.
- MIN_ELEMENTS = ['name', 'version', 'identifier', 'supplier', 'concluded_license', 'copyright_text']¶
ntia_conformance_checker.graph_utils module¶
Graph utilities for SPDX 2 and SPDX 3.
- class ntia_conformance_checker.graph_utils.GraphConnectivity(reachable_component_ids: set[str] = <factory>, floating_component_ids: set[str] = <factory>, unknown_pointer_edges: dict[str, list[str]]=<factory>, missing_element_ids: set[str] = <factory>, has_dependency_relationship: bool = False)[source]¶
Bases:
objectResult of a graph connectivity analysis.
- reachable_component_ids¶
Packages reachable from the roots.
- Type:
set[str]
- floating_component_ids¶
Packages not reachable from the roots.
- Type:
set[str]
- unknown_pointer_edges¶
Relationships with a missing end, as written: source ID to target IDs (see
_find_unknown_pointer_edges).- Type:
dict[str, list[str]]
- missing_element_ids¶
IDs of the missing elements, at either end of those relationships.
- Type:
set[str]
- has_dependency_relationship¶
Whether a reachable element declares a dependency relationship (see
_has_dependency_relationship).- Type:
bool
- floating_component_ids: set[str]¶
- has_dependency_relationship: bool = False¶
- property has_unknown_pointers: bool¶
Whether a root or a followed relationship links to a missing element.
- missing_element_ids: set[str]¶
- reachable_component_ids: set[str]¶
- unknown_pointer_edges: dict[str, list[str]]¶
- ntia_conformance_checker.graph_utils.analyze_graph(sbom_spec: str, parsed_data: Any, spdx3_doc: Any = None) GraphConnectivity[source]¶
Analyze graph connectivity to find reachable components and missing elements.
Connectivity is evaluated at the component (package) level because components represent the primary unit of software conformance in minimum elements standards.
- Returns:
- Reachable and floating components, links to
missing elements, the missing element IDs, and whether a dependency relationship is declared.
- Return type:
- ntia_conformance_checker.graph_utils.analyze_graph_connectivity(sbom_spec: str, parsed_data: Any, spdx3_doc: Any = None) tuple[set[str], set[str], dict[str, list[str]], bool][source]¶
Analyze graph connectivity to find reachable components and unknown pointers.
Kept for compatibility;
analyze_graphalso returns the missing element IDs.- Returns:
- (reachable_component_ids, floating_component_ids,
unknown_pointer_edges, has_unknown_pointers), where unknown_pointer_edges maps a source ID to target IDs, for relationships with a missing end, as written (see
_find_unknown_pointer_edges).
- Return type:
tuple
- ntia_conformance_checker.graph_utils.get_reachable_nodes(sbom_spec: str, parsed_data: Any, spdx3_doc: Any = None) tuple[set[str], dict[str, list[str]]][source]¶
Get all nodes connected to the root by using Breadth-First Search.
- Returns:
- (reachable_node_ids, traversal_edges), where
traversal_edges holds edges in traversal direction, from parent to child. A relationship walked against its written direction is an edge from its target to its source, such as SPDX 2
A CONTAINED_BY Bor SPDX 3A generates B(from B to A).
- Return type:
tuple
ntia_conformance_checker.main module¶
Entrypoint for CLI.
ntia_conformance_checker.model module¶
Shared data types for the declarative-rules engine.
Finding– one occurrence of a rule violation, format-agnostic. Probes yieldFindingobjects; the SARIF / JSON / text emitters convert them to their output shape.ELEMENT_IDS– the canonical, presence-oriented vocabulary used throughout YAML rules, probes, andBaseCheckeraccessors. Singular, spec-aligned names. Document-level and component-level checks use the same vocabulary because the rule concept is the same (the element must be present).
- ntia_conformance_checker.model.COMPONENT_ELEMENT_IDS: frozenset[str] = frozenset({'concluded_license', 'copyright_notice', 'cryptographic_hash', 'name', 'relationship', 'supplier', 'unique_identifier', 'version'})¶
Elements checked for presence on each component.
- ntia_conformance_checker.model.DOCUMENT_ELEMENT_IDS: frozenset[str] = frozenset({'author', 'dependency_relationship', 'primary_component', 'sbom_type', 'spec_version', 'timestamp'})¶
Elements checked for presence on the SBOM as a whole.
- class ntia_conformance_checker.model.Finding(*, component_id: str, component_name: str = '', note: str = '')[source]¶
Bases:
objectOne occurrence of a rule violation.
component_idis the SPDX-style identifier (e.g."SPDXRef-Pkg-foo") for component-level findings, or the literal string"document"for document-level findings.component_nameis the human-readable name when known (empty string for document-level findings or anonymous components).noteis an optional, finding-specific message that overrides the rule’s default warning text. Most probes leave it empty so the rule’sSpecRule.warningflows through to output.- component_id: str¶
- component_name: str = ''¶
- property is_document_level: bool¶
True if this finding is about the SBOM document, not a component.
- note: str = ''¶
ntia_conformance_checker.ntia_checker module¶
NTIA Minimum Elements checking functionality.
- class ntia_conformance_checker.ntia_checker.NTIAChecker(file: str, validate: bool = True, compliance: str = 'ntia', sbom_spec: str = 'spdx2')[source]¶
Bases:
BaseCheckerNTIA Minimum Elements check.
- MIN_ELEMENTS = ['name', 'version', 'identifier', 'supplier']¶
ntia_conformance_checker.registry module¶
Spec registry: the single source of truth for available standards.
Every rules/*.yaml file packaged with this library is discovered and
loaded once at import time, indexed by its spec id. This makes a spec’s
id the authoritative compliance identifier:
it is the string the user passes to
--comply/compliance=,it keys the dispatch in
SbomChecker,its
Spec.titleis the human-readable description shown in CLI help and report headers.
Adding a new standard is therefore just dropping a YAML file into the
rules/ directory – no new Python subclass, no factory edit, no
hardcoded id list to update. (A named convenience subclass such as
NTIAChecker is optional and only kept for backwards-compatible
imports.)
Convention: name each file after its spec id
(e.g. rules/ntia.yaml -> id: ntia; rules/fsct3.yaml -> id: fsct3).
Discovery keys on the in-file id, not the filename, so a mismatch is not a
hard error – but matching them keeps the directory navigable. A new edition
is a new spec with its own id (e.g. a future fsct4.yaml -> id: fsct4).
- ntia_conformance_checker.registry.descriptions() dict[str, str][source]¶
Map each spec
idto its human-readableSpec.title.
ntia_conformance_checker.report module¶
Report generation functionality.
Some of the code here was originally in the BaseChecker class.
- class ntia_conformance_checker.report.ReportContext(sbom_spec: str = '', compliance_standard: str = '', compliant: bool = False, requirement_results: list[tuple[str, bool]] | None = None, components_without_info: list[tuple[str, list[tuple[str, str]]]] | None = None, validation_messages: list[ValidationMessage] | None = None, conformance_messages: list[ValidationMessage] | None = None, parsing_errors: list[str] | None = None, unknown_pointer_edges: dict[str, list[str]] | None = None, missing_element_ids: set[str] | None = None, floating_component_ids: set[str] | None = None, components_evaluated: bool = True)[source]¶
Bases:
objectContext for generating conformance reports.
- compliance_standard: str = ''¶
- compliant: bool = False¶
- components_evaluated: bool = True¶
- components_without_info: list[tuple[str, list[tuple[str, str]]]] | None = None¶
- conformance_messages: list[ValidationMessage] | None = None¶
- floating_component_ids: set[str] | None = None¶
- missing_element_ids: set[str] | None = None¶
- parsing_errors: list[str] | None = None¶
- requirement_results: list[tuple[str, bool]] | None = None¶
- sbom_spec: str = ''¶
- unknown_pointer_edges: dict[str, list[str]] | None = None¶
- validation_messages: list[ValidationMessage] | None = None¶
- ntia_conformance_checker.report.get_validation_messages_html(validation_messages: list[ValidationMessage], verbose: bool = False) str[source]¶
Generates HTML for validation messages and context details.
- Parameters:
validation_messages (list[ValidationMessage]) – List of validation messages.
verbose (bool) – If True, include detailed validation context.
- Returns:
HTML representation of the validation messages.
- Return type:
str
- ntia_conformance_checker.report.get_validation_messages_json(validation_messages: list[ValidationMessage]) list[dict[str, str]][source]¶
Generates JSON-serializable list for validation messages and context details.
- Parameters:
validation_messages (list[ValidationMessage]) – List of validation messages.
- Returns:
JSON-serializable representation of the validation messages.
- Return type:
list[dict[str, str]]
- ntia_conformance_checker.report.get_validation_messages_text(validation_messages: list[ValidationMessage], verbose: bool = False) str[source]¶
Generates validation messages and optional context details.
- Parameters:
validation_messages (list[ValidationMessage]) – List of validation messages.
verbose (bool) – If True, include detailed validation context.
- Returns:
Plain-text representation of the validation messages.
- Return type:
str
- ntia_conformance_checker.report.print_validation_messages(validation_messages: list[ValidationMessage], verbose: bool = False) None[source]¶
Prints validation messages and optional context details.
- Parameters:
validation_messages (list[ValidationMessage]) – List of validation messages.
verbose (bool) – If True, include detailed validation context.
- Returns:
None
- ntia_conformance_checker.report.report_html(rc: ReportContext, verbose: bool = False) str[source]¶
Generates element-by-element result table in HTML.
- Parameters:
rc (ReportContext) – Information for generating the report.
verbose (bool) – If True, include detailed validation messages.
- Returns:
HTML representation of the results.
- Return type:
str
- ntia_conformance_checker.report.report_json(checker_instance: BaseChecker) dict[str, Any][source]¶
Build the JSON output dictionary.
Lists built from sets or unordered collections are sorted, so the same SBOM always gives the same output.
- Parameters:
checker_instance – The checker with results to report.
- Returns:
The report, with JSON types only.
- Return type:
dict[str, Any]
- ntia_conformance_checker.report.report_text(rc: ReportContext, verbose: bool = False) str[source]¶
Generates element-by-element result table in plain-text.
- Parameters:
rc (ReportContext) – Information for generating the report.
verbose (bool) – If True, include detailed validation messages.
- Returns:
Plain-text representation of the results.
- Return type:
str
ntia_conformance_checker.sbom_checker module¶
Main checking functionality.
- final class ntia_conformance_checker.sbom_checker.SbomChecker(file: str, validate: bool = True, compliance: str = 'ntia', sbom_spec: str = 'spdx2')[source]¶
Bases:
BaseCheckerSBOM checker factory - do not subclass this class.
Subclass BaseChecker instead to implement a new compliance checker.
Post-v3.0.2, SbomChecker acts like a factory that returns a subclass of BaseChecker based on the given “compliance” argument during instantiation.
Currently there are two compliance standards available:
“ntia” (default), returns an instance of NTIAChecker - NTIAChecker has the same behavior as the original SbomChecker
“fsct3-min”, returns an instance of FSCT3Checker - FSCT3Checker is a checker for FSCT 3rd Edition Baseline Attributes
If “compliance” is not recognized, SbomChecker raises a ValueError.
ntia_conformance_checker.spdx3_utils module¶
Helpers for SPDX 3.
- ntia_conformance_checker.spdx3_utils.SPDX3_INDIVIDUAL_ELEMENT_IRIS: frozenset[str] = frozenset({'https://spdx.org/rdf/3.0.1/terms/Core/NoAssertionElement', 'https://spdx.org/rdf/3.0.1/terms/Core/NoneElement', 'https://spdx.org/rdf/3.0.1/terms/Core/SpdxOrganization', 'https://spdx.org/rdf/3.0.1/terms/ExpandedLicensing/NoAssertionLicense', 'https://spdx.org/rdf/3.0.1/terms/ExpandedLicensing/NoneLicense'})¶
the none and no-assertion values above, and
SpdxOrganization.- Type:
SPDX 3.0.1 individuals a document may refer to without defining them
- ntia_conformance_checker.spdx3_utils.SPDX3_NONE_AND_NOASSERTION_IRIS: frozenset[str] = frozenset({'https://spdx.org/rdf/3.0.1/terms/Core/NoAssertionElement', 'https://spdx.org/rdf/3.0.1/terms/Core/NoneElement', 'https://spdx.org/rdf/3.0.1/terms/ExpandedLicensing/NoAssertionLicense', 'https://spdx.org/rdf/3.0.1/terms/ExpandedLicensing/NoneLicense'})¶
SPDX 3.0.1 individuals for no value or an unknown value, not an element: Core NoneElement (“a set of Elements with cardinality (number/count) of zero”), NoAssertionElement (“a set of Elements of unknown identify or cardinality (number)”), ExpandedLicensing NoneLicense (“no license is present”) and NoAssertionLicense (“no assertion can be made about its actual value”).
- ntia_conformance_checker.spdx3_utils.get_all_element_ids(object_set: SHACLObjectSet, reachable_ids: set[str] | None = None) set[str][source]¶
Retrieve spdxId for all SPDX 3 Element objects from an SHACLObjectSet.
- ntia_conformance_checker.spdx3_utils.get_all_package_ids(object_set: SHACLObjectSet, reachable_ids: set[str] | None = None) set[str][source]¶
Retrieve spdxId for all /Software/Package objects from an SHACLObjectSet.
- ntia_conformance_checker.spdx3_utils.get_all_packages(object_set: SHACLObjectSet) set[software_Package][source]¶
Retrieve all /Software/Package objects from an SHACLObjectSet.
This includes instances of software_Package and its subclasses, such as ai_AIPackage and dataset_DatasetPackage.
- ntia_conformance_checker.spdx3_utils.get_boms_from_spdx_document(spdx_doc: SpdxDocument | None) list[Bom][source]¶
Retrieve the BOMs that are rootElements of an SPDX 3 SpdxDocument.
- Parameters:
spdx_doc (spdx3.SpdxDocument | None) – The SPDX 3 SpdxDocument.
- Returns:
A list of BOMs if found, otherwise an empty list.
- Return type:
list[spdx3.Bom]
- ntia_conformance_checker.spdx3_utils.get_dependency_relationships_completeness(object_set: SHACLObjectSet) dict[str, list[str]][source]¶
Extract the completeness attribute for all dependency relationships (‘contains’, ‘dependsOn’) in the SPDX 3 document.
- Returns:
A dictionary mapping all relationship’s from_id to a list of all completeness attributes.
- Return type:
dict[str, list[str]]
- ntia_conformance_checker.spdx3_utils.get_distribution_artifacts_map(object_set: SHACLObjectSet) dict[str, list[software_File]][source]¶
Create a mapping of package spdxId to their linked software_File distribution artifacts.
- Returns:
A dictionary mapping package spdxId to a list of linked software_File objects.
- Return type:
dict[str, list[spdx3.software_File]]
- ntia_conformance_checker.spdx3_utils.get_packages_from_bom(bom: Bom | None) list[software_Package][source]¶
Retrieve the /Software/Packages that are rootElements of an SPDX 3 BOM.
- Parameters:
bom (spdx3.Bom | None) – The SPDX 3 Bom.
- Returns:
A list of packages if found, otherwise an empty list.
- Return type:
list[spdx3.software_Package]
- ntia_conformance_checker.spdx3_utils.get_spdx3_element_id(value: Any) str[source]¶
Return the SPDX ID of an SPDX 3 element, or of an element reference.
A reference to an element may be the element itself or its IRI as a string, as in
Relationship.from_andRelationship.to.- Parameters:
value – An SPDX 3 element, an IRI, or None.
- Returns:
The SPDX ID, or an empty string if there is none.
- Return type:
str
- ntia_conformance_checker.spdx3_utils.has_sha512_hash(file_obj: SHACLObject) bool[source]¶
Check if a software_File has a SHA-512 hash declared in its verifiedUsing property.
- ntia_conformance_checker.spdx3_utils.iter_objects_with_property(object_set: spdx3.SHACLObjectSet, typ: type[spdx3.SHACLObject] = <class 'spdx_python_model.bindings.v3_0_1.model.Artifact'>, property_name: str = 'spdxId', reachable_ids: set[str] | None = None) Iterator[tuple[str, str, Any]][source]¶
Yield (name, spdxId, property) for each SPDX 3 object.
Objects are yielded sorted by (name, spdxId), as SHACLObjectSet iteration order is not stable across runs.
- Parameters:
object_set (spdx3.SHACLObjectSet) – The SHACLObjectSet to iterate over.
typ (type[spdx3.SHACLObject]) – The type of SPDX3 object
property_name (str) – The property name to retrieve.
reachable_ids (set[str] | None) – A set of reachable SPDX IDs from root.
- Yields:
Iterator[tuple[str, str, Any]] – A tuple containing the name, SPDX ID, and the specified property of the object.
- ntia_conformance_checker.spdx3_utils.iter_relationships_by_type(object_set: spdx3.SHACLObjectSet, rel_type: str) Iterator[tuple[str, list[str]]][source]¶
Yield (from_id, to_ids_list) for each relationship of the specified relationship type.
- ntia_conformance_checker.spdx3_utils.parse_spdx3_file(file_path: str) tuple[SHACLObjectSet | None, list[str]][source]¶
Parse SPDX 3 SBOM document.
- Returns:
- A tuple containing the parsed
SHACLObjectSet (or None if parsing failed) and a list of parsing error strings.
- Return type:
tuple[spdx3.SHACLObjectSet | None, list[str]]
- ntia_conformance_checker.spdx3_utils.validate_spdx3_data(object_set: SHACLObjectSet) tuple[SpdxDocument | None, list[ValidationMessage]][source]¶
Validate an SHACLObjectSet if it contains a valid SpdxDocument.
The SPDX 3.0 specification states that “Any instance of serialization of SPDX data shall not contain more than one SpdxDocument element definition.”
See: https://spdx.github.io/spdx-spec/latest/model/Core/Classes/SpdxDocument/
- Parameters:
object_set (spdx3.SHACLObjectSet) – The SHACLObjectSet containing the SPDX 3 document.
- Returns:
An SpdxDocument if found, otherwise None. list[ValidationMessage]: A list of validation messages. Empty if no errors.
- Return type:
spdx3.SpdxDocument | None
ntia_conformance_checker.spec module¶
Generic per-element and per-standard specification for compliance checkers.
Defines three frozen dataclasses used as the single source of truth for every output format (text table, JSON, SARIF, future OSCAL):
SpecCategory– one category / cluster within a standard. Maps to a SARIF taxon in the per-spec category taxonomy and to an OSCALgroup.SpecRule– one minimum-element check. Holds rule identity, its location in the source spec (category + clause), the element under test, the human-facing meaning (element description, competency question, warning), maturity (which tier requires it), provision (how strong the requirement is), status, the probe that performs the check, and optional output mappings.Spec– a compliance standard’s full rule catalogue. Holds the standard id/title, general help URL (used as a fallback when a rule has no rule-specific URL), the categories and rules, and the taxonomy names.
Rule identifiers follow the SBOM-[SPEC]-[CATEGORY]-[NNN] convention
documented in RULES.md. SPEC is the uppercased Spec.id
(e.g. NTIA, FSCT3) – the edition is part of the id because each
edition is a distinct standard with its own requirements; CATEGORY is
SpecCategory.code (e.g. DF, COMP); NNN is
SpecRule.number zero-padded to three digits.
- ntia_conformance_checker.spec.DEFAULT_MATURITY_LEVELS: tuple[SpecMaturity, ...] = (SpecMaturity(level=0, id='required', title='Required', description='A minimum element that the SBOM must provide.'),)¶
Applied to any spec that does not declare its own
maturity_levels– a flat spec then has a single, named baseline level (required) instead of an anonymous one. Severity comes from each rule’s provision, not the tier.
- class ntia_conformance_checker.spec.ProbeRef(*, name: str, params: dict[str, ~typing.Any]=<factory>)[source]¶
Bases:
objectReference to a registered probe, with bound parameters.
Loaded from the
probe:block of a YAML rule. The engine resolvesnameagainstntia_conformance_checker.probes._registryand calls the probe withparamsas keyword arguments.- name: str¶
Probe name as registered with
probes.probe().
- params: dict[str, Any]¶
Keyword arguments passed to the probe; treat as read-only. Probe functions declare every accepted parameter explicitly, and the loader rejects params that do not fit the probe’s signature.
- ntia_conformance_checker.spec.Provision¶
ISO/IEC Directives provision type – the kind of provision a rule states, independent of its maturity. Determines severity and whether failure blocks conformance:
requirement->error, blocks compliance.recommendation->warning, advisory.permission->none, advisory (a permission cannot be violated by absence, so it never produces an actionable finding).
A single maturity level can mix all three.
alias of
Literal[‘requirement’, ‘recommendation’, ‘permission’]
- ntia_conformance_checker.spec.Severity¶
Unified severity scale, ordered
error > warning > note > none.Shared vocabulary for SARIF
result.level, a rule’s default severity, and the CLI log/verbosity threshold.noteis the informational band (logs and tool notifications); no rule provision maps to it.alias of
Literal[‘error’, ‘warning’, ‘note’, ‘none’]
- class ntia_conformance_checker.spec.Spec(*, id: str, title: str, uri: str = '', categories: tuple[~ntia_conformance_checker.spec.SpecCategory, ...]=<factory>, maturity_levels: tuple[~ntia_conformance_checker.spec.SpecMaturity, ...]=<factory>, rules: tuple[~ntia_conformance_checker.spec.SpecRule, ...]=<factory>, taxonomies: SpecTaxonomies = <factory>)[source]¶
Bases:
objectA compliance standard’s full rule catalogue.
Shared metadata at the standard level (general help URL, taxonomy names) lives here; per-rule overrides live on
SpecRule.- active_rules(target: int | None = None) tuple[SpecRule, ...][source]¶
Active rules in scope for an assessment
targetmaturity.Excludes TBD + catalogue-only. With
targetset, also excludes rules above the target (maturity > target) – they are out of scope and are neither evaluated nor reported.target is Nonekeeps every active rule (all tiers).
- blocking_rules(target: int | None = None) tuple[SpecRule, ...][source]¶
In-scope active rules whose failure breaks compliance.
Only
requirementprovisions are blocking;recommendation/permissionrules are still emitted as findings (warning / none) but are advisory – a present-but-implausible value, say, is reported without making the SBOM non-conformant. Honours the assessmenttargetthe same way asactive_rules().
- categories: tuple[SpecCategory, ...]¶
The standard’s categories / clusters. Each becomes a SARIF taxon in the category taxonomy.
- category(category_id: str) SpecCategory[source]¶
Look up a
SpecCategoryby id; raise KeyError if absent.
- emitted_rules() tuple[SpecRule, ...][source]¶
Rules that appear in the SARIF catalogue (everything except TBD).
Not maturity-filtered: the catalogue advertises the full rule surface of the spec regardless of the assessment target.
- id: str¶
Compliance-standard identifier, e.g.
"ntia"/"fsct3". Registry key, YAML filename, and the value emitted in SARIFrun.properties.complianceStandard. Its uppercase form is theSPECsegment of every rule id, so it must be a hyphen-free, uppercase-safe token (lowercase ASCII letters/digits, starting with a letter).
- maturity(level: int) SpecMaturity[source]¶
Look up a
SpecMaturityby its ordinal; KeyError if absent.
- maturity_levels: tuple[SpecMaturity, ...]¶
The standard’s maturity vocabulary, keyed by universal ordinal. Optional in YAML – a flat spec omits it and the loader substitutes
DEFAULT_MATURITY_LEVELS(a singlerequired/ level0/requiredbaseline). When declared it must include level0.
- maturity_ordinals() tuple[int, ...][source]¶
Declared maturity ordinals, ascending – the valid assessment targets.
- property max_maturity: int¶
Highest declared maturity ordinal (
0for a flat spec).
- oscal_control_id(rule: SpecRule) str[source]¶
Return the rule’s OSCAL control id (override or lowercased rule id).
- static report_name(rule: SpecRule) str[source]¶
PascalCase reporting name for
rule, derived from its slug.Used as the SARIF
reportingDescriptor.name(and any other output format wanting a whitespace-free, human-readable rule name). Derived – never stored – so it cannot drift fromSpecRule.slug; the two differ only in casing. E.g."ntia-component-supplier-missing"->"NtiaComponentSupplierMissing".
- rule_id(rule: SpecRule) str[source]¶
Compose the canonical
SBOM-[SPEC]-[CAT]-[NNN]rule id.The
SPECsegment isiduppercased.
- rule_uri(rule: SpecRule) str[source]¶
Rule’s source-spec clause URL if set, otherwise the standard URL.
- rules: tuple[SpecRule, ...]¶
The standard’s rule catalogue. Rules with
status == "tbd"are excluded from SARIF emission entirely; rules withstatus == "catalogue-only"appear in the catalogue but never as results.
- severity(rule: SpecRule) Literal['error', 'warning', 'note', 'none'][source]¶
The rule’s severity, from its provision (emitted as SARIF
level).
- taxonomies: SpecTaxonomies¶
The standard’s
SpecTaxonomies(category + clause names). Output-format agnostic; consumed by the SARIF emitter asToolComponent.nameand by a future OSCAL exporter.
- title: str¶
Human-readable standard name, e.g.
"2021 NTIA SBOM Minimum Elements".
- class ntia_conformance_checker.spec.SpecCategory(*, id: str, code: str, title: str, description: str = '')[source]¶
Bases:
objectA grouping within a
Spec(e.g. NTIA Data Fields, a G7 cluster).Renders as a SARIF taxon in the spec’s category taxonomy and as an OSCAL
groupin a future OSCAL exporter.- code: str¶
Uppercase short, hyphen-free token used as the
CATEGORYsegment of a rule id. Example:"DF"->SBOM-NTIA-DF-001.
- description: str = ''¶
Optional one-line category description for SARIF taxon
shortDescription.text.
- id: str¶
Lowercase kebab-case category id (SARIF taxon id / OSCAL group id). Example:
"data-fields"for NTIA §IV Data Fields. Referenced bySpecRule.spec_category.
- title: str¶
"Data Fields".- Type:
Human-readable category title. Example
- class ntia_conformance_checker.spec.SpecMaturity(*, level: int, id: str, title: str = '', description: str = '')[source]¶
Bases:
objectOne maturity level within a
Spec.Declaring maturity levels is optional – a flat spec with no tiers simply omits
Spec.maturity_levels, and the loader substitutesDEFAULT_MATURITY_LEVELS(a singlerequired/ level0/requiredbaseline) so every rule still has a named level.When a spec does declare levels,
levelis a universal ordinal –0is the baseline, higher numbers demand more depth / completeness. This ordering is shared across specs (level 0 = baseline everywhere), so it supports “is this rule within target level N?” and cross-spec comparison.The
idis a spec-defined machine slug for the level (FSCT v3:minimum/recommended/aspirational; NTIA:required); thetitleis its human label. Rules still reference the level by its integerlevel;idis for output and possible name-based selection.Maturity carries no severity – it only scopes which requirements apply at a target level. How bad a missing requirement is comes from the rule’s
SpecRule.provision, an orthogonal axis.- description: str = ''¶
Optional one-line description of the maturity level.
- id: str¶
Spec-specific machine slug for the level (e.g.
"minimum","required"). Lowercase, hyphen/underscore-friendly.
- level: int¶
Universal maturity ordinal (
0= baseline; higher = deeper).
- title: str = ''¶
Optional human-readable label (e.g.
"Minimum Expected").
- class ntia_conformance_checker.spec.SpecRule(*, number: int, slug: str, spec_category: str, spec_clause_number: str = '', spec_clause_name: str = '', spec_clause_uri: str = '', element_id: str = '', element_description: str = '', element_concept_uris: tuple[str, ...] = (), competency_question: str = '', warning: str = '', maturity: int = 0, provision: Literal['requirement', 'recommendation', 'permission'] = 'requirement', status: Literal['active', 'catalogue-only', 'tbd'] = 'active', probe: ProbeRef | None = None, oscal_control_id: str = '', json_group: str | None = None, json_key: str | None = None)[source]¶
Bases:
objectPer-element check specification, reusable across compliance checkers.
- competency_question: str = ''¶
The yes/no competency question the rule answers, used as the label in text/HTML report tables (e.g.
"All component suppliers provided?").
- element_concept_uris: tuple[str, ...] = ()¶
IRIs of this element’s concept in external vocabularies – the external-identifier counterpart to
element_id. Consumers may treat each entry asskos:exactMatch.
- element_description: str = ''¶
Short noun phrase naming the element (e.g.
"component supplier"). Used in per-finding result messages. For the canonical user-facing prose, seewarning.
- element_id: str = ''¶
Canonical element id from
ntia_conformance_checker.model.ELEMENT_IDS(e.g."name","supplier","timestamp"). Carries the semantic key that survives across specs – different specs may name the same underlying concept differently, but theelement_idmatches as long as the probe queries the same SBOM-model field.
- json_group: str | None = None¶
JSON output group / key prefix (e.g.
"aiPackages").Nonemeans the rule, if emitted, lives at the top level of the JSON output.
- json_key: str | None = None¶
JSON output key within
json_group.Nonemeans the rule is not emitted in JSON output.
- maturity: int = 0¶
Universal maturity ordinal this rule sits at – which tier requires it. Defaults to
0(the baseline). Must match one of the owningSpec’sSpecMaturity.levelvalues – for a flat spec that is the substitutedDEFAULT_MATURITY_LEVELS(just level0). Lets a spec carry several rules for the sameelement_idat increasing levels (each with its own deeper probe). Carries no severity.
- number: int¶
Sequence number within
(spec, category), in the order the spec lists the attribute. Zero-padded to three digits asNNNin the rule id.
- oscal_control_id: str = ''¶
Optional override for the future OSCAL
control-id. When empty, the OSCAL exporter is expected to lowercase the SARIF rule id.
- probe: ProbeRef | None = None¶
Probe to run for this rule.
Nonefor catalogue-only and TBD rules (they appear in the catalogue but no probe is invoked).
- provision: Literal['requirement', 'recommendation', 'permission'] = 'requirement'¶
ISO provision type – how bad it is when missing. Maps to severity (
requirement->error,recommendation->warning,permission->none) and decides whether failure blocks compliance (onlyrequirementdoes). Orthogonal tomaturity.
- slug: str¶
Human-readable rule slug, lowercase kebab-case, prefixed with the spec id to avoid cross-spec collisions.
Frames the finding (the rule’s failure condition), not the attribute – e.g.
"ntia-component-supplier-missing","fsct3-component-name-missing". Most rules are “…-missing” today, but the framing generalises ("fsct3-timestamp-not-iso-format").This is the single human-readable identifier for a rule: the PascalCase
Spec.report_name()(SARIFreportingDescriptor.nameetc.) is derived from it, so the two never drift – they differ only in casing to suit each output format’s convention.
- spec_category: str¶
Id of the
SpecCategorythis rule belongs to (matchesSpecCategory.id). Determines theCATEGORYsegment of the rule id (via the category’scode) and the category taxon the rule’srelationshipspoint at.
- spec_clause_name: str = ''¶
Human-readable clause title (e.g.
"License").
- spec_clause_number: str = ''¶
Literal clause / section designator from the source spec (e.g.
"IV"or"2.2.2.7"). Becomes the id of the rule’s clause taxon and – when paired withSpecTaxonomies.clause– a clause taxonomy entry.
- spec_clause_uri: str = ''¶
Deep link to the exact spec clause. When empty, consumers fall back to
Spec.uriviaSpec.rule_uri().
- status: Literal['active', 'catalogue-only', 'tbd'] = 'active'¶
Whether the rule is emitted in the catalogue / as results. See
Statusfor semantics.
- warning: str = ''¶
Canonical, single-sentence diagnostic prose for the rule, following the parallel pattern documented in
RULES.md:component-level:
"An SBOM component should have a {X}."document-level:
"An SBOM should {X}."
This string is the source of truth for the user-facing warning text. SARIF emits it as the rule’s
shortDescription.text; CLI / HTML / future localisers should consume it from here rather than re-inventing wording in code. Empty falls back to"{element_description.capitalize()} is missing.".
- class ntia_conformance_checker.spec.SpecTaxonomies(*, category: str = '', clause: str = '')[source]¶
Bases:
objectNames of a standard’s two taxonomies (output-format agnostic).
Each taxonomy groups the rules along one axis and is materialised per output format – a SARIF
ToolComponent(toolComponent.name) today, an OSCAL catalog/group id later. Despite the SARIF wording these names are not SARIF-specific, hence nosarif_prefix.- category: str = ''¶
Name of the category taxonomy (e.g.
"ntia-minimum-elements").Named for its taxa: each taxon is a
SpecCategory, and every rule has asupersetrelationship to its category taxon. Mind the level mismatch – the field names the taxonomy by what it contains (categories), but the taxonomy as a whole is the standard’s catalog, so the value is the catalog/standard identifier ("ntia-minimum-elements", not"ntia-categories") and doubles as the OSCAL catalog id; the categories within are the OSCAL groups.
- clause: str = ''¶
Name of the clause taxonomy (e.g.
"ntia-clauses").Also named for its taxa: each taxon id is a literal spec clause number from
SpecRule.spec_clause_number, and every rule has anequalrelationship to its clause taxon. Here name and taxa line up (both clause-flavoured), unlikecategory. Empty disables the clause taxonomy and the per-ruleequalrelationship.
- ntia_conformance_checker.spec.Status¶
Per-rule emission status.
active– rule appears in the SARIF rule catalogue and results are emitted when the check fails.catalogue-only– rule appears in the catalogue (consumers can show the full spec surface) but the checker never emits results for it; either the attribute is aspirational or the check is not yet implemented.tbd– identifier is reserved inRULES.mdonly. The rule is not added to the catalogue; it exists so that wiring up the check later does not require renumbering existing rules.
alias of
Literal[‘active’, ‘catalogue-only’, ‘tbd’]
ntia_conformance_checker.spec_loader module¶
YAML -> Spec loader for the declarative-rules engine.
Each spec lives in ntia_conformance_checker/rules/<spec>.yaml with
the schema:
spec:
id: ntia # machine id; uppercased -> SPEC segment
title: 2021 NTIA SBOM Minimum Elements
uri: https://...
taxonomies: # output-format-agnostic names
category: ntia-minimum-elements
clause: ntia-clauses
categories:
- id: data-fields
code: DF
title: Data Fields
description: ...
maturity_levels: # ordinal 0 = baseline (default)
- level: 0
id: required
title: Required
rules: # id SBOM-NTIA-DF-001 is derived
- number: 1
slug: ntia-component-supplier-missing # finding-framed; report_name derived
spec_category: data-fields
maturity: 0 # which tier; omitted -> 0
provision: requirement # severity; omitted -> requirement (error)
element_id: supplier
...
probe:
name: require_component_attribute
params: { attribute: supplier }
- exception ntia_conformance_checker.spec_loader.SpecLoadError[source]¶
Bases:
ValueErrorRaised when a YAML spec file is not valid YAML or does not match the expected schema.
- ntia_conformance_checker.spec_loader.load_spec(path: str | Path) Spec[source]¶
Load and validate a spec YAML file, returning a
Specinstance.- Raises:
FileNotFoundError –
pathdoes not exist.SpecLoadError – the file is syntactically valid YAML but does not match the expected schema (unknown keys, missing required fields, malformed probe reference, etc).
Module contents¶
Export functions for usage as library.
- class ntia_conformance_checker.BSIChecker(file: str, validate: bool = True, compliance: str = 'bsi', sbom_spec: str = 'spdx3')[source]¶
Bases:
BaseCheckerBSI Minimum Elements check according to BSI TR-03183-2 v2.1.0.
- MIN_ELEMENTS = ['creator', 'name', 'version', 'filename', 'distribution_licenses', 'sha512_hash', 'executable_property', 'archive_property', 'structured_property']¶
- check_dependency_completeness() bool[source]¶
Check if dependency enumerations clearly indicate their completeness.
- components_without_archive_prop: list[tuple[str, str]]¶
- components_without_bom_references: list[tuple[str, str]]¶
- components_without_creators: list[tuple[str, str]]¶
- components_without_deployable_uris: list[tuple[str, str]]¶
- components_without_effective_licenses: list[tuple[str, str]]¶
- components_without_executable_prop: list[tuple[str, str]]¶
- components_without_filenames: list[tuple[str, str]]¶
- components_without_original_licenses: list[tuple[str, str]]¶
- components_without_security_txt: list[tuple[str, str]]¶
- components_without_sha512_hashes: list[tuple[str, str]]¶
- components_without_source_code_hashes: list[tuple[str, str]]¶
- components_without_source_code_uris: list[tuple[str, str]]¶
- components_without_structured_prop: list[tuple[str, str]]¶
- components_without_unique_identifiers: list[tuple[str, str]]¶
- dependency_completeness: bool¶
- doc_creator: bool¶
- doc_uri: bool¶
- get_components_without_archive_prop() list[tuple[str, str]][source]¶
BSI Requirement: Omit ‘archive’ if non-archive. Since omission represents ‘False’, a static checker cannot fail a component for missing this tag. Always compliant.
- get_components_without_bom_references() list[tuple[str, str]][source]¶
Check if the component references another BOM. BSI Requirement: MAY be included (Optional Data Field).
- get_components_without_concluded_licenses() list[tuple[str, str]][source]¶
Overrides BaseChecker to enforce BSI document Table 9 and Section 6.1 rules: 1. Target MUST be simplelicensing_LicenseExpression. 2. Must use valid SPDX license expressions, Scancode, or custom LicenseRefs.
- get_components_without_creators() list[tuple[str, str]][source]¶
Check if each component creator has a valid email or URL.
- get_components_without_deployable_uris() list[tuple[str, str]][source]¶
Check if the component has a URI of the deployable form. BSI Requirement: MUST be included IF it exists (Additional Data Field).
- get_components_without_effective_licenses() list[tuple[str, str]][source]¶
Check if the effective licence is included. BSI Requirement: MAY be included (Optional Data Field).
- get_components_without_executable_prop() list[tuple[str, str]][source]¶
BSI Requirement: Omit ‘executable’ if non-executable. Since omission represents ‘False’, a static checker cannot fail a component for missing this tag. Always compliant.
- get_components_without_filenames() list[tuple[str, str]][source]¶
Check if each package has a linked software_File with a valid name.
- get_components_without_original_licenses() list[tuple[str, str]][source]¶
Check if original licences are included. BSI Requirement: MUST be included IF they exist (Additional Data Field).
- get_components_without_security_txt() list[tuple[str, str]][source]¶
Check if the component contains a URL to security.txt. BSI Requirement: MAY be included (Optional Data Field).
- get_components_without_sha512_hashes() list[tuple[str, str]][source]¶
Check if the deployable component has a SHA-512 hash.
- get_components_without_source_code_hashes() list[tuple[str, str]][source]¶
Check if the source code of the component has a SHA-512 hash. BSI Requirement: MAY be included (Optional Data Field).
- get_components_without_source_code_uris() list[tuple[str, str]][source]¶
Check if the component has a Source code URI. BSI Requirement: MUST be included IF it exists (Additional Data Field).
- class ntia_conformance_checker.BaseChecker(file: str, validate: bool = True, compliance: str = '', sbom_spec: str = 'spdx2')[source]¶
Bases:
ABCBase class for all compliance/conformance checkers.
This base class contains methods for common tasks like file parsing and information extractions from the SBOM.
Any class inheriting from BaseChecker must implement its abstract methods, such as check_compliance and output_json.
- MIN_ELEMENTS: list[str] = []¶
- adapter: SbomAdapter¶
- all_components_without_info: list[tuple[str, list[tuple[str, str]]]]¶
- check_dependency_relationships() bool[source]¶
Check if a reachable element declares a dependency relationship.
- compliance_standard: str = ''¶
- compliant: bool = False¶
- components_evaluated: bool = False¶
- components_without_concluded_licenses: list[tuple[str, str]]¶
- components_without_copyright_texts: list[tuple[str, str]]¶
- components_without_identifiers: list[tuple[str, str]]¶
- components_without_names: list[tuple[str, str]]¶
- components_without_suppliers: list[tuple[str, str]]¶
- components_without_versions: list[tuple[str, str]]¶
- property conformance_messages: list[ValidationMessage]¶
Conformance messages from compliance/conformance checks.
- dependency_relationships: bool = False¶
- doc: Document | spdx3.SHACLObjectSet | None = None¶
- doc_author: bool = False¶
- doc_timestamp: bool = False¶
- doc_version: bool = False¶
- file: str = ''¶
- get_components_without_concluded_licenses() list[tuple[str, str]][source]¶
Retrieve components missing a concluded license.
- Returns:
A list of tuples of the form (component_name, spdx_id). Consumers should extract the preferred value (name or SPDX ID) as needed.
- Return type:
list[tuple[str, str]]
- get_components_without_copyright_texts() list[tuple[str, str]][source]¶
Retrieve components missing a copyright text.
- Returns:
A list of tuples of the form (component_name, spdx_id). Consumers should extract the preferred value (name or SPDX ID) as needed.
- Return type:
list[tuple[str, str]]
- get_components_without_identifiers() list[tuple[str, str]][source]¶
Retrieve components missing unique identifiers (SPDX IDs).
- Returns:
A list of tuples of the form (component_name, spdx_id). Consumers should extract the preferred value (name or SPDX ID) as needed.
- Return type:
list[tuple[str, str]]
- get_components_without_names() list[tuple[str, str]][source]¶
Retrieve components missing a name.
- Returns:
A list of tuples of the form (component_name, spdx_id). Consumers should extract the preferred value (name or SPDX ID) as needed.
- Return type:
list[tuple[str, str]]
- get_components_without_suppliers() list[tuple[str, str]][source]¶
Retrieve components missing supplier information.
- Returns:
A list of tuples of the form (component_name, spdx_id). Consumers should extract the preferred value (name or SPDX ID) as needed.
- Return type:
list[tuple[str, str]]
- get_components_without_versions() list[tuple[str, str]][source]¶
Retrieve components missing version information.
- Returns:
A list of tuples of the form (component_name, spdx_id). Consumers should extract the preferred value (name or SPDX ID) as needed.
- Return type:
list[tuple[str, str]]
- get_sbom_types() list[str][source]¶
Get SBOM types (generation context) from the document.
CISA Framing Software Component Transparency (2024) listed “SBOM type” as one of baseline attributes, see Table 1 (p. 22) in: https://www.cisa.gov/resources-tools/resources/framing-software-component-transparency-2024
- get_total_number_components() int[source]¶
Retrieve total number of components.
- Returns:
The total number of components.
- Return type:
int
- property ntia_minimum_elements_compliant: bool¶
use
compliantinstead.- Type:
Deprecated
- output_html() str[source]¶
Create element-by-element result table in HTML.
- Returns:
The HTML representation of the results.
- Return type:
str
- output_json() dict[str, Any][source]¶
Create a JSON-serializable result dict.
Subclasses may override to provide custom fields.
- parse_file() Document | None[source]¶
Parse SPDX 2 SBOM document.
- Returns:
An SPDX 2 SBOM document if successful, otherwise None.
- Return type:
Document | None
- property parsing_error: list[str]¶
use
parsing_errorsinstead.- Type:
Deprecated
- property parsing_errors: list[str]¶
Parsing errors encountered during file parsing.
- print_components_missing_info() None[source]¶
Print information about components that are missing required details.
What is considered “missing” is determined by a compliance standard. Subclasses may override this method to provide custom behavior.
- Returns:
None
- print_table_output(verbose: bool = False) None[source]¶
Print element-by-element result table.
- Parameters:
verbose (bool) – If True, print detailed information.
- Returns:
None
- sbom_gen_context: list[str]¶
- sbom_name: str = ''¶
- sbom_spec: str = ''¶
- table_elements: list[tuple[str, bool]]¶
- property validation_messages: list[ValidationMessage]¶
Validation messages from SPDX document validation.
- class ntia_conformance_checker.FSCT3Checker(file: str, validate: bool = True, compliance: str = 'fsct3-min', sbom_spec: str = 'spdx2')[source]¶
Bases:
BaseCheckerFSCTv3 checker.
A set of Baseline Attributes is defined in Section 2.2 of Framing Software Component Transparency: Establishing a Common Software Bill of Materials (SBOM) Third Edition.
There are three maturity levels (Minimum Expected, Recommended Practice, and Aspirational Goal) for content provided in Attribute entries.
This checker currently only checks for Minimum Expected maturity level.
- MIN_ELEMENTS = ['name', 'version', 'identifier', 'supplier', 'concluded_license', 'copyright_text']¶
- class ntia_conformance_checker.NTIAChecker(file: str, validate: bool = True, compliance: str = 'ntia', sbom_spec: str = 'spdx2')[source]¶
Bases:
BaseCheckerNTIA Minimum Elements check.
- MIN_ELEMENTS = ['name', 'version', 'identifier', 'supplier']¶
- final class ntia_conformance_checker.SbomChecker(file: str, validate: bool = True, compliance: str = 'ntia', sbom_spec: str = 'spdx2')[source]¶
Bases:
BaseCheckerSBOM checker factory - do not subclass this class.
Subclass BaseChecker instead to implement a new compliance checker.
Post-v3.0.2, SbomChecker acts like a factory that returns a subclass of BaseChecker based on the given “compliance” argument during instantiation.
Currently there are two compliance standards available:
“ntia” (default), returns an instance of NTIAChecker - NTIAChecker has the same behavior as the original SbomChecker
“fsct3-min”, returns an instance of FSCT3Checker - FSCT3Checker is a checker for FSCT 3rd Edition Baseline Attributes
If “compliance” is not recognized, SbomChecker raises a ValueError.