|
| 1 | +# Contributing to mod_botshield |
| 2 | + |
| 3 | +Thanks for your interest. The project is small and the workflow is |
| 4 | +deliberately low-ceremony. |
| 5 | + |
| 6 | +## Quick start |
| 7 | + |
| 8 | +```sh |
| 9 | +git clone https://github.com/hubzero/botshield.git |
| 10 | +cd botshield |
| 11 | +sudo tests/setup/provision.sh |
| 12 | +tests/run --parallel --mark "not browser" |
| 13 | +``` |
| 14 | + |
| 15 | +`provision.sh` is idempotent; it installs apt packages, builds and |
| 16 | +installs the module, sets up a self-signed-cert HTTPS dev vhost on |
| 17 | +`localhost`, generates per-provider dummy captcha secrets, and |
| 18 | +creates the test venv at `tests/.venv/`. Re-run it any time you |
| 19 | +want to reset the environment. |
| 20 | + |
| 21 | +After that, `tests/run` is the dispatcher — flags + markers are |
| 22 | +documented in [`tests/README.md`](tests/README.md). |
| 23 | + |
| 24 | +## Reporting bugs and asking questions |
| 25 | + |
| 26 | +- **Bugs**: open a GitHub issue with reproduction steps. A minimal |
| 27 | + Apache config snippet plus a `curl` invocation that triggers the |
| 28 | + problem is the gold standard. |
| 29 | +- **Security bugs**: do not open public issues. See |
| 30 | + [SECURITY.md](SECURITY.md). |
| 31 | +- **Questions / feature ideas**: GitHub Discussions is fine for |
| 32 | + open-ended things; issues are fine for things you want tracked. |
| 33 | + |
| 34 | +## Submitting a pull request |
| 35 | + |
| 36 | +1. Fork → branch from `main`. |
| 37 | +2. Make the change. Keep it focused — one concern per PR is |
| 38 | + easier to review than three concerns bundled. |
| 39 | +3. **Run the test suite**: |
| 40 | + ```sh |
| 41 | + tests/run --parallel |
| 42 | + ``` |
| 43 | + PRs are gated on CI. Locally-green tests + clean CI is the |
| 44 | + baseline; flake-on-CI-only happens occasionally and is a |
| 45 | + conversation, not an automatic block. |
| 46 | +4. **Rebuild the docs** if you touched `docs-src/*.md` or |
| 47 | + `site-src/*`: |
| 48 | + ```sh |
| 49 | + make docs |
| 50 | + git add docs/ |
| 51 | + ``` |
| 52 | + The CI `docs-fresh` job will fail your PR if you forget. |
| 53 | +5. **Commit messages**: imperative, focused on the *why* when it |
| 54 | + isn't obvious from the diff. The git log shows the style; copy |
| 55 | + what you see. No "fix typo" PRs are too small to be welcome. |
| 56 | +6. **Open the PR**. Describe what changed and what you tested. |
| 57 | + Screenshots / log excerpts when relevant. |
| 58 | + |
| 59 | +## Where things live |
| 60 | + |
| 61 | +- `src/` — the C source. 19 modules, each `.c` paired with `.h`. |
| 62 | + `DESIGN.md` explains the module split. |
| 63 | +- `apache/botshield-dev.conf` — the dev vhost. Path-templated |
| 64 | + through `${BS_REPO}` so it works on any developer's checkout. |
| 65 | +- `docs-src/` — markdown source for the operator handbook |
| 66 | + (rendered to `docs/` by `make docs`). |
| 67 | +- `tests/pytests/` — pytest cases. Reusable framework helpers |
| 68 | + in `tests/botshield_test/`. |
| 69 | +- `tests/fuzz/` — LibFuzzer harnesses for the cookie + robots |
| 70 | + parsers. |
| 71 | +- `tests/bench/` — wrk + oha benchmark scripts. |
| 72 | +- `tools/` — `build_site.py` (docs renderer) + |
| 73 | + `refresh-bot-ranges.sh` (operator cron tool). |
| 74 | + |
| 75 | +`CHANGELOG.md` is date-organized and gets an entry per |
| 76 | +notable PR. `DESIGN.md` is current-state architecture; update it |
| 77 | +when you change behavior, not just when you ship a feature. |
| 78 | + |
| 79 | +## Code style |
| 80 | + |
| 81 | +- C99. Apache style for indentation (4 spaces, no tabs except |
| 82 | + Makefile). `.editorconfig` enforces the basics. |
| 83 | +- Function/symbol prefixes: `bs_` / `BS_` for cross-file public |
| 84 | + symbols. File-local helpers use `static` and don't need the |
| 85 | + prefix. |
| 86 | +- Comments explain *why* something is the way it is when the |
| 87 | + code itself can't say it. Don't narrate what `if (x > 0)` does; |
| 88 | + do explain why we picked `x > 0` over `x >= 0`. |
| 89 | +- No regex on the hot path — hand-rolled byte scanners |
| 90 | + (`memcmp` / `memchr`). Reserve regex for config-time. |
| 91 | + |
| 92 | +## License |
| 93 | + |
| 94 | +By contributing, you agree your contribution is licensed under the |
| 95 | +MIT License (see [LICENSE](LICENSE)). |
0 commit comments