(inputs, **kwargs)
| 502 | # TODO: The use of kwargs makes it difficult to understand what arguments the function accept |
| 503 | # and difficult to follow the code flow. |
| 504 | def process_files(inputs, **kwargs): |
| 505 | # Iterate over each of the input files |
| 506 | # For live capture, the "input" would just be the name of the interface |
| 507 | global plugin_chain |
| 508 | interface = kwargs.get("interface", False) |
| 509 | count = kwargs.get("count", None) |
| 510 | # Try and use the first plugin's BPF as the initial filter |
| 511 | # The BPFs for other plugins will be applied along the chain as needed |
| 512 | bpf = plugin_chain[0].bpf |
| 513 | |
| 514 | while len(inputs) > 0: |
| 515 | input0 = inputs.pop(0) |
| 516 | |
| 517 | # Check if file needs to be decompressed by its file extension |
| 518 | extension = os.path.splitext(input0)[-1] |
| 519 | if extension in (".gz", ".bz2", ".zip") and "interface" not in kwargs: |
| 520 | tempfiles = decompress_file(input0, extension, kwargs.get("unzipdir", tempfile.gettempdir())) |
| 521 | inputs = tempfiles + inputs |
| 522 | continue |
| 523 | |
| 524 | for plugin in plugin_chain: |
| 525 | plugin._prefile(input0) |
| 526 | |
| 527 | for packet in read_packets(input0, interface=interface, bpf=bpf, count=count): |
| 528 | feed_plugin_chain(0, packet) |
| 529 | |
| 530 | clean_plugin_chain(0) |
| 531 | for plugin in plugin_chain: |
| 532 | plugin.purge() |
| 533 | plugin._postfile() |
| 534 | |
| 535 | |
| 536 | # TODO: Separate some of this logic outside of this function so we can call |
no test coverage detected