def write_files(self): """ This method writes code for then current selection into files It adds an entry into the manifest with specified informations """ current_flaw_group = self.current_sink.flaw_group.lower() current_flaw = self.current_sink.flaw_type files_path = [] # Create main file main_filename = self.generate_file_name("File1") filemanager = FileManager(main_filename, self.dir_name, "OWASP_"+current_flaw_group, current_flaw, self.is_safe_selection(), self.current_code) filemanager.createFile() full_path = filemanager.getPath() + main_filename line = 0 if not self.is_safe_selection(): line = Generator.findFlaw(full_path, self.file_template.comment['inline']) files_path.append({'path': full_path, 'line': line}) # Create other classes for i, cl in enumerate(self.classes_code): filename = self.generate_file_name("File"+str(i+2)) filemanager = FileManager(filename, self.dir_name, "OWASP_"+current_flaw_group, current_flaw, self.is_safe_selection(), cl['code']) filemanager.createFile() full_path = filemanager.getPath() + filename files_path.append({'path': full_path, 'line': 0}) # Update the report if current_flaw_group not in self.report: self.report[current_flaw_group] = {} if current_flaw not in self.report[current_flaw_group]: self.report[current_flaw_group][current_flaw] = {} self.report[current_flaw_group][current_flaw]["safe_sample"] = 0 self.report[current_flaw_group][current_flaw]["unsafe_sample"] = 0 if self.is_safe_selection(): self.report[current_flaw_group][current_flaw]["safe_sample"] += 1 else: self.report[current_flaw_group][current_flaw]["unsafe_sample"] += 1 # update manifest input_type = "None : None" if self.current_input: input_type = self.current_input.input_type self.manifest.addTestCase(input_type, current_flaw_group, current_flaw, files_path, self.file_template.language_name)
def write_files(self): """ This method writes code for then current selection into files It adds an entry into the manifest with specified informations """ current_flaw_group = self.current_sink.flaw_group.lower() current_flaw = self.current_sink.flaw_type files_path = [] # Create main file main_filename = self.generate_file_name("File1") filemanager = FileManager(main_filename, self.dir_name, "OWASP_" + current_flaw_group, current_flaw, self.is_safe_selection(), self.current_code) filemanager.createFile() full_path = filemanager.getPath() + main_filename line = 0 if not self.is_safe_selection(): line = Generator.findFlaw(full_path, self.file_template.comment['inline']) files_path.append({'path': full_path, 'line': line}) # Create other classes for i, cl in enumerate(self.classes_code): filename = self.generate_file_name("File" + str(i + 2)) filemanager = FileManager(filename, self.dir_name, "OWASP_" + current_flaw_group, current_flaw, self.is_safe_selection(), cl['code']) filemanager.createFile() full_path = filemanager.getPath() + filename files_path.append({'path': full_path, 'line': 0}) # Update the report if current_flaw_group not in self.report: self.report[current_flaw_group] = {} if current_flaw not in self.report[current_flaw_group]: self.report[current_flaw_group][current_flaw] = {} self.report[current_flaw_group][current_flaw]["safe_sample"] = 0 self.report[current_flaw_group][current_flaw]["unsafe_sample"] = 0 if self.is_safe_selection(): self.report[current_flaw_group][current_flaw]["safe_sample"] += 1 else: self.report[current_flaw_group][current_flaw]["unsafe_sample"] += 1 # update manifest input_type = "None : None" if self.current_input: input_type = self.current_input.input_type self.manifest.addTestCase(input_type, current_flaw_group, current_flaw, files_path, self.file_template.language_name)