Esempio n. 1
0
class Command(BaseCommand):
    help = 'Veracode -> SDE import utility.'

    def configure(self):
        vc_api = VeracodeAPI(self.config)
        self.vc_integrator = VeracodeIntegrator(vc_api, self.config)

    def handle(self):
        self.vc_integrator.initialize()
        self.vc_integrator.load_mapping_from_xml()
        self.vc_integrator.parse()
        self.emit.info('Finding file parsed successfully. Starting the import')
        self.vc_integrator.import_findings()
Esempio n. 2
0
class TestVeracode(unittest.TestCase):
     def setUp(self):
          self.integrator = VeracodeIntegrator(config)
          config.parse_config_file(CONF_FILE_LOCATION)
          self.integrator.init_plugin()

     def note_check(self, task_id, result, status):
         api_result = self.integrator.plugin.get_task_ide_notes("T%d" % task_id)
         notes = api_result['notes']
         last_note = notes[len(notes)-1]
         #note_time = datetime.datetime.fromtimestamp(last_note['updated'])
         #Timezone issue - datetime is 1 hour off. Neutering this assertion until this is worked out
         #self.assertTrue(note_time >= result.import_start_datetime and note_time <= result.import_finish_datetime)
         self.assertTrue(last_note['status'] == status)

     def test_import_findings(self):
         self.assertTrue(config['trial_run'] != 'true')
         task_list = self.integrator.plugin.get_task_list()
         total_nontest_tasks = len([task for task in task_list
                                   if task['phase'] not in ['testing']])
         self.integrator.load_mapping_from_xml()
         self.integrator.parse()
         findings = self.integrator.generate_findings()
         base = minidom.parse(config['report_xml'])
         xml_findings_count = len(base.getElementsByTagName('flaw'))
         self.assertTrue(xml_findings_count == len(findings))

         result = self.integrator.import_findings()
         self.assertTrue(result.error_count == 0)
         all_tasks_sanity_check = (len(result.noflaw_tasks) + len(result.affected_tasks)) == total_nontest_tasks
         self.assertTrue(all_tasks_sanity_check)
         self.assertTrue(result.error_cwes_unmapped == 0)

         for task_id in result.noflaw_tasks:
             self.note_check(task_id, result, "DONE")

         for task_id in result.affected_tasks:
             self.note_check(task_id, result, "TODO")
Esempio n. 3
0
 def configure(self):
     vc_api = VeracodeAPI(self.config)
     self.vc_integrator = VeracodeIntegrator(vc_api, self.config)
Esempio n. 4
0
 def setUp(self):
      self.integrator = VeracodeIntegrator(config)
      config.parse_config_file(CONF_FILE_LOCATION)
      self.integrator.init_plugin()