Пример #1
0
    def _check_docker_by_container_id(item):
        analyzer = Analyzer()
        # -- Evaluates the docker image
        evaluated_docker_image = analyzer.evaluate_image(None, item['container_id'])

        # -- Updates mongodb report
        InternalServer.get_mongodb_driver().update_docker_image_scan_result_to_history(item['_id'],
                                                                                       evaluated_docker_image)
Пример #2
0
    def _check_docker_by_container_id(item):
        analyzer = Analyzer()
        # -- Evaluates the docker image
        evaluated_docker_image = analyzer.evaluate_image(None, item['container_id'])

        # -- Updates mongodb report
        InternalServer.get_mongodb_driver().update_docker_image_scan_result_to_history(item['_id'],
                                                                                       evaluated_docker_image)
Пример #3
0
    def _check_docker_by_image_name(item):
        analyzer = Analyzer()
        # -- Evaluates the docker image
        evaluated_docker_image = analyzer.evaluate_image(item['image_name'], None)

        # -- Updates mongodb report
        InternalServer.get_mongodb_driver().update_docker_image_scan_result_to_history(item['_id'],
                                                                                       evaluated_docker_image)

        # -- Cleanup
        if item['pulled']:
            InternalServer.get_docker_driver().docker_remove_image(item['image_name'])
Пример #4
0
    def _check_docker_by_image_name(item):
        analyzer = Analyzer()
        # -- Evaluates the docker image
        evaluated_docker_image = analyzer.evaluate_image(item['image_name'], None)

        # -- Updates mongodb report
        InternalServer.get_mongodb_driver().update_docker_image_scan_result_to_history(item['_id'],
                                                                                       evaluated_docker_image)

        # -- Cleanup
        if item['pulled']:
            InternalServer.get_docker_driver().docker_remove_image(item['image_name'])
Пример #5
0
class Agent:

    # -- Public methods

    # Agent Constructor
    def __init__(self, dagda_server_url):
        super(Agent, self).__init__()
        self.dagda_server_url = dagda_server_url
        self.analyzer = Analyzer(dagda_server_url=dagda_server_url)

    def run_static_analysis(self, image_name=None, container_id=None):
        evaluated_docker_image = self.analyzer.evaluate_image(
            image_name=image_name, container_id=container_id)
        docker_image_name = evaluated_docker_image['image_name']
        r = requests.post(self.dagda_server_url + '/history/' +
                          docker_image_name,
                          data=json.dumps(evaluated_docker_image),
                          headers={'content-type': 'application/json'})
        # -- Print cmd output
        if r is not None and r.content:
            print(
                json.dumps(json.loads(r.content.decode('utf-8')),
                           sort_keys=True,
                           indent=4))