|
1 | | -# osv-vuln-bot |
| 1 | +# ⭐ osv-vuln-bot — Always-Green OSV Scanner (Python CLI) |
2 | 2 |
|
3 | | -Automated OSV vulnerability scanner CLI. Scans a dependency manifest and reports findings. |
4 | | -Roadmap: open dependency bump PRs prioritized by severity. |
| 3 | +A lean, production-grade **Python CLI** to audit dependencies against [OSV.dev](https://osv.dev/). |
| 4 | +It mirrors CI locally, enables **CodeQL**, enforces a **strict always-green** workflow (linear history + required checks), and fails builds when risk thresholds are met. |
| 5 | + |
| 6 | +<div align="center"> |
| 7 | + |
| 8 | +[](https://github.com/CoderDeltaLAN/osv-vuln-bot/actions/workflows/build.yml) |
| 9 | +[](https://github.com/CoderDeltaLAN/osv-vuln-bot/actions/workflows/codeql.yml) |
| 10 | +[](https://github.com/CoderDeltaLAN/osv-vuln-bot/releases) |
| 11 | + |
| 12 | +[](LICENSE) |
| 13 | +[](https://www.paypal.com/donate/?hosted_button_id=YVENCBNCZWVPW) |
| 14 | + |
| 15 | +</div> |
| 16 | + |
| 17 | +--- |
| 18 | + |
| 19 | +## Repo layout |
| 20 | + |
| 21 | +```text |
| 22 | +. |
| 23 | +├── scripts/ # Utilities (e.g., gen_deps_from_poetry.py) |
| 24 | +├── examples/deps.sample.json # Example dependency inventory |
| 25 | +├── src/osv_vuln_bot/ # Python package + CLI |
| 26 | +├── tests/ # pytest (95%+ coverage) |
| 27 | +└── .github/workflows/ # build.yml, codeql.yml, etc. |
| 28 | +``` |
| 29 | + |
| 30 | +--- |
| 31 | + |
| 32 | +## 🚀 Quick Start (Python) |
5 | 33 |
|
6 | | -## Quick start |
7 | 34 | ```bash |
| 35 | +cd /home/user/Proyectos/osv-vuln-bot |
8 | 36 | poetry install --no-interaction |
9 | | -poetry run osv-vuln-bot scan --deps examples/deps.sample.json --out /tmp/osv-report.json --fail-on high |
| 37 | + |
| 38 | +# Local gates (mirror CI) |
| 39 | +poetry run ruff check . |
| 40 | +poetry run black --check . |
| 41 | +PYTHONPATH=src poetry run pytest -q |
| 42 | +poetry run mypy src |
10 | 43 | ``` |
11 | 44 |
|
12 | | -## Manifest format |
13 | | -`deps.json` is an array of objects: |
14 | | -```json |
15 | | -[ |
16 | | - {"ecosystem":"PyPI","name":"requests","version":"2.32.0"}, |
17 | | - {"ecosystem":"npm","name":"lodash","version":"4.17.21"} |
18 | | -] |
| 45 | +### CLI usage |
| 46 | + |
| 47 | +Generate inventory from `poetry.lock` and scan: |
| 48 | + |
| 49 | +```bash |
| 50 | +cd /home/user/Proyectos/osv-vuln-bot |
| 51 | +poetry run python scripts/gen_deps_from_poetry.py poetry.lock > deps.json |
| 52 | +poetry run osv-vuln-bot --deps deps.json --fail-on high |
19 | 53 | ``` |
20 | 54 |
|
21 | | -## CI |
22 | | -- Workflow: **CI / build** (Python 3.11/3.12; uploads logs artifacts). |
23 | | -- Code scanning: **CodeQL Analysis**. |
| 55 | +Help & options: |
| 56 | + |
| 57 | +```bash |
| 58 | +cd /home/user/Proyectos/osv-vuln-bot |
| 59 | +poetry run osv-vuln-bot --help |
| 60 | +``` |
| 61 | + |
| 62 | +**Notes** |
| 63 | +- `--deps` expects a JSON array of `{ "ecosystem":"PyPI", "name":"<pkg>", "version":"<ver>" }`. |
| 64 | +- `--fail-on` supports: `none | low | moderate | high | critical`. |
| 65 | +- If the threshold is met or exceeded, the process **exits non-zero** (perfect for CI gating). |
| 66 | + |
| 67 | +--- |
| 68 | + |
| 69 | +## 🧪 Local Developer Workflow (mirrors CI) |
| 70 | + |
| 71 | +```bash |
| 72 | +cd /home/user/Proyectos/osv-vuln-bot |
| 73 | +poetry run ruff check . |
| 74 | +poetry run black --check . |
| 75 | +PYTHONPATH=src poetry run pytest -q |
| 76 | +poetry run mypy src |
| 77 | +``` |
| 78 | + |
| 79 | +--- |
| 80 | + |
| 81 | +## 🔧 CI (GitHub Actions) |
| 82 | + |
| 83 | +- Linux matrix **Python 3.11 / 3.12** with steps matching local gates. |
| 84 | +- **OSV scan** integrated (job fails when the risk threshold is hit). |
| 85 | +- **Artifacts** with per-job logs for troubleshooting. |
| 86 | +- **CodeQL** runs on PRs and `main`. |
| 87 | + |
| 88 | +Relevant Python job fragment: |
| 89 | + |
| 90 | +```yaml |
| 91 | +- run: python -m pip install --upgrade pip |
| 92 | +- run: pip install poetry |
| 93 | +- run: poetry install --no-interaction |
| 94 | +- run: poetry run ruff check . |
| 95 | +- run: poetry run black --check . |
| 96 | +- env: |
| 97 | + PYTHONPATH: src |
| 98 | + run: poetry run pytest -q |
| 99 | +- run: poetry run mypy src |
| 100 | +- name: Generate deps from poetry.lock |
| 101 | + run: poetry run python scripts/gen_deps_from_poetry.py poetry.lock > deps.ci.json |
| 102 | +- name: OSV scan (fail on high) |
| 103 | + run: poetry run osv-vuln-bot --deps deps.ci.json --fail-on high |
| 104 | +``` |
| 105 | +
|
| 106 | +--- |
| 107 | +
|
| 108 | +## 🗺 When to Use This Project |
| 109 | +
|
| 110 | +- You need **security gating** with OSV on PRs and `main`. |
| 111 | +- Python repos that must **stay green** (branch protections + auto-merge). |
| 112 | +- Prefer **linear history** via squash-merge. |
| 113 | + |
| 114 | +--- |
| 115 | + |
| 116 | +## 🧩 Customization |
| 117 | + |
| 118 | +- Tune `--fail-on` to match your risk appetite. |
| 119 | +- Swap the inventory source (e.g., generate JSON from `requirements.txt`). |
| 120 | +- Extend the CI matrix or add OS runners if required. |
| 121 | + |
| 122 | +--- |
| 123 | + |
| 124 | +## 🛡 Security |
| 125 | + |
| 126 | +- Private disclosures via GitHub Security Advisories. |
| 127 | +- **CodeQL** enabled; OSV runs on every PR and `main`. |
| 128 | +- Secret scanning is enabled; never commit secrets. |
| 129 | + |
| 130 | +--- |
| 131 | + |
| 132 | +## 🙌 Contributing |
| 133 | + |
| 134 | +- **Small, atomic PRs** using Conventional Commits. |
| 135 | +- Keep **local gates** green before pushing. |
| 136 | +- Enable **auto-merge** once checks pass. |
| 137 | + |
| 138 | +--- |
| 139 | + |
| 140 | +## 📈 SEO Keywords |
| 141 | + |
| 142 | +osv scanner python cli, osv.dev vulnerability audit, poetry lock deps to osv, |
| 143 | +always green ci python, ruff black pytest mypy, github actions matrix, codeql analysis, |
| 144 | +branch protection required checks, squash merge linear history, dependency security gating |
| 145 | + |
| 146 | +--- |
| 147 | + |
| 148 | +## 👤 Author |
| 149 | + |
| 150 | +**CoderDeltaLAN (Yosvel)** |
| 151 | + |
| 152 | +GitHub: https://github.com/CoderDeltaLAN |
| 153 | + |
| 154 | +--- |
| 155 | + |
| 156 | +## 💚 Donations & Sponsorship |
| 157 | + |
| 158 | +If this project saves you time, consider supporting ongoing maintenance. Thank you! |
| 159 | +[](https://www.paypal.com/donate/?hosted_button_id=YVENCBNCZWVPW) |
24 | 160 |
|
25 | | -License: MIT. |
| 161 | +--- |
26 | 162 |
|
| 163 | +## 📄 License |
27 | 164 |
|
28 | | -Public repo: https://github.com/CoderDeltaLAN/osv-vuln-bot |
| 165 | +Released under the **MIT License**. See [LICENSE](LICENSE). |
0 commit comments