Generates a table of module information. Constructs a table to display information such as module name, type, and event details. Args: modules (list, optional): List of module names to include in the table. mod_type (str, optional): Type of modules to includ
(self, modules=None, mod_type=None, include_author=False, include_created_date=False)
| 549 | d[k] = set(items) |
| 550 | |
| 551 | def modules_table(self, modules=None, mod_type=None, include_author=False, include_created_date=False): |
| 552 | """Generates a table of module information. |
| 553 | |
| 554 | Constructs a table to display information such as module name, type, and event details. |
| 555 | |
| 556 | Args: |
| 557 | modules (list, optional): List of module names to include in the table. |
| 558 | mod_type (str, optional): Type of modules to include ('scan', 'output', 'internal'). |
| 559 | |
| 560 | Returns: |
| 561 | str: A formatted table string. |
| 562 | |
| 563 | Examples: |
| 564 | >>> print(modules_table(["portscan"])) |
| 565 | +----------+--------+-----------------+------------------------------+-------------------------------+----------------------+-------------------+ |
| 566 | | Module | Type | Needs API Key | Description | Flags | Consumed Events | Produced Events | |
| 567 | +==========+========+=================+==============================+===============================+======================+===================+ |
| 568 | | portscan | scan | No | Execute port scans | active, aggressive, portscan, | DNS_NAME, IP_ADDRESS | OPEN_TCP_PORT | |
| 569 | | | | | | web-thorough | | | |
| 570 | +----------+--------+-----------------+------------------------------+-------------------------------+----------------------+-------------------+ |
| 571 | """ |
| 572 | |
| 573 | table = [] |
| 574 | header = ["Module", "Type", "Needs API Key", "Description", "Flags", "Consumed Events", "Produced Events"] |
| 575 | if include_author: |
| 576 | header.append("Author") |
| 577 | if include_created_date: |
| 578 | header.append("Created Date") |
| 579 | maxcolwidths = [20, 10, 5, 30, 30, 20, 20] |
| 580 | for module_name, preloaded in self.filter_modules(modules, mod_type): |
| 581 | module_type = preloaded["type"] |
| 582 | consumed_events = sorted(preloaded.get("watched_events", [])) |
| 583 | produced_events = sorted(preloaded.get("produced_events", [])) |
| 584 | flags = sorted(preloaded.get("flags", [])) |
| 585 | api_key_required = "" |
| 586 | meta = preloaded.get("meta", {}) |
| 587 | api_key_required = "Yes" if meta.get("auth_required", False) else "No" |
| 588 | description = meta.get("description", "") |
| 589 | row = [ |
| 590 | module_name, |
| 591 | module_type, |
| 592 | api_key_required, |
| 593 | description, |
| 594 | ", ".join(flags), |
| 595 | ", ".join(consumed_events), |
| 596 | ", ".join(produced_events), |
| 597 | ] |
| 598 | if include_author: |
| 599 | author = meta.get("author", "") |
| 600 | row.append(author) |
| 601 | if include_created_date: |
| 602 | created_date = meta.get("created_date", "") |
| 603 | row.append(created_date) |
| 604 | table.append(row) |
| 605 | return make_table(table, header, maxcolwidths=maxcolwidths) |
| 606 | |
| 607 | def modules_options(self, modules=None, mod_type=None): |
| 608 | """ |
no test coverage detected