def _get_docker_state(self, docker_state_file): ''' Returns a JSON object provided the docker_state_file either as a URL or an XML file ''' if docker_state_file.startswith("http://"): split_url = urlparse.urlsplit(docker_state_file) image_scanner = Client(split_url.hostname, port=split_url.port) result_json = image_scanner.get_docker_json(docker_state_file) else: result_json = json.loads(open(docker_state_file).read()) self.local_reportdir = os.path.dirname(docker_state_file) return result_json
# Scan an image or container scan_results = image_scanner.scan_list(['bef54']) # The result of scan_list will return a JSON based structure # that has a very basic summary of the scan as well as # information you can use to get more granular information # about the scan results if debug: debug_print(scan_results) # To get more granular information on the results, grab the # resulting docker_state.json file from scan_results which is # also a JSON structure. docker_state = image_scanner.get_docker_json(scan_results['json_url']) if debug: debug_print(docker_state) # The docker_state is the core of source of information regarding # the results of the previous scan. We can now use various functions # inside the xmlp object to extract specific information # List of RPMS per scanned ID rpm_dict = xmlp.return_rpm_by_docker_obj(docker_state) if debug: debug_print(rpm_dict) # List of cve information per scanned ID