Skip to content

Commit 3185899

Browse files
authored
Merge pull request #5 from blackducksoftware/dev-worklaptop
v1.0.6
2 parents 3a62dd6 + fb47f7a commit 3185899

File tree

5 files changed

+23
-12
lines changed

5 files changed

+23
-12
lines changed

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Synopsys Scan Yocto Script - bd_scan_yocto_via_sbom.py v1.0.5
1+
# Synopsys Scan Yocto Script - bd_scan_yocto_via_sbom.py v1.0.6
22

33
# PROVISION OF THIS SCRIPT
44
This script is provided under the MIT license (see LICENSE file).
@@ -135,6 +135,8 @@ There are several additional options to modify the behaviour of this utility inc
135135
Additional Synopsys Detect options
136136
--api_timeout Specify API timeout in seconds (default 60) - will be used in
137137
Synopsys Detect as --detect.timeout
138+
--sbom_create_custom_components
139+
Create custom components when uploading SBOM (default False)
138140
--debug Debug logging mode
139141
--logfile LOGFILE Logging output file
140142

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
44

55
[project]
66
name = "bd_scan_yocto_via_sbom"
7-
version = "1.0.5"
7+
version = "1.0.6"
88
authors = [
99
{ name="Matthew Brady", email="[email protected]" },
1010
]

yocto_import_sbom/BBClass.py

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ def process_bitbake_env(self, conf):
135135
@staticmethod
136136
def run_cmd(command):
137137
try:
138-
ret = subprocess.run(command, capture_output=True, text=True, timeout=20)
138+
ret = subprocess.run(command, capture_output=True, text=True, timeout=60)
139139
if ret.returncode != 0:
140140
logging.error(f"Run command '{command}' failed with error {ret.returncode} - {ret.stderr}")
141141
return False, ''
@@ -240,13 +240,15 @@ def check_files(conf):
240240
conf.license_manifest = manifest
241241

242242
imgdir = os.path.join(conf.deploy_dir, "images", machine)
243-
cvefile = ""
244-
245-
if os.path.isdir(imgdir):
246-
for file in sorted(os.listdir(imgdir)):
247-
if file == conf.target + "-" + machine + ".cve":
248-
cvefile = os.path.join(imgdir, file)
249-
break
243+
if conf.cve_check_file != "":
244+
cvefile = conf.cve_check_file
245+
else:
246+
cvefile = ""
247+
if os.path.isdir(imgdir):
248+
for file in sorted(os.listdir(imgdir)):
249+
if file == conf.target + "-" + machine + ".cve":
250+
cvefile = os.path.join(imgdir, file)
251+
break
250252

251253
if not os.path.isfile(cvefile):
252254
logging.warning(f"CVE check file {cvefile} could not be located - skipping CVE processing")

yocto_import_sbom/BOMClass.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,8 @@ def upload_sbom(conf, bom, sbom):
174174
files = {'file': (sbom.file, open(sbom.file, 'rb'), 'application/spdx')}
175175
multipart_form_data = {
176176
'projectName': conf.bd_project,
177-
'versionName': conf.bd_version
177+
'versionName': conf.bd_version,
178+
'autocreate': conf.sbom_custom_components
178179
}
179180
# headers['Content-Type'] = 'multipart/form-data; boundary=6o2knFse3p53ty9dmcQvWAIx1zInP11uCfbm'
180181
response = requests.post(url, headers=headers, files=files, data=multipart_form_data,

yocto_import_sbom/ConfigClass.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,9 @@ def __init__(self):
7676
parser.add_argument("--detect_opts", help="OPTIONAL Additional Synopsys Detect options", default="")
7777
parser.add_argument("--api_timeout", help="OPTIONAL API and Detect timeout in seconds (default 60)",
7878
default="60")
79+
parser.add_argument("--sbom_create_custom_components",
80+
help="Create custom components for unmatched components on SBOM upload",
81+
action='store_true')
7982

8083
parser.add_argument("--debug", help="Debug logging mode", action='store_true')
8184
parser.add_argument("--logfile", help="Logging output file", default="")
@@ -110,6 +113,7 @@ def __init__(self):
110113
self.detect_jar = ''
111114
self.detect_opts = args.detect_opts
112115
self.api_timeout = args.api_timeout
116+
self.sbom_custom_components = args.sbom_create_custom_components
113117

114118
terminate = False
115119
if args.debug:
@@ -214,7 +218,9 @@ def __init__(self):
214218
terminate = True
215219
self.max_oe_version_distance = distarr
216220

217-
self.oe_data_folder = args.oe_data_folder
221+
if not os.path.isdir(self.oe_data_folder):
222+
logging.error(f"OE_data_folder {self.oe_data_folder} does not exist")
223+
terminate = True
218224

219225
if args.package_dir:
220226
if not os.path.exists(args.package_dir):

0 commit comments

Comments
 (0)