Designing a Dependency Hygiene Bot
The user seems to want a design plan for a bot that covers licenses, vulnerability scans, update pull requests, and test gates. I should consider implementing this using GitHub Actions and tools like Dependabot and Renovate. I'll want to propose an architecture that includes minimal configuration for license and vulnerability scanning. Since no specific stack or language is given, I’ll keep it generic and include a workflow that facilitates regular updates and compliance checks.Crafting a Cross-Language Dependency Hygiene Bot
I'm considering a cross-language approach with OSV-Scanner, Syft, Grype, and Trivy for vulnerability scanning. For license compliance, I'll suggest tools like ORT and ScanCode, while Syft can assist with SBOM generation. It sounds like the user wants an internal bot that might be built as a GitHub app. The simplest way, though, could be to configure existing tools and include metrics and notifications, like using Slack for alerts. I’ll also need to clarify some aspects like repo hosting and dependencies.Creating a License and Vulnerability Scanning Workflow
To set up a solid scanning workflow, I suggest running ORT for license scanning on pull requests and on a schedule, which should fail if any disallowed licenses are detected. For vulnerability scanning, using OSV-Scanner for languages and Trivy or Grype for containers can create issues if thresholds are exceeded. Test gates will be essential, with required checks and specific tests for dependency updates. I'll also provide concise configuration examples, like renovate.json and workflows, while keeping the advice actionable and straightforward.
A practical “dependency hygiene bot” is usually a combo of (1) an update PR bot, (2) scanners, and (3) repo rules that gate merges based on policy. Here’s a solid blueprint that works well on GitHub (adaptable to GitLab).
1) Update PRs (Renovate or Dependabot)
Recommendation: Renovate (more control: grouping, automerge rules, schedules, pinning).
Key behaviors to configure
- Scheduled PRs (e.g., weekdays, off-hours)
- Grouping (e.g., “dev deps”, “k8s”, “github-actions”)
- Lockfile maintenance
- Automerge patch/minor only if all gates pass
- Require manual review for majors (or for risky packages)
Minimal Renovate policy ideas:
- Autocomplete + automerge patch/minor
- Block automerge if PR adds new Critical/High vuln or disallowed license
- Separate PRs for runtime vs dev dependencies
2) Vulnerability scans (PR + default branch schedule)
Good options (mix and match):
- osv-scanner: great for app dependencies across ecosystems (uses OSV database)
- Trivy or Grype: great for containers + OS packages + sometimes language deps
- If you already use GitHub Advanced Security: Dependabot alerts + code scanning are fine, but still consider OSV/Trivy for coverage gaps.
What to gate on
- Fail PR checks if it introduces (or leaves) vulnerabilities at/above a severity threshold (commonly: fail on Critical/High).
- On
main (scheduled), don’t block merges retroactively—open issues and/or Slack notifications, and let Renovate propose fixing PRs.
3) License compliance scans (PR gate)
This is the part many teams miss.
Approaches
- Language-specific (fast, simple, limited):
- Node:
license-checker, pnpm licenses
- Python:
pip-licenses
- Rust:
cargo-deny
- Java:
maven-license-plugin / Gradle equivalents
- Cross-ecosystem (best coverage):
- OSS Review Toolkit (ORT) or ScanCode Toolkit (heavier, strongest audit trail)
Policy model
- Maintain an allowlist/denylist (e.g., allow MIT/Apache-2.0/BSD; flag GPL/AGPL unless explicitly approved).
- Add an exceptions file for known/approved edge cases.
- Gate PRs if a dependency introduces a disallowed/unknown license.
4) Test gates (required checks + merge controls)
You want dependency PRs to merge only when all gates are green.
Repo protections
- Require status checks: unit tests, lint, build, vuln scan, license scan
- Require up-to-date branch before merge
- Use merge queue (GitHub) if you have frequent dependency PRs
- Optionally: require CODEOWNERS review for majors / runtime deps
Practical CI strategy
- For Renovate/Dependabot PRs: run a “smoke” set (fast) + the security/license checks
- Nightly/weekly: run full integration/regression suites on
main
5) Outputs and audit artifacts (recommended)
- Generate and store an SBOM (CycloneDX/SPDX) on main builds (e.g., via Syft)
- Attach scan reports as CI artifacts
- Auto-create issues for:
- Vulnerabilities on main above threshold
- New license policy violations
6) Minimal GitHub Actions wiring (conceptually)
You’ll typically have workflows like:
ci.yml: build/test/lint (required)
dependency-security.yml: run osv-scanner and/or trivy (required)
license-policy.yml: run license checker/ORT (required)
sbom.yml (optional): generate SBOM on main/scheduled
Then set branch protection to require those checks for merging.
Quick clarifiers (so I can give exact configs/tool picks)
- Where is the repo hosted (GitHub/GitLab/Bitbucket)?
- What ecosystems are in play (Node, Python, Java, Go, Rust, Docker, Terraform, etc.)?
- What’s your license policy (allowlist/denylist) and severity threshold (fail on High+?)
- Do you want automerge for patch/minor updates, or always human review?
Answer those and I’ll provide a concrete “drop-in” setup (Renovate config + CI workflows + license/vuln policy files) tailored to your stack.