| 315 | |
| 316 | |
| 317 | def render(results: floss.results.ResultDocument, verbose, disable_headers, color): |
| 318 | sys.__stdout__.reconfigure(encoding="utf-8") |
| 319 | console = Console(file=io.StringIO(), color_system=get_color(color), highlight=False, soft_wrap=True) |
| 320 | |
| 321 | if not disable_headers: |
| 322 | console.print("\n") |
| 323 | if verbose == Verbosity.DEFAULT: |
| 324 | console.print(f"FLARE FLOSS RESULTS (version {results.metadata.version})\n") |
| 325 | else: |
| 326 | colored_str = heading_style(f"FLARE FLOSS RESULTS (version {results.metadata.version})\n") |
| 327 | console.print(colored_str) |
| 328 | render_meta(results, console, verbose) |
| 329 | console.print("\n") |
| 330 | |
| 331 | if results.analysis.enable_static_strings: |
| 332 | render_staticstrings(results.strings.static_strings, console, verbose, disable_headers) |
| 333 | console.print("\n") |
| 334 | |
| 335 | if results.metadata.language in ( |
| 336 | floss.language.identify.Language.GO.value, |
| 337 | floss.language.identify.Language.RUST.value, |
| 338 | ): |
| 339 | render_language_strings( |
| 340 | results.metadata.language, |
| 341 | results.strings.language_strings, |
| 342 | results.strings.language_strings_missed, |
| 343 | console, |
| 344 | verbose, |
| 345 | disable_headers, |
| 346 | ) |
| 347 | console.print("\n") |
| 348 | |
| 349 | if results.analysis.enable_stack_strings: |
| 350 | render_heading(f"FLOSS STACK STRINGS ({len(results.strings.stack_strings)})", console, verbose, disable_headers) |
| 351 | render_stackstrings(results.strings.stack_strings, console, verbose, disable_headers) |
| 352 | console.print("\n") |
| 353 | |
| 354 | if results.analysis.enable_tight_strings: |
| 355 | render_heading(f"FLOSS TIGHT STRINGS ({len(results.strings.tight_strings)})", console, verbose, disable_headers) |
| 356 | render_stackstrings(results.strings.tight_strings, console, verbose, disable_headers) |
| 357 | console.print("\n") |
| 358 | |
| 359 | if results.analysis.enable_decoded_strings: |
| 360 | render_heading( |
| 361 | f"FLOSS DECODED STRINGS ({len(results.strings.decoded_strings)})", console, verbose, disable_headers |
| 362 | ) |
| 363 | render_decoded_strings(results.strings.decoded_strings, console, verbose, disable_headers) |
| 364 | |
| 365 | console.file.seek(0) |
| 366 | return console.file.read() |