|
1 | | -# ⭐ osv-vuln-bot — Always-Green OSV Scanner (Python CLI) |
| 1 | +# 🔎 OSV Vulnerability Bot — Always‑Green Python Project |
2 | 2 |
|
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. |
| 3 | +Automated vulnerability scanning and CI hardening for Python projects. |
| 4 | +This repo integrates **OSV‑Scanner** against `poetry.lock`, a strict **green CI** (ruff, black, pytest, mypy), and **CodeQL** for security—all guarded by branch protection. |
5 | 5 |
|
6 | 6 | <div align="center"> |
7 | 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) |
| 8 | +[](https://github.com/CoderDeltaLAN/osv-vuln-bot/actions/workflows/ci.yml) |
| 9 | +[](https://github.com/CoderDeltaLAN/osv-vuln-bot/actions/workflows/codeql.yml) |
10 | 10 | [](https://github.com/CoderDeltaLAN/osv-vuln-bot/releases) |
11 | 11 |  |
12 | 12 | [](LICENSE) |
13 | | -[](https://www.paypal.com/donate/?hosted_button_id=YVENCBNCZWVPW) |
14 | 13 |
|
15 | 14 | </div> |
16 | 15 |
|
17 | 16 | --- |
18 | 17 |
|
19 | | -## Repo layout |
| 18 | +## What this project does |
20 | 19 |
|
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 | | -``` |
| 20 | +- Runs **OSV‑Scanner** on `poetry.lock` to surface known vulnerabilities early. |
| 21 | +- Enforces **always‑green** PRs with required checks: *Analyze*, *python (3.11)*, *python (3.12)*. |
| 22 | +- Uses **CodeQL** for code‑scanning and **Release Drafter** + conventional commits for clean releases. |
| 23 | +- Keeps **linear history** via squash‑merge and branch protection. |
29 | 24 |
|
30 | 25 | --- |
31 | 26 |
|
32 | | -## 🚀 Quick Start (Python) |
| 27 | +## Quick start (local) |
33 | 28 |
|
34 | 29 | ```bash |
35 | | -cd /home/user/Proyectos/osv-vuln-bot |
36 | | -poetry install --no-interaction |
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 |
| 30 | +# Install tooling (inside your virtualenv) |
| 31 | +python -m pip install -U pip |
| 32 | +pip install ruff black pytest mypy |
| 33 | + |
| 34 | +# Lint/format/tests/types (mirrors CI) |
| 35 | +ruff check . |
| 36 | +black --check . |
| 37 | +PYTHONPATH=src pytest -q |
| 38 | +mypy src |
43 | 39 | ``` |
44 | 40 |
|
45 | | -### CLI usage |
46 | | - |
47 | | -Generate inventory from `poetry.lock` and scan: |
48 | | - |
| 41 | +### Local OSV scan |
49 | 42 | ```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 |
53 | | -``` |
54 | | - |
55 | | -Help & options: |
| 43 | +# Option A: Using osv-scanner CLI |
| 44 | +python -m pip install osv-scanner |
| 45 | +osv-scanner --lockfile=poetry.lock |
56 | 46 |
|
57 | | -```bash |
58 | | -cd /home/user/Proyectos/osv-vuln-bot |
59 | | -poetry run osv-vuln-bot --help |
| 47 | +# Option B: Docker (if you prefer containers) |
| 48 | +docker run --rm -v "$PWD:/work" ghcr.io/google/osv-scanner:latest \ |
| 49 | + --lockfile=/work/poetry.lock |
60 | 50 | ``` |
61 | 51 |
|
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 | | -``` |
| 52 | +> CI runs these gates on PRs and `main`. Branch protection blocks merges if any fail. |
78 | 53 |
|
79 | 54 | --- |
80 | 55 |
|
81 | | -## 🔧 CI (GitHub Actions) |
| 56 | +## CI / CD |
82 | 57 |
|
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`. |
| 58 | +- **CI:** `.github/workflows/ci.yml` → Linux, Python 3.11/3.12, ruff/black/pytest/mypy. |
| 59 | +- **Security:** `.github/workflows/codeql.yml` → CodeQL analysis on PRs and `main`. |
| 60 | +- **Releases:** Drafted by Release Drafter; tags via GitHub Releases. Keep commits conventional for good notes. |
87 | 61 |
|
88 | | -Relevant Python job fragment: |
| 62 | +Example Python steps (as in CI): |
89 | 63 |
|
90 | 64 | ```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 |
| 65 | +- run: python -m pip install -U pip |
| 66 | +- run: pip install ruff black pytest mypy |
| 67 | +- run: ruff check . |
| 68 | +- run: black --check . |
| 69 | +- run: pytest -q |
| 70 | +- run: mypy src |
104 | 71 | ``` |
105 | 72 |
|
106 | 73 | --- |
107 | 74 |
|
108 | | -## 🗺 When to Use This Project |
| 75 | +## Branch protection (main) |
109 | 76 |
|
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. |
| 77 | +- Required checks: **Analyze**, **python (3.11)**, **python (3.12)**. |
| 78 | +- Linear history, no force‑push, conversations resolved, admins enforced. |
| 79 | +- Squash‑merge only; auto‑merge allowed once checks pass. |
113 | 80 |
|
114 | 81 | --- |
115 | 82 |
|
116 | | -## 🧩 Customization |
| 83 | +## Contributing |
117 | 84 |
|
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. |
| 85 | +- Use **small, atomic PRs** and **Conventional Commits** (e.g., `feat: ...`, `fix: ...`, `docs: ...`). |
| 86 | +- Keep local gates green before pushing. |
| 87 | +- Enable **auto‑merge** when checks pass. |
121 | 88 |
|
122 | 89 | --- |
123 | 90 |
|
124 | | -## 🛡 Security |
| 91 | +## Security Policy |
125 | 92 |
|
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. |
| 93 | +Please report vulnerabilities via **GitHub Security Advisories** (private) or open a minimal reproducible issue if appropriate. CodeQL and OSV scans run automatically on PRs and `main`. |
129 | 94 |
|
130 | 95 | --- |
131 | 96 |
|
132 | | -## 🙌 Contributing |
| 97 | +## Sponsorship |
133 | 98 |
|
134 | | -- **Small, atomic PRs** using Conventional Commits. |
135 | | -- Keep **local gates** green before pushing. |
136 | | -- Enable **auto-merge** once checks pass. |
| 99 | +If this project is useful, consider supporting continued maintenance and polish. Thank you! |
| 100 | +[**PayPal Donate**](https://www.paypal.com/donate/?hosted_button_id=YVENCBNCZWVPW) |
137 | 101 |
|
138 | 102 | --- |
139 | 103 |
|
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) |
160 | | - |
161 | | ---- |
| 104 | +## License |
162 | 105 |
|
163 | | -## 📄 License |
| 106 | +Distributed under the **MIT License**. See [LICENSE](LICENSE). |
164 | 107 |
|
165 | | -Released under the **MIT License**. See [LICENSE](LICENSE). |
0 commit comments