(self, hits, scan_metadata: dict)
| 305 | self._fd.close() |
| 306 | |
| 307 | def output(self, hits, scan_metadata: dict): |
| 308 | hits = set(hits) |
| 309 | imported_modules = {h.extra["name"] for h in hits if h.name == "ModuleImport"} |
| 310 | score = 0 |
| 311 | tags = set() |
| 312 | severities = Counter(get_severity(d) for d in hits) |
| 313 | |
| 314 | for h in hits: |
| 315 | score += h.score |
| 316 | tags |= h.tags |
| 317 | |
| 318 | score = sum(x.score for x in hits) |
| 319 | |
| 320 | if score < self.min_score: |
| 321 | return |
| 322 | |
| 323 | secho("\n", file=self._fd, color=TTY_COLORS) # Empty line for readability |
| 324 | self._formatter.print_top_separator() |
| 325 | self._formatter.print_heading(style(f"Scan results for {scan_metadata.get('name', 'N/A')}", fg="bright_green")) |
| 326 | score_color = "bright_green" if score == 0 else "bright_red" |
| 327 | self._formatter.align(style(f"Scan score: {score}", fg=score_color, bold=True)) |
| 328 | |
| 329 | self._formatter.align("") |
| 330 | |
| 331 | for severity, color in SEVERITY_COLORS.items(): |
| 332 | count = severities[severity] |
| 333 | if count == 0: |
| 334 | color = "bright_black" |
| 335 | self._formatter.align(style(f"{severity.capitalize()} severity - {count}x", fg=color)) |
| 336 | |
| 337 | self._formatter.align("") |
| 338 | |
| 339 | if len(tags) > 0: |
| 340 | self._formatter.align(f"Tags:") |
| 341 | for t in tags: |
| 342 | self._formatter.align(f" - {t}") |
| 343 | |
| 344 | if imported_modules: |
| 345 | self._formatter.print_heading("Imported modules") |
| 346 | for line in self.pprint_imports(self.imports_to_tree(imported_modules)): |
| 347 | self._formatter.align(line) |
| 348 | else: |
| 349 | self._formatter.print_heading("No imported modules detected") |
| 350 | |
| 351 | if hits: |
| 352 | self._formatter.print_heading("Code detections") |
| 353 | for h in hits: |
| 354 | self._formatter.print_thick_separator() |
| 355 | self._format_detection(h._asdict(), top_separator=False, bottom_separator=False) |
| 356 | else: |
| 357 | self._formatter.print_heading(style("No code detections has been triggered", fg="bright_green")) |
| 358 | |
| 359 | self._formatter.print_bottom_separator() |
| 360 | |
| 361 | |
| 362 | class TextInfoOutput(InfoOutputBase): |
nothing calls this directly
no test coverage detected