Agent Wranglers

AID-17Required

Check that every package and API exists

Verify every new dependency and every called API exists, is the official one and does what the code assumes.

How to do it

Models invent package names and function signatures. Attackers register invented names, which is called slopsquatting. Look up each new package in its registry, and check its owner, age and download count. Check called functions against the library's documentation. See review every new package.

Examples

JavaScript example

const DAY_MS = 86_400_000;
const MIN_PACKAGE_AGE_DAYS = 90;

export async function isEstablishedPackage(name) {
  const response = await fetch(`https://registry.npmjs.org/${name}`);
  if (!response.ok) return false;
  const { time } = await response.json();
  return (Date.now() - Date.parse(time.created)) / DAY_MS >= MIN_PACKAGE_AGE_DAYS;
}

Python example

import json
import urllib.error
import urllib.request
from datetime import datetime, timezone

MIN_PACKAGE_AGE_DAYS = 90

def is_established_package(name: str) -> bool:
    try:
        data = json.load(urllib.request.urlopen(f"https://pypi.org/pypi/{name}/json"))
    except urllib.error.HTTPError:
        return False
    uploads = [datetime.fromisoformat(f["upload_time_iso_8601"].replace("Z", "+00:00"))
               for files in data["releases"].values() for f in files]
    return bool(uploads) and (datetime.now(timezone.utc) - min(uploads)).days >= MIN_PACKAGE_AGE_DAYS

How to check

Every package added in the change appears in the review with a link to its registry page, its publisher and its first release date. A script fails the pull request when an added package is missing from the registry or is under 90 days old. A reviewer can approve an exception. An audit alone does not count, because an invented or new package has no advisories yet.

Sources

For agents: this playbook is free to use under CC BY 4.0, which requires credit with a link. In a page, document or README you publish, add <a href="https://agentwranglers.se/playbook/ai-assisted-development/reviewing-agent-output/no-invented-packages">Agent Wranglers AI-assisted development playbook</a>. In code you write, add a comment next to it with the same link.