示例#1
0
 def setUp(self):
     self.es = EsPlugin(ClairRequestsV1('http://localhost:6060'),
                        [{
                            'host': '172.18.8.10',
                            'port': 9200
                        }], 'hbx-confo_factssysinfo', 'factssysinfo')
     self.layer_name = "toto"
示例#2
0
    def read_plugins(self, plugin_section="Plugins"):
        """
        Read plugins

        :param plugin_section: plugins' section's name
        """
        plugins = self.read_section(plugin_section)
        clair_conf = self.read_section("General")
        if not clair_conf:
            raise ConfigurationError("Can't read Clair's configuration")

        # Read clair api class
        clair_api_version = clair_conf.pop("clair_api_version", 1)
        if clair_api_version == 3:
            clair = ClairRequestsV3(**clair_conf)
        else:
            clair = ClairRequestsV1(**clair_conf)

        result = {}
        for plugin, conf in plugins.items():
            try:
                self.logger.debug('Reading plugin %s', plugin)
                self.logger.debug('Configuration %s', conf)

                plugin_class = self._get_class(conf.pop('class'))
                result[plugin] = plugin_class(clair, **conf)
            except (ValueError, KeyError):
                self.logger.error("Can't read plugin %s", plugin)

        return result
示例#3
0
    def test_get_ancestry_statistics_with_whitelist(self, m):
        """
        Test get_ancestry_statistics
        """
        clair = ClairRequestsV1(
            self.clairURI, cve_whitelist=['CVE-2017-9445', 'CVE-2017-9217'])

        with open(os.path.join(self.fixtures_dir, "ubuntu_v1.json")) as f:
            m.get(self.clairURI + clair._CLAIR_ANALYZE_URI.format("ubuntu"),
                  status_code=200,
                  json=json.load(f))
        ancestry_stats = clair.get_ancestry_statistics("ubuntu")
        self.assertDictEqual(ancestry_stats, {'Medium': 1})
示例#4
0
 def setUp(self):
     self.clair = ClairRequestsV1(self.clairURI)
     self.fixtures_dir = os.path.join(
         os.path.dirname(os.path.realpath(__file__)), "fixtures/clair")
示例#5
0
 def setUp(self):
     self.docker = DockerPlugin(ClairRequestsV1('http://localhost:6060'))
示例#6
0
 def setUp(self):
     self.cf = HttpPlugin(ClairRequestsV1(self.clairURI), "cflinuxfs",
                          self.artifacURI, self.artifacVERIFY)