Skip to content

Commit 5b84522

Browse files
authored
Merge pull request #6 from blackducksoftware/dev-worklaptop
v1.0.7
2 parents 3185899 + 3cce147 commit 5b84522

File tree

5 files changed

+50
-28
lines changed

5 files changed

+50
-28
lines changed

README.md

Lines changed: 2 additions & 2 deletions
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.6
1+
# Synopsys Scan Yocto Script - bd_scan_yocto_via_sbom.py v1.0.7
22

33
# PROVISION OF THIS SCRIPT
44
This script is provided under the MIT license (see LICENSE file).
@@ -127,7 +127,7 @@ There are several additional options to modify the behaviour of this utility inc
127127
Package type used for installing packages (e.g. rpm,
128128
deb or ipx)
129129
--skip_sig_scan Do not Signature scan downloads and packages
130-
--scan_all_packages Signature scan all files (only recipes not matchedfrom
130+
--scan_all_packages Signature scan all packages (only recipes not matched from
131131
OE data are scanned by default)
132132
--detect_jar_path DETECT_JAR_PATH
133133
Synopsys Detect jar path

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.6"
7+
version = "1.0.7"
88
authors = [
99
{ name="Matthew Brady", email="[email protected]" },
1010
]

yocto_import_sbom/BBClass.py

Lines changed: 33 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ def process_bitbake_env(self, conf):
7676
for mline in lines:
7777
if re.search(
7878
"^(MANIFEST_FILE|DEPLOY_DIR|MACHINE_ARCH|DL_DIR|DEPLOY_DIR_RPM|"
79-
"DEPLOY_DIR_IPK|DEPLOY_DIR_DEB|IMAGE_PKGTYPE)=",
79+
"DEPLOY_DIR_IPK|DEPLOY_DIR_DEB|IMAGE_PKGTYPE|LICENSE_DIR)=",
8080
mline):
8181

8282
# if re.search('^TMPDIR=', mline):
@@ -98,6 +98,10 @@ def process_bitbake_env(self, conf):
9898
if not conf.download_dir:
9999
conf.download_dir = val
100100
logging.info(f"Bitbake Env: download_dir={conf.download_dir}")
101+
elif re.search('^LICENSE_DIR=', mline):
102+
if not conf.license_dir:
103+
conf.license_dir = val
104+
logging.info(f"Bitbake Env: license_dir={conf.license_dir}")
101105
elif not rpm_dir and re.search('^DEPLOY_DIR_RPM=', mline):
102106
rpm_dir = val
103107
logging.info(f"Bitbake Env: rpm_dir={rpm_dir}")
@@ -111,7 +115,7 @@ def process_bitbake_env(self, conf):
111115
conf.image_pkgtype = val
112116
logging.info(f"Bitbake Env: image_pkgtype={conf.image_pkgtype}")
113117

114-
if conf.package_dir:
118+
if not conf.package_dir:
115119
if conf.image_pkgtype == 'rpm' and rpm_dir:
116120
conf.package_dir = rpm_dir
117121
elif conf.image_pkgtype == 'ipk' and ipk_dir:
@@ -123,10 +127,12 @@ def process_bitbake_env(self, conf):
123127
temppath = os.path.join(conf.build_dir, 'tmp', 'deploy')
124128
if os.path.isdir(temppath):
125129
conf.deploy_dir = temppath
130+
126131
if not conf.download_dir:
127132
temppath = os.path.join(conf.build_dir, 'downloads')
128133
if os.path.isdir(temppath):
129134
conf.download_dir = temppath
135+
130136
if not conf.package_dir and conf.deploy_dir:
131137
temppath = os.path.join(conf.deploy_dir, conf.image_pkgtype)
132138
if os.path.isdir(temppath):
@@ -219,25 +225,32 @@ def check_files(conf):
219225
machine = conf.machine.replace('_', '-')
220226

221227
if not conf.license_manifest:
222-
if not conf.target or not conf.machine:
223-
logging.error("Manifest file not specified and it could not be determined as Target not specified or "
224-
"machine not identified from environment")
225-
return False
226-
else:
227-
manpath = os.path.join(conf.deploy_dir, "licenses",
228-
f"{conf.target}-{machine}-*", "license.manifest")
229-
manifest = ""
230-
manlist = glob.glob(manpath)
231-
if len(manlist) > 0:
232-
# Get most recent file
233-
manifest = manlist[-1]
234-
235-
if not os.path.isfile(manifest):
236-
logging.error(f"Manifest file '{manifest}' could not be located")
228+
if conf.license_dir:
229+
manpath = os.path.join(conf.license_dir,
230+
f"{conf.target}-{machine}", "license.manifest")
231+
if os.path.isfile(manpath):
232+
conf.license_manifest = manpath
233+
234+
if not conf.license_manifest:
235+
if not conf.target or not conf.machine:
236+
logging.error("Manifest file not specified and it could not be determined as Target not specified or "
237+
"machine not identified from environment")
237238
return False
238239
else:
239-
logging.info(f"Located license.manifest file {manifest}")
240-
conf.license_manifest = manifest
240+
manpath = os.path.join(conf.deploy_dir, "licenses",
241+
f"{conf.target}-{machine}-*", "license.manifest")
242+
manifest = ""
243+
manlist = glob.glob(manpath)
244+
if len(manlist) > 0:
245+
# Get most recent file
246+
manifest = manlist[-1]
247+
248+
if not os.path.isfile(manifest):
249+
logging.error(f"Manifest file '{manifest}' could not be located")
250+
return False
251+
else:
252+
logging.info(f"Located license.manifest file {manifest}")
253+
conf.license_manifest = manifest
241254

242255
imgdir = os.path.join(conf.deploy_dir, "images", machine)
243256
if conf.cve_check_file != "":
@@ -264,7 +277,7 @@ def get_pkg_files(conf):
264277
package_paths_list = glob.glob(pattern, recursive=True)
265278
package_files_list = []
266279
for path in package_paths_list:
267-
package_files_list.append(os.path.basename(path))
280+
package_files_list.append(path)
268281

269282
return package_files_list
270283

yocto_import_sbom/BOMClass.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ def process_cve_file(self, cve_file, reclist):
228228
self.CVEPatchedVulnList = patched_vulns
229229
return
230230

231-
def run_detect_sigscan(self, tdir, conf):
231+
def run_detect_sigscan(self, conf, tdir):
232232
import shutil
233233

234234
cmd = self.get_detect(conf)

yocto_import_sbom/ConfigClass.py

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ def __init__(self):
6969

7070
parser.add_argument("--skip_sig_scan", help="Do not Signature scan downloads and packages",
7171
action='store_true')
72-
parser.add_argument("--scan_all_files", help="Signature scan all files (only recipes not matched"
72+
parser.add_argument("--scan_all_packages", help="Signature scan all packages (only recipes not matched"
7373
"from OE data are scanned by default)",
7474
action='store_true')
7575
parser.add_argument("--detect_jar_path", help="OPTIONAL Synopsys Detect jar path", default="")
@@ -114,6 +114,8 @@ def __init__(self):
114114
self.detect_opts = args.detect_opts
115115
self.api_timeout = args.api_timeout
116116
self.sbom_custom_components = args.sbom_create_custom_components
117+
self.cve_check_dir = ''
118+
self.license_dir = ''
117119

118120
terminate = False
119121
if args.debug:
@@ -130,7 +132,7 @@ def __init__(self):
130132
else:
131133
logging.basicConfig(level=loglevel)
132134

133-
logging.info("Black Duck Yocto scan via SBOM utility")
135+
logging.info("Black Duck Yocto scan via SBOM utility - v1.0.7")
134136
logging.info("SUPPLIED ARGUMENTS:")
135137
for arg in vars(args):
136138
logging.info(f"--{arg}={getattr(args, arg)}")
@@ -229,10 +231,17 @@ def __init__(self):
229231
else:
230232
self.package_dir = args.package_dir
231233

234+
if args.download_dir:
235+
if not os.path.exists(args.download_dir):
236+
logging.error(f"Specified package dir '{args.download_dir}' does not exist")
237+
terminate = True
238+
else:
239+
self.download_dir = args.download_dir
240+
232241
if args.skip_sig_scan:
233242
self.skip_sig_scan = True
234-
if args.scan_all_files:
235-
self.scan_all_packages = True
243+
elif args.scan_all_packages:
244+
self.scan_all_packages = True
236245

237246
if args.detect_jar_path and not os.path.isfile(args.detect_jar_path):
238247
logging.error(f"Detect jar file {args.detect_jar_path} does not exist")

0 commit comments

Comments
 (0)