OSV integration
Use vuln.mlab.sh as a package-scoped, OSV-compatible vulnerability gate.
POST /api/v2/query is a package-scoped lookup designed to let vuln.mlab.sh act
as an OSV source - for example a
batlehub VulnerabilityScanner.
Unlike keyword search (/api/v1/cve), it returns only the vulnerabilities
affecting the exact coordinate you query, never a free-text match, which is the
hard requirement for a blocking CVE gate. Request and response shapes are OSV's
/v1/query, so any OSV client
works against it.
It is answered from vuln.mlab.sh's own mirror of the OSV database, with version ranges evaluated locally in each ecosystem's own version order (semver, PEP 440, Maven, RubyGems, Composer, dpkg, rpm, apk). No key, no rate limit.
Query by PURL
curl -s -X POST "https://vuln.mlab.sh/api/v2/query" \
-H 'Content-Type: application/json' \
-d '{"package":{"purl":"pkg:cargo/[email protected]"}}'Query by ecosystem + name
curl -s -X POST "https://vuln.mlab.sh/api/v2/query" \
-H 'Content-Type: application/json' \
-d '{"package":{"ecosystem":"crates.io","name":"time"},"version":"0.1.44"}'Distro packages
Debian, Ubuntu and Alpine packages are queried with the release in the ecosystem,
or as a purl with a distro qualifier:
curl -s -X POST "https://vuln.mlab.sh/api/v2/query" \
-H 'Content-Type: application/json' \
-d '{"package":{"ecosystem":"Debian:12","name":"openssl"},"version":"3.0.11-1~deb12u1"}'Distro records often have no aliases: their CVE is in upstream, or in the id
itself (DEBIAN-CVE-2023-5363).
vulns is always present, [] when the coordinate has no known vulnerabilities.
Without a version, every advisory of the package is returned.
Status semantics
This endpoint uses real HTTP status codes, unlike the v1 API, so a blocking gate can tell "clean" apart from "outage":
| Status | Meaning |
|---|---|
200 | Query succeeded. Body is { "vulns": [...] }, possibly empty. |
400 | Malformed JSON, not a package-scoped query, or a purl type that cannot be matched. |
502 | The vulnerability database is unreachable. Outage, not "no vulns". |
A client must not treat an outage (502) as an empty finding set, or a transient
blip would silently clear previously-recorded vulnerabilities.
To check a whole lockfile in one request instead of one call per package, use the SBOM scan.
Wiring into batlehub
Point the [vulnerability_scan] OSV source's base URL at https://vuln.mlab.sh
and have the adapter use the /api/v2/query path (the reference OsvScanner
hardcodes /v1/query, so the path is the only change). The OSV request body,
response parsing and fixed_version extraction all work unchanged.