MCPcopy Create free account
hub / github.com/blacklanternsecurity/bbot / update_docs

Function update_docs

bbot/scripts/docs.py:133–305  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

131
132
133def update_docs():
134 md_files = [p for p in bbot_code_dir.glob("**/*.md") if p.is_file()]
135
136 def update_md_files(keyword, s):
137 for file in md_files:
138 find_replace_file(file, keyword, s)
139
140 def update_individual_module_options():
141 regex = re.compile("BBOT MODULE OPTIONS ([A-Z_]+)")
142 for file in md_files:
143 with open(file) as f:
144 content = f.read()
145 for match in regex.finditer(content):
146 module_name = match.groups()[0].lower()
147 bbot_module_options_table = DEFAULT_PRESET.module_loader.modules_options_table(modules=[module_name])
148 find_replace_file(file, f"BBOT MODULE OPTIONS {module_name.upper()}", bbot_module_options_table)
149
150 # Example commands
151 bbot_example_commands = []
152 for title, description, command in DEFAULT_PRESET.args.scan_examples:
153 example = ""
154 example += f"**{title}:**\n\n"
155 # example += f"{description}\n"
156 example += f"```bash\n# {description}\n{command}\n```"
157 bbot_example_commands.append(example)
158 bbot_example_commands = "\n\n".join(bbot_example_commands)
159 assert len(bbot_example_commands.splitlines()) > 10
160 update_md_files("BBOT EXAMPLE COMMANDS", bbot_example_commands)
161
162 # Help output
163 bbot_help_output = DEFAULT_PRESET.args.parser.format_help().replace("docs.py", "bbot")
164 bbot_help_output = f"```text\n{bbot_help_output}\n```"
165 assert len(bbot_help_output.splitlines()) > 50
166 update_md_files("BBOT HELP OUTPUT", bbot_help_output)
167
168 # BBOT events
169 bbot_event_table = DEFAULT_PRESET.module_loader.events_table()
170 assert len(bbot_event_table.splitlines()) > 10
171 update_md_files("BBOT EVENTS", bbot_event_table)
172
173 # BBOT modules
174 bbot_module_table = DEFAULT_PRESET.module_loader.modules_table(include_author=True, include_created_date=True)
175 assert len(bbot_module_table.splitlines()) > 50
176 update_md_files("BBOT MODULES", bbot_module_table)
177
178 # BBOT output modules
179 bbot_output_module_table = DEFAULT_PRESET.module_loader.modules_table(
180 mod_type="output", include_author=True, include_created_date=True
181 )
182 assert len(bbot_output_module_table.splitlines()) > 10
183 update_md_files("BBOT OUTPUT MODULES", bbot_output_module_table)
184
185 # BBOT universal module options
186 from bbot.scanner.preset.args import universal_module_options
187
188 universal_module_options_table = ""
189 for option, description in universal_module_options.items():
190 universal_module_options_table += f"**{option}**: {description}\n"

Callers 2

test_docsFunction · 0.90
docs.pyFile · 0.85

Calls 11

update_md_filesFunction · 0.85
openFunction · 0.85
update_tocFunction · 0.85
gen_chord_dataFunction · 0.85
replaceMethod · 0.80
events_tableMethod · 0.80
modules_tableMethod · 0.80
modules_options_tableMethod · 0.80
flags_tableMethod · 0.80
presets_tableMethod · 0.80

Tested by 1

test_docsFunction · 0.72

Used in the wild real call sites across dependent graphs

searching dependent graphs…