Skip to content

Commit

Permalink
autogenerate docs toc
Browse files Browse the repository at this point in the history
  • Loading branch information
TheTechromancer committed Jul 9, 2023
1 parent 0cdd6ec commit e518f1e
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 5 deletions.
22 changes: 21 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,27 @@ BBOT is inspired by [Spiderfoot](https://github.com/smicallef/spiderfoot) but ta

BBOT typically outperforms other subdomain enumeration tools by 20-25%. To learn how this is possible, see [How It Works](https://www.blacklanternsecurity.com/how_it_works/).

## Consider checking out our [Documentation](https://www.blacklanternsecurity.com/bbot).
## Consider checking out our [Documentation](https://www.blacklanternsecurity.com/bbot):

<!-- BBOT DOCS TOC -->
- **Basics**
- [Getting Started](https://www.blacklanternsecurity.com/bbot/index)
- [How it Works](https://www.blacklanternsecurity.com/bbot/how_it_works)
- [Comparison to Other Tools](https://www.blacklanternsecurity.com/bbot/comparison)
- **Scanning**
- [Scanning Overview](https://www.blacklanternsecurity.com/bbot/scanning/index)
- [Events](https://www.blacklanternsecurity.com/bbot/scanning/events)
- [Output](https://www.blacklanternsecurity.com/bbot/scanning/output)
- [Tips and Tricks](https://www.blacklanternsecurity.com/bbot/scanning/tips_and_tricks)
- [Advanced Usage](https://www.blacklanternsecurity.com/bbot/scanning/advanced)
- [Configuration](https://www.blacklanternsecurity.com/bbot/scanning/configuration)
- [List of Modules](https://www.blacklanternsecurity.com/bbot/scanning/list_of_modules)
- **Contribution**
- [How to Write a Module](https://www.blacklanternsecurity.com/bbot/contribution)
- **Misc**
- [Release History](https://www.blacklanternsecurity.com/bbot/release_history)
- [Troubleshooting](https://www.blacklanternsecurity.com/bbot/troubleshooting)
<!-- END BBOT DOCS TOC -->

## Installation ([pip](https://pypi.org/project/bbot/))

Expand Down
26 changes: 25 additions & 1 deletion bbot/scripts/docs.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import os
import re
import yaml
from pathlib import Path

from bbot.modules import module_loader
Expand All @@ -14,6 +15,8 @@
blacklist_chars = ["<", ">"]
blacklist_re = re.compile(r"\|([^|]*[" + re.escape("".join(blacklist_chars)) + r"][^|]*)\|")

bbot_code_dir = Path(__file__).parent.parent.parent


def enclose_tags(text):
# Use re.sub() to replace matched words with the same words enclosed in backticks
Expand Down Expand Up @@ -47,7 +50,6 @@ def find_replace_file(file, keyword, replace):


def update_docs():
bbot_code_dir = Path(__file__).parent.parent.parent
md_files = [p for p in bbot_code_dir.glob("**/*.md") if p.is_file()]

def update_md_files(keyword, s):
Expand Down Expand Up @@ -100,5 +102,27 @@ def update_md_files(keyword, s):
assert len(default_config_yml.splitlines()) > 20
update_md_files("BBOT DEFAULT CONFIG", default_config_yml)

# Table of Contents
mkdocs_yml_file = bbot_code_dir / "mkdocs.yml"
yaml.SafeLoader.add_constructor(
"tag:yaml.org,2002:python/name:pymdownx.superfences.fence_code_format", lambda x, y: {}
)
bbot_docs_toc = ""
base_url = "https://www.blacklanternsecurity.com/bbot"
with open(mkdocs_yml_file, "r") as f:
mkdocs_yaml = yaml.safe_load(f)
nav = mkdocs_yaml["nav"]
for section in nav:
# print(section)
for section_title, subsections in section.items():
bbot_docs_toc += f"- **{section_title}**\n"
for subsection in subsections:
for subsection_title, subsection_path in subsection.items():
path = subsection_path.split(".md")[0]
bbot_docs_toc += f" - [{subsection_title}]({base_url}/{path})\n"
bbot_docs_toc = bbot_docs_toc.strip()
assert len(bbot_docs_toc.splitlines()) > 5
update_md_files("BBOT DOCS TOC", bbot_docs_toc)


update_docs()
2 changes: 1 addition & 1 deletion docs/scanning/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

## Scan Names

Every BBOT scan gets a random and mildly-entertaining name like **`demonic_jimmy`**. Output for that scan, including scan stats and any web screenshots, are saved to a folder by that name in `~/.bbot/scans`. The most recent 20 scans are kept, and older ones are removed.
Every BBOT scan gets a random, mildly-entertaining name like **`demonic_jimmy`**. Output for that scan, including scan stats and any web screenshots, are saved to a folder by that name in `~/.bbot/scans`. The most recent 20 scans are kept, and older ones are removed.

If you don't want a random name, you can change it with `-n`. You can also change the location of BBOT's output with `-o`:

Expand Down
4 changes: 2 additions & 2 deletions mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@ nav:
- How it Works: how_it_works.md
- Comparison to Other Tools: comparison.md
- Scanning:
- scanning/index.md
- Scanning Overview: scanning/index.md
- Events: scanning/events.md
- Output: scanning/output.md
- Tips and Tricks: scanning/tips_and_tricks.md
- Advanced Usage: scanning/advanced.md
- Configuration: scanning/configuration.md
- List of Modules: scanning/list_of_modules.md
- Contribution:
- How to Write a Module: contribution.md
- How to Write a Module: contribution.md
- Misc:
- Release History: release_history.md
- Troubleshooting: troubleshooting.md
Expand Down

0 comments on commit e518f1e

Please sign in to comment.