Skip to content

Spdx3 support #12

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 12 additions & 6 deletions src/bin/merger_ci.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
from ..views.cyclonedx import CycloneDx
from ..views.spdx import SPDX
from ..views.fast_spdx import FastSPDX
from ..views.fast_spdx3 import FastSPDX3
from ..views.templates import Templates
from ..controllers.packages import PackagesController
from ..controllers.vulnerabilities import VulnerabilitiesController
Expand Down Expand Up @@ -155,6 +156,7 @@ def read_inputs(controllers):
timeEstimates = TimeEstimates(controllers)
cdx = CycloneDx(controllers)
spdx = SPDX(controllers)
fastspdx3 = FastSPDX3(controllers)
fastspdx = FastSPDX(controllers)
templates = Templates(controllers)

Expand Down Expand Up @@ -201,12 +203,16 @@ def read_inputs(controllers):
for file in glob.glob(f"{os.getenv('SPDX_FOLDER', SPDX_FOLDER)}/*.spdx.json"):
try:
verbose(f"merger_ci: Reading {file}")
if use_fastspdx:
with open(file, "r") as f:
fastspdx.parse_from_dict(json.loads(f.read()))
else:
spdx.load_from_file(file)
spdx.parse_and_merge()
with open(file, "r") as f:
data = json.load(f)

if fastspdx3.could_parse_spdx(data):
fastspdx3.parse_from_dict(data)
elif use_fastspdx:
fastspdx.parse_from_dict(data)
else:
spdx.load_from_file(file)
spdx.parse_and_merge()
except Exception as e:
if os.getenv('IGNORE_PARSING_ERRORS', 'false') != 'true':
print(f"Error parsing SPDX file: {file} {e}")
Expand Down
18 changes: 12 additions & 6 deletions src/bin/spdx_merge.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

from ..views.spdx import SPDX
from ..views.fast_spdx import FastSPDX
from ..views.fast_spdx3 import FastSPDX3
from ..controllers.packages import PackagesController
from ..controllers.vulnerabilities import VulnerabilitiesController
from ..controllers.assessments import AssessmentsController
Expand All @@ -30,16 +31,21 @@ def read_inputs(controllers):

spdx = SPDX(controllers)
fastspdx = FastSPDX(controllers)
fastspdx3 = FastSPDX3(controllers)

for file in glob.glob(f"{os.getenv('INPUT_SPDX_FOLDER', INPUT_SPDX_FOLDER)}/*.spdx.json"):
try:
verbose(f"spdx_merge: Merging {file}")
if use_fastspdx:
with open(file, "r") as f:
fastspdx.parse_from_dict(json.loads(f.read()))
else:
spdx.load_from_file(file)
spdx.parse_and_merge()
with open(file, "r") as f:
data = json.load(f)

if fastspdx3.could_parse_spdx(data):
fastspdx3.parse_controllers_from_dict(data)
elif use_fastspdx:
fastspdx.parse_from_dict(data)
else:
spdx.load_from_file(file)
spdx.parse_and_merge()
except Exception as e:
if os.getenv('IGNORE_PARSING_ERRORS', 'false') != 'true':
print(f"Error parsing SPDX file: {file} {e}")
Expand Down
Loading