Skip to main content
Tutorial

Build a Dependency Risk Agent With OSV and deps.dev

Check each lockfile dependency for known vulnerabilities and runtimes past end of life with OSV, deps.dev and endoflife.date, in one Python script.

fastcrw
By RecepNovember 20, 20267 min read

By the fastCRW team · Tutorial · Catalogue figures checked 2026-11-05 against GET /v1/data · Verify independently before relying on any figure.

A dependency risk agent answers three questions for every pinned package in a project: does this exact version have known advisories, is the runtime the project targets still supported, and which fix should the team take next. You can build the first two with three public sources, OSV, deps.dev and endoflife.date, through one API key from the Pergamon catalogue. The script below is about 60 lines of Python and runs against a real lockfile. For the wider picture of calling public sources from an agent, see Public data API for AI agents.

What goes in and what comes out

The script reads two kinds of file. For npm it reads the top-level entries of a package-lock.json (lockfile version 2 or 3). For Python it reads exact name==version lines from a requirements.txt. Ranges such as >= are skipped, because a range does not name the version you ship.

The output is one line per advisory, plus one line per runtime that the script checks. A CI job can fail when a line appears, or an agent can summarise the lines into a report.

Step 1: package facts from deps.dev

The version capability of deps.dev returns one exact version with its licences, its publish date, and an advisoryKeys list. The list holds the advisory IDs that deps.dev links to that version. Use version, not package: the package record for a large library can exceed the 256 KiB limit that applies to MCP results.

curl "https://api.fastcrw.com/v1/data/depsdev/version?system=npm&name=lodash&version=4.17.20" \
  -H "Authorization: Bearer $CRW_API_KEY"

Trimmed output from a run on 2026-11-05:

{"success":true,"provider":"depsdev","capability":"version","credits_used":1,
 "provenance":{"source":"deps.dev (Open Source Insights)","upstream_url":"https://api.deps.dev/v3/systems/npm/packages/lodash/versions/4.17.20", ...},
 "data":{"versionKey":{"system":"NPM","name":"lodash","version":"4.17.20"},"publishedAt":"2020-08-13T16:53:54Z",
 "isDeprecated":false,"licenses":["MIT"],
 "advisoryKeys":[{"id":"GHSA-29mw-wpgm-hmr9"},{"id":"GHSA-35jh-r3h4-6jhm"},{"id":"GHSA-r5fr-rjxr-66jc"},{"id":"GHSA-xxjr-mmjv-4gpg"}], ...}}

This version of lodash carries four advisory IDs. The next step turns each ID into a readable record.

Step 2: advisory details from OSV

The OSV source holds the full record for each advisory. The vulnerability capability takes one id and returns the summary, the details, the affected ranges and the references. The IDs from deps.dev work directly, so the script passes them through unchanged.

curl "https://api.fastcrw.com/v1/data/osv/vulnerability?id=GHSA-jfh8-c2jp-5v3q" \
  -H "Authorization: Bearer $CRW_API_KEY"

OSV has no batch query in the Pergamon catalogue, which lists three OSV capabilities: vulnerability, ecosystem-advisories and ecosystems. The script therefore loops over the advisory IDs, one call each. The ecosystem-advisories capability (with ecosystem and an optional maxResults) lists advisory file names for an ecosystem such as PyPI. It is useful for coverage checks, not for looking up a single package.

Step 3: runtime end of life from endoflife.date

Dependencies are not the only risk. A Python 3.9 service keeps running after the interpreter stops getting security fixes. The endoflife.date cycle capability takes a product and a cycle and returns the end-of-life date for that release line.

curl "https://api.fastcrw.com/v1/data/endoflife/cycle?product=python&cycle=3.9" \
  -H "Authorization: Bearer $CRW_API_KEY"

The response carries eol: "2025-10-31" and latest: "3.9.25". On 2026-11-05 that date is in the past, so the script reports the runtime as end of life.

The script

Save this as dep_risk.py. It needs only the crw package, which reads CRW_API_KEY from the environment.

# pip install crw
import json
from pathlib import Path

from crw import CrwApiError, CrwClient

client = CrwClient()  # reads CRW_API_KEY
MAX_ADVISORIES = 3  # each advisory is one more credit per package
RUNTIMES = [("python", "3.9"), ("nodejs", "18")]


def read_requirements(path: Path) -> dict[str, str]:
    pins = {}
    for line in path.read_text().splitlines():
        if "==" in line and not line.lstrip().startswith("#"):
            name, version = line.split("==", 1)
            pins[name.strip().lower()] = version.strip()
    return pins


def read_npm_lock(path: Path) -> dict[str, str]:
    packages = json.loads(path.read_text())["packages"]
    return {
        key.removeprefix("node_modules/"): meta["version"]
        for key, meta in packages.items()
        if key.count("node_modules/") == 1 and "version" in meta
    }


def check_package(system: str, name: str, version: str) -> list[str]:
    info = client.get_data("depsdev", "version", {"system": system, "name": name, "version": version})
    advisory_ids = [item["id"] for item in info["data"]["advisoryKeys"]]
    lines = []
    for advisory_id in advisory_ids[:MAX_ADVISORIES]:
        vuln = client.get_data("osv", "vulnerability", {"id": advisory_id})
        summary = vuln["data"].get("summary", "no summary")
        lines.append(f"{name}@{version} {advisory_id}: {summary}")
    return lines


def check_runtime(product: str, cycle: str) -> str:
    data = client.get_data("endoflife", "cycle", {"product": product, "cycle": cycle})["data"]
    return f"{product} {cycle} end of life: {data['eol']}"


def main(paths: list[str]) -> None:
    for raw in paths:
        path = Path(raw)
        is_npm = path.name == "package-lock.json"
        pins = read_npm_lock(path) if is_npm else read_requirements(path)
        for name, version in pins.items():
            try:
                for line in check_package("npm" if is_npm else "pypi", name, version):
                    print(line)
            except CrwApiError as err:
                print(f"{name}@{version} skipped: {err.error_code}")
    for product, cycle in RUNTIMES:
        print(check_runtime(product, cycle))


if __name__ == "__main__":
    import sys

    main(sys.argv[1:])

Run it with uv, which installs the SDK into a throwaway environment:

uv run --with crw python dep_risk.py package-lock.json requirements.txt

The sample inputs were a package-lock.json that pins lodash 4.17.20 and minimist 1.2.5, and a requirements.txt that pins requests==2.19.0 and flask==2.3.3. Real output from that run:

lodash@4.17.20 GHSA-29mw-wpgm-hmr9: Regular Expression Denial of Service (ReDoS) in lodash
lodash@4.17.20 GHSA-35jh-r3h4-6jhm: Command Injection in lodash
lodash@4.17.20 GHSA-r5fr-rjxr-66jc: lodash vulnerable to Code Injection via `_.template` imports key names
minimist@1.2.5 GHSA-xvch-5gv4-984h: Prototype Pollution in minimist
requests@2.19.0 GHSA-9hjg-9r4m-mvj7: Requests vulnerable to .netrc credentials leak via malicious URLs
requests@2.19.0 GHSA-9wx4-h78v-vm56: Requests `Session` object does not verify requests after making first request with verify=False
requests@2.19.0 GHSA-gc5v-m9x4-r6x2: Requests has Insecure Temp File Reuse in its extract_zipped_paths() utility function
flask@2.3.3 GHSA-68rp-wp8r-4726: Flask session does not add `Vary: Cookie` header when accessed in some ways
flask@2.3.3 PYSEC-2026-2151: no summary
python 3.9 end of life: 2025-10-31
nodejs 18 end of life: 2025-04-30

Three things in that output matter. The lodash line stops at three advisories because of MAX_ADVISORIES, so the fourth ID from deps.dev is not printed. Raise the cap to see it. The PYSEC record came back without a summary, so the script prints the fallback text instead of an empty line. And both runtimes are reported as end of life, because both release lines have passed their end-of-life dates.

Triage the output

Treat each line as a lead, not a verdict. Three checks turn a line into a decision:

  • Does the affected range cover your version? The script does not test ranges. Open the record with the vulnerability capability and read its affected section.
  • Does the package ship? A high-severity advisory in a test-only dependency is a different ticket from the same advisory in a runtime dependency.
  • Is there a fixed version? The OSV record lists fixed versions for each affected range. Upgrade to the fixed version, or to the next release line of that package.

The runtime lines answer a different question. A Python 3.9 interpreter past its end-of-life date still runs, but it gets no further security fixes, so the fix is a runtime upgrade, not a package bump.

Add exploit likelihood for CVE aliases

Some OSV records name a CVE alias. The EPSS score estimates how likely that CVE is to be exploited in the next 30 days, which is useful for ordering a long list. Call the score capability with the cve option. Trimmed output for CVE-2021-44228 on 2026-11-05:

curl "https://api.fastcrw.com/v1/data/epss/score?cve=CVE-2021-44228" \
  -H "Authorization: Bearer $CRW_API_KEY"

{"success":true,"provider":"epss","capability":"score","credits_used":1,
 "data":{"status":"OK","total":1,"data":[{"cve":"CVE-2021-44228","epss":"0.999990000","percentile":"1.000000000","date":"2026-11-04"}]}}

Use the score to order the list: a high score on a package you ship goes first, and a low score on a long-tail advisory can wait for the next scheduled upgrade.

Run it in CI

The script exits with status 0 even when it finds advisories, so a CI gate has to read the report. The gate below fails the job when any advisory line appears. Store CRW_API_KEY as a repository secret and run the job on a schedule, not on every commit, because each run spends credits.

#!/usr/bin/env bash
# Fail the job when the report lists any advisory.
set -euo pipefail
uv run --with crw python dep_risk.py package-lock.json requirements.txt > risk.txt
if grep -qE "GHSA-|PYSEC-" risk.txt; then
  cat risk.txt
  exit 1
fi

On the sample inputs above, this gate fails with exit status 1 and prints the report. On a lockfile with no advisory IDs, it passes.

Cost per lockfile

Every lookup is one call and every call that succeeds costs one credit. A package costs one deps.dev call plus up to MAX_ADVISORIES OSV calls, so at the default cap it costs up to four credits. Each runtime check costs one more. The sample run above made 15 successful calls: 4 for lodash, 2 for minimist, 4 for requests, 3 for flask and 2 for the runtimes. A failed call is not billed, so an upstream outage does not cost credits.

Set MAX_ADVISORIES to 1 when you only need to know whether a package is affected at all. Set it higher when a triage agent needs the full list.

Limits of this approach

  • It checks only the advisory IDs that deps.dev links to each version. An advisory that deps.dev does not list for that version will not appear.
  • It does not score exploit likelihood. The EPSS call above is a separate step.
  • It does not suggest a fixed version or check whether the advisory's affected range covers the version you pinned. Read the OSV record for that.
  • It reads only top-level entries in package-lock.json. Nested copies of a package are not checked.

OSV data is CC BY 4.0, published by the OSV project. Each response carries its own attribution text, so keep it when you show results to a user. The script sends each package name and version to the fastCRW API, which forwards the lookup to deps.dev, OSV and endoflife.date.

Sources

Related: CVE vulnerability API for agents · Package registry APIs for npm, PyPI and crates · Public data API for AI agents · Pergamon catalogue

FAQ

Frequently asked questions

Does this script replace a full software composition analysis tool?
No. It checks the advisories that deps.dev links to each exact version, plus the runtime end-of-life dates. A full scanner also resolves transitive trees, reads licence policies and tracks fixes. Use this script as a cheap first pass or as an input to an agent.
Why use the deps.dev version call instead of the package call?
The version call returns one exact version with its advisory IDs and is small enough to pass as an MCP result. The package call returns every version of a library and can be much larger, for example the record for react, which is over the 256 KiB MCP limit.
How many credits does a typical lockfile cost?
With the default cap of three advisories per package, each package costs one credit for the deps.dev call plus up to three for OSV, and each runtime check costs one more. Failed calls are not billed. Count your packages first and multiply by four to get an upper bound.

Get Started

Try fastCRW free

Run a live request in the playground — no signup required. Or grab a free API key with 1000 free credits, no credit card.

Continue exploring

More tutorial posts

View category archive