Esempio n. 1
0
    def test_send_results(self, mocked_print_data):
        mocked_print_data.return_value = ""

        data = {
            'scan_start_time': "1991-01-01T00:00:00Z",
            'scan_id': 'dd1794f2-544d-456b-a45a-a2bec53633b1',
            'tool_name': 'unit_tests',
            'target': 'target.py:0',
            'type': "test",
            'title': "test title",
            'severity': 1,
            'cvss': 2.0,
            'confidence': 1,
            'description': "test.description",
            'first_found': '',
            'false_positive': ''
        }

        self.config.pvc_location = self.raw_dtemp
        consumer = stdout_json.StdoutJsonConsumer(self.config)
        results, raw = consumer.load_results()

        consumer.send_results(results, raw)
        data['first_found'] = data['scan_start_time']
        data['false_positive'] = False
        mocked_print_data.assert_called_with(data)

        self.config.pvc_location = self.enriched_dtemp
        consumer = stdout_json.StdoutJsonConsumer(self.config)
        results, raw = consumer.load_results()

        consumer.send_results(results, raw)
        data['first_found'] = "1992-02-02T00:00:00Z"
        data['false_positive'] = True
        mocked_print_data.assert_called_with(data)
Esempio n. 2
0
    def test_load_results(self):
        self.config.pvc_location = self.enriched_dtemp
        consumer = stdout_json.StdoutJsonConsumer(self.config)
        _, raw = consumer.load_results()
        self.assertFalse(raw)

        self.config.pvc_location = self.raw_dtemp
        consumer = stdout_json.StdoutJsonConsumer(self.config)
        _, raw = consumer.load_results()
        self.assertTrue(raw)
Esempio n. 3
0
 def _create_consumer(self):
     return stdout_json.StdoutJsonConsumer(self.config)