Skip to content

Commit d4ec054

Browse files
Merge pull request #2464 from blacklanternsecurity/update-docs-script
Update automatic docs generation
2 parents 79910ec + 6c25e43 commit d4ec054

12 files changed

Lines changed: 923 additions & 1028 deletions

File tree

bbot/scanner/preset/path.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ def __init__(self):
1818
self.paths = [DEFAULT_PRESET_PATH]
1919

2020
def find(self, filename):
21-
filename_path = Path(filename).expanduser().resolve()
21+
filename_path = Path(filename).expanduser()
2222
extension = filename_path.suffix.lower()
2323
file_candidates = set()
2424
extension_candidates = {".yaml", ".yml"}
@@ -39,7 +39,7 @@ def find(self, filename):
3939
if file.is_file():
4040
log.verbose(f'Found preset matching "{filename}" at {file}')
4141
self.add_path(file.parent)
42-
return file.resolve()
42+
return file
4343
raise ValidationError(
4444
f'Could not find preset at "{filename}" - file does not exist. Use -lp to list available presets'
4545
)
@@ -61,7 +61,7 @@ def add_path(self, path):
6161
return
6262
# preemptively remove any paths that are subdirectories of the new path
6363
self.paths = [p for p in self.paths if not p.is_relative_to(path)]
64-
self.paths.append(path)
64+
self.paths.insert(0, path)
6565

6666
def __iter__(self):
6767
yield from self.paths

bbot/scripts/docs.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -199,14 +199,16 @@ def update_individual_module_options():
199199

200200
# BBOT presets
201201
for _, (loaded_preset, category, preset_path, original_filename) in DEFAULT_PRESET.all_presets.items():
202+
str_category = "" if not category else f"/{category}"
203+
filename = f"~/.bbot/presets{str_category}/{original_filename.name}"
202204
preset_yaml = f"""
203-
```yaml title={preset_path.name}
205+
```yaml title={filename}
204206
{loaded_preset._yaml_str}
205207
```
206208
"""
207209
preset_yaml_expandable = f"""
208210
<details>
209-
<summary><b><code>{preset_path.name}</code></b></summary>
211+
<summary><b><code>{original_filename.name}</code></b></summary>
210212
211213
```yaml
212214
{loaded_preset._yaml_str}
@@ -222,7 +224,8 @@ def update_individual_module_options():
222224
yaml_str = loaded_preset._yaml_str
223225
indent = " " * 4
224226
yaml_str = f"\n{indent}".join(yaml_str.splitlines())
225-
filename = homedir_collapseuser(preset_path)
227+
str_category = "" if not category else f"/{category}"
228+
filename = f"~/.bbot/presets{str_category}/{original_filename.name}"
226229

227230
num_modules = len(loaded_preset.scan_modules)
228231
modules = ", ".join(sorted([f"`{m}`" for m in loaded_preset.scan_modules]))
@@ -233,7 +236,7 @@ def update_individual_module_options():
233236
234237
{loaded_preset.description}
235238
236-
??? note "`{filename.name}`"
239+
??? note "`{original_filename.name}`"
237240
```yaml title="{filename}"
238241
{yaml_str}
239242
```

0 commit comments

Comments
 (0)