Skip to content

Commit 4b7358f

Browse files
committed
.
1 parent 354c0ee commit 4b7358f

File tree

1 file changed

+18
-29
lines changed

1 file changed

+18
-29
lines changed

examples/client/multi-image/scan_docker_image_lite.py

Lines changed: 18 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
55
Alternative version if Docker image layer by layer scan.
66
7-
This program will download docker image and scan it into Blackduck server layer by layer
7+
This program will download docker image and scan it into Black Duck server layer by layer
88
Each layer will be scanned as a separate scan with a signature scan.
99
1010
Layers in the container images could be grouped into groups of contiguous layers.
@@ -49,16 +49,16 @@
4949
5050
optional arguments:
5151
-h, --help show this help message and exit
52-
--grouping GROUPING Group layers into user defined provect versions (can't be used with --base-image)
52+
--grouping GROUPING Group layers into user defined project versions (can't be used with --base-image)
5353
--base-image BASE_IMAGE
5454
Use base image spec to determine base image/layers (can't be used with --grouping or
5555
--dockerfile)
5656
--dockerfile DOCKERFILE
5757
Use Dockerfile to determine base image/layers (can't be used with --grouping or ---base-image)
5858
--project-name Specify project name (default is container image spec)
59-
--project-verson Specify project version (default is container image tag/version)
59+
--project-version Specify project version (default is container image tag/version)
6060
--detect-options DETECT_OPTIONS
61-
Extra detect options to be passed directlyto the detect
61+
Extra detect options to be passed directly to the detect
6262
6363
6464
Using --detect-options
@@ -187,13 +187,23 @@ def read_config(self):
187187
with open(configFile) as fp:
188188
data = json.load(fp)
189189
return data
190+
191+
def read_oci_layout(self):
192+
oci_layout_file = self.imagedir + "/" + 'oci-layout'
193+
if os.path.exists(oci_layout_file) and os.path.isfile(oci_layout_file):
194+
with open(oci_layout_file) as fp:
195+
data = json.load(fp)
196+
return data
197+
else:
198+
return None
190199

191200
class Detector():
192201
def __init__(self, hub):
193202
# self.detecturl = 'https://blackducksoftware.github.io/hub-detect/hub-detect.sh'
194203
# self.detecturl = 'https://detect.synopsys.com/detect.sh'
195204
# self.detecturl = 'https://detect.synopsys.com/detect7.sh'
196-
self.detecturl = 'https://detect.synopsys.com/detect8.sh'
205+
# self.detecturl = 'https://detect.synopsys.com/detect8.sh'
206+
self.detecturl = 'https://detect.synopsys.com/detect9.sh'
197207
self.baseurl = hub.config['baseurl']
198208
self.filename = '/tmp/hub-detect.sh'
199209
self.token=hub.config['api_token']
@@ -240,6 +250,7 @@ def __init__(
240250
if detect_options:
241251
self.extra_options = detect_options.split(" ")
242252
print ("<--{}-->".format(self.grouping))
253+
self.binary = False
243254

244255
def prepare_container_image(self):
245256
self.docker.initdir()
@@ -262,28 +273,6 @@ def prepare_container_image(self):
262273
if len(history_grouping) and self.grouping == '1024:everything':
263274
self.grouping = history_grouping
264275

265-
def prepare_container_image_old(self):
266-
self.docker.initdir()
267-
self.docker.pull_container_image(self.container_image_name)
268-
result = self.docker.get_container_image_history(self.container_image_name)
269-
history = result.stdout.splitlines()
270-
layer_count = 0
271-
history_grouping = ''
272-
for line in reversed(history):
273-
print (line)
274-
if not line.rstrip().endswith(b' 0B'):
275-
layer_count +=1
276-
match = re.search('echo (.+?)_group_end', str(line))
277-
if match:
278-
found = match.group(1)
279-
if len(history_grouping):
280-
history_grouping += ','
281-
history_grouping += str(layer_count) + ":" + found
282-
if len(history_grouping) and self.grouping == '1024:everything':
283-
self.grouping = history_grouping
284-
self.docker.save_container_image(self.container_image_name)
285-
self.docker.unravel_container()
286-
287276
def process_container_image_by_user_defined_groups(self):
288277
self.manifest = self.docker.read_manifest()
289278
print(self.manifest)
@@ -455,12 +444,12 @@ def main(argv=None):
455444

456445
parser = ArgumentParser()
457446
parser.add_argument('imagespec', help="Container image tag, e.g. repository/imagename:version")
458-
parser.add_argument('--grouping',default=None, type=str, help="Group layers into user defined provect versions (can't be used with --base-image)")
447+
parser.add_argument('--grouping',default=None, type=str, help="Group layers into user defined project versions (can't be used with --base-image)")
459448
parser.add_argument('--base-image',default=None, type=str, help="Use base image spec to determine base image/layers (can't be used with --grouping or --dockerfile)")
460449
parser.add_argument('--dockerfile',default=None, type=str, help="Use Dockerfile to determine base image/layers (can't be used with --grouping or ---base-image)")
461450
parser.add_argument('--project-name',default=None, type=str, help="Specify project name (default is container image spec)")
462451
parser.add_argument('--project-version',default=None, type=str, help="Specify project version (default is container image tag/version)")
463-
parser.add_argument('--detect-options',default=None, type=str, help="Extra detect options to be passed directlyto the detect")
452+
parser.add_argument('--detect-options',default=None, type=str, help="Extra detect options to be passed directly to the detect")
464453

465454
args = parser.parse_args()
466455

0 commit comments

Comments
 (0)