Skip to content

Commit

Permalink
Fix black format
Browse files Browse the repository at this point in the history
Signed-off-by: Arthit Suriyawongkul <[email protected]>
  • Loading branch information
bact committed Nov 27, 2024
1 parent d3e7357 commit 8f97c53
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 45 deletions.
3 changes: 2 additions & 1 deletion ntia_conformance_checker/base_checker.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ def output_json(self) -> dict:
def output_html(self) -> str:
"""Abstract method to create a result in HTML format."""

def __init__(self, file, validate=True):
def __init__(self, file, validate=True, compliance=""):
"""
Initialize the BaseChecker.
Expand All @@ -81,6 +81,7 @@ def __init__(self, file, validate=True):
validate (bool): Whether to validate the file.
compliance (str): The compliance standard to be used. Defaults to "ntia".
"""
self.compliance_standard = compliance
self.parsing_error = []
self.validation_messages = ""

Expand Down
32 changes: 16 additions & 16 deletions ntia_conformance_checker/fsct_checker.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,11 @@ def output_json(self):
"""Create a dict of results for outputting to JSON."""
# instantiate dict and fields that have > 1 level
result = {}
result["parsingError"] = self.parsing_error
result["isConformant"] = self.compliant

if not self.parsing_error:
result["complianceStandard"] = self.compliance_standard
result["sbomName"] = self.sbom_name
result["componentNames"] = {}
result["componentVersions"] = {}
Expand All @@ -190,35 +194,31 @@ def output_json(self):
result["timestampProvided"] = self.doc_timestamp
result["dependencyRelationshipsProvided"] = self.dependency_relationships

result["componentNames"]["nonconformantComponents"] = (
self.components_without_names
)
result["componentNames"][
"nonconformantComponents"
] = self.components_without_names
result["componentNames"]["allProvided"] = not self.components_without_names
result["componentVersions"]["nonconformantComponents"] = (
self.components_without_versions
)
result["componentVersions"][
"nonconformantComponents"
] = self.components_without_versions
result["componentVersions"][
"allProvided"
] = not self.components_without_versions
result["componentIdentifiers"]["nonconformantComponents"] = (
self.components_without_identifiers
)
result["componentIdentifiers"][
"nonconformantComponents"
] = self.components_without_identifiers
result["componentIdentifiers"][
"allProvided"
] = not self.components_without_identifiers
result["componentSuppliers"]["nonconformantComponents"] = (
self.components_without_suppliers
)
result["componentSuppliers"][
"nonconformantComponents"
] = self.components_without_suppliers
result["componentSuppliers"][
"allProvided"
] = not self.components_without_suppliers
result["totalNumberComponents"] = self.get_total_number_components()
if self.validation_messages:
result["validationMessages"] = list(map(str, self.validation_messages))
else:
result["parsingError"] = self.parsing_error

result["isFsct3Conformant"] = self.compliant

return result

Expand Down
34 changes: 17 additions & 17 deletions ntia_conformance_checker/ntia_checker.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
class NTIAChecker(BaseChecker):
"""NTIA Minimum Elements check."""

def __init__(self, file, validate=True):
def __init__(self, file, validate=True, compliance="ntia"):
super().__init__(file=file, validate=validate)

if self.doc:
Expand Down Expand Up @@ -154,6 +154,10 @@ def output_json(self) -> dict:
"""Create a dict of results for outputting to JSON."""
# instantiate dict and fields that have > 1 level
result = {}
result["parsingError"] = self.parsing_error
result["isConformant"] = self.compliant
result["isNtiaConformant"] = self.compliant # for backward compatibility

if not self.parsing_error:
result["sbomName"] = self.sbom_name
result["componentNames"] = {}
Expand All @@ -165,35 +169,31 @@ def output_json(self) -> dict:
result["timestampProvided"] = self.doc_timestamp
result["dependencyRelationshipsProvided"] = self.dependency_relationships

result["componentNames"]["nonconformantComponents"] = (
self.components_without_names
)
result["componentNames"][
"nonconformantComponents"
] = self.components_without_names
result["componentNames"]["allProvided"] = not self.components_without_names
result["componentVersions"]["nonconformantComponents"] = (
self.components_without_versions
)
result["componentVersions"][
"nonconformantComponents"
] = self.components_without_versions
result["componentVersions"][
"allProvided"
] = not self.components_without_versions
result["componentIdentifiers"]["nonconformantComponents"] = (
self.components_without_identifiers
)
result["componentIdentifiers"][
"nonconformantComponents"
] = self.components_without_identifiers
result["componentIdentifiers"][
"allProvided"
] = not self.components_without_identifiers
result["componentSuppliers"]["nonconformantComponents"] = (
self.components_without_suppliers
)
result["componentSuppliers"][
"nonconformantComponents"
] = self.components_without_suppliers
result["componentSuppliers"][
"allProvided"
] = not self.components_without_suppliers
result["totalNumberComponents"] = self.get_total_number_components()
if self.validation_messages:
result["validationMessages"] = list(map(str, self.validation_messages))
else:
result["parsingError"] = self.parsing_error

result["isNtiaConformant"] = self.compliant

return result

Expand Down
25 changes: 14 additions & 11 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,16 @@ build-backend = "setuptools.build_meta"
name = "ntia_conformance_checker"
version = "3.0.2"
authors = [
{name = "Josh Lin", email = "[email protected]"},
{name = "John Speed Meyers", email = "[email protected]"}
{ name = "Josh Lin", email = "[email protected]" },
{ name = "John Speed Meyers", email = "[email protected]" },
]
maintainers = [
{name = "John Speed Meyers", email = "[email protected]"},
{name = "Gary O'Neall", email = "[email protected]"},
{name = "Josh Lin", email = "[email protected]"},
{name = "SPDX group at the Linux Foundation and others", email = "[email protected]"},
{ name = "John Speed Meyers", email = "[email protected]" },
{ name = "Gary O'Neall", email = "[email protected]" },
{ name = "Josh Lin", email = "[email protected]" },
{ name = "SPDX group at the Linux Foundation and others", email = "[email protected]" },
]
license = {text = "Apache-2.0"}
license = { text = "Apache-2.0" }
description = "Check SPDX SBOM for NTIA minimum elements and common SBOM baseline attributes"
readme = "README.md"
classifiers = [
Expand All @@ -28,8 +28,11 @@ classifiers = [
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3.13",
"Topic :: Security",
"Topic :: Software Development :: Libraries :: Python Modules",
"Topic :: System :: Systems Administration",
]
urls = {Homepage = "https://github.com/spdx/ntia-conformance-checker"}
urls = { Homepage = "https://github.com/spdx/ntia-conformance-checker" }
requires-python = ">=3.8"
keywords = [
"spdx",
Expand All @@ -49,13 +52,13 @@ dependencies = ["spdx-tools==0.8.3"]
[project.optional-dependencies]
test = ["pytest"]

[tool.setuptools]
packages = ["ntia_conformance_checker"]

[project.scripts]
# Both "ntia-checker" and "sbomcheck" are identical.
# "ntia-checker" is kept for backward compatibility.
# While "sbomcheck" is introduced for a more generic name,
# to accommodate other compliance standards.
ntia-checker = "ntia_conformance_checker.main:main"
sbomcheck = "ntia_conformance_checker.main:main"

[tool.setuptools]
packages = ["ntia_conformance_checker"]

0 comments on commit 8f97c53

Please sign in to comment.