Пример #1
0
 def _get_root(self, result_file):
     '''
     Returns an ET object for the input XML which can be a file
     or a URL pointing to an xml file
     '''
     if result_file.startswith("http://"):
         split_url = urlparse.urlsplit(result_file)
         image_scanner = Client(split_url.hostname, port=split_url.port)
         result_tree = image_scanner.getxml(result_file)
     else:
         result_tree = ET.parse(result_file)
     return result_tree.getroot()
Пример #2
0
    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
Пример #3
0
from image_scanner_client import Client
from xml_parse import ParseOvalXML
import json

debug = True


def debug_print(json_data):
    ''' Simple helper function to pretty-print JSON data '''
    print json.dumps(json_data, indent=4, separators=(',', ': '))

xmlp = ParseOvalXML()

# Create the connection to the host
image_scanner = Client("localhost", "5001", "4")

# 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.