Metadata-Version: 2.4
Name: ezco
Version: 0.1.0
Summary: Security guard for AI coding agents: fake packages, leaked secrets, poisoned agent files, at commit, install and clone time
License-Expression: MIT
Project-URL: Homepage, https://github.com/negimedhansh47-jpg/ezco
Project-URL: Issues, https://github.com/negimedhansh47-jpg/ezco/issues
Keywords: security,ai-agents,slopsquatting,prompt-injection,mcp,pre-commit,claude-code,codex,cursor
Classifier: Development Status :: 4 - Beta
Classifier: Environment :: Console
Classifier: Intended Audience :: Developers
Classifier: Topic :: Security
Classifier: Topic :: Software Development :: Version Control :: Git
Classifier: Programming Language :: Python :: 3
Classifier: Operating System :: OS Independent
Requires-Python: >=3.11
Description-Content-Type: text/markdown
License-File: LICENSE
Dynamic: license-file

# ezco

Website: https://negimedhansh47-jpg.github.io/ezco/

A security guard for commits written by AI coding agents. It runs before every `git commit` and **blocks the commit** if it finds:

- **Fake or suspicious packages.** AI tools invent package names that don't exist (about 1 in 5 in one study of 576,000 code samples). Attackers register those names ("slopsquatting"). Blocks packages that don't exist and typos of popular packages that almost nobody uses. Checks `requirements.txt`, `pyproject.toml`, `package.json` and packages launched by MCP configs.
- **Leaked secrets.** API keys (AWS, GitHub, OpenAI, Anthropic, Google, Stripe, Slack, Groq), private keys, passwords inside database URLs, and random-looking hard-coded secrets, with the exact link and steps to revoke each one. Secrets are masked in the report. Also warns when a `.env` file is committed.
- **Poisoned MCP tools and agent files.** Hidden Unicode characters, prompt-injection phrases in MCP tool code, `AGENTS.md`, `CLAUDE.md`, `.cursorrules` and Cursor `.mdc` rules, and risky MCP server configs (unpinned packages, `curl | sh`, plain-http servers). It scans files in your repo; it does not connect to live MCP servers.
- **`--deep` mode (optional).** An LLM (Groq) second pass for attacks the rules can't see. Secrets are redacted before anything is sent, and the LLM can only add warnings, never cancel a rule.

## Install

```
pip install git+https://github.com/negimedhansh47-jpg/ezco
cd your-project
ezco install
```

That's it. Every `git commit` in that repo is now checked. Only the lines and packages the commit **adds** are checked, so it stays fast. Needs Python 3.11+.

If `ezco` isn't found (or Windows blocks `ezco.exe`), use `python -m ezco` instead: `python -m ezco install`. If you already have a pre-commit hook, `ezco install --force` keeps it as `pre-commit.old` and runs it first.

## Use

| Command | What it does |
|---|---|
| `ezco install` | Turn on the check for every commit in this repo |
| `ezco scan` | Scan the whole folder now (or `ezco scan file.py folder/`) |
| `ezco scan --deep` | Same, plus the LLM review (needs `GROQ_API_KEY`) |
| `ezco install --agent [claude\|codex\|gemini\|all]` | Also stop an AI agent from **installing** a fake package (see below). Default: `claude` |
| `ezco clone <url> [folder]` | Clone a repo and quarantine dangerous AI-agent files (see below) |
| `ezco guard [folder]` | Check a folder's AI-agent files before opening an agent there |
| `ezco uninstall` | Turn it off |

**Why `--agent` matters:** a malicious package can run code the moment it is installed, so catching it at commit time is too late. `--agent` adds a hook to the agent's project settings (`.claude/settings.json`, `.codex/hooks.json` or `.gemini/settings.json`). Before the agent runs `pip install`, `npm i`, `uv add`, `npx` and similar, the packages are checked. A fake or typo package gets the command denied, and the agent is told why, so it picks the real package instead. The hook answers with each tool's documented JSON "deny", so it works whichever shell runs it (cmd, PowerShell, sh, bash). ezco must be pip-installed, because the hook runs `python -m ezco`. Codex asks you to review and trust a new hook before it runs.

## Which agents are covered

| | Claude Code | Codex CLI | Gemini CLI | Cursor | Any other agent |
|---|---|---|---|---|---|
| Commit hook (git) | Yes | Yes | Yes | Yes | Yes, if it commits with git and doesn't use `--no-verify` |
| Clone guard: instruction files | `CLAUDE.md` | `AGENTS.md`, `AGENTS.override.md` | `GEMINI.md` | `.cursor/rules/*.mdc`, `.cursorrules`, `AGENTS.md` | Windsurf, Cline, Copilot files |
| Clone guard: hooks + MCP servers | `.claude/settings.json`, `.mcp.json` | `.codex/hooks.json`, `.codex/config.toml` | `.gemini/settings.json` | `.cursor/hooks.json`, `.cursor/mcp.json` | `.vscode/mcp.json` |
| Install gate | Yes, **live-tested** (Windows) | Yes, format from Codex docs, **not live-tested** | Yes, format from Gemini docs, tested by piping its hook JSON through cmd, PowerShell and sh. Gemini CLI 0.58 loads the hook ("These hooks will be executed"), but a full live run is **not done yet** | **No** (see below) | No |

- **No Cursor install gate, on purpose.** Cursor's docs don't say whether a hook answering "allow" skips your normal approval prompt. If it does, a gate that allows clean commands would auto-run every command, and Cursor would get *less* safe. The clone guard still covers Cursor's files.
- Formats and sources: [docs/research-harnesses.md](docs/research-harnesses.md). CI runs the tests on Linux, macOS and Windows, with Python 3.11 to 3.13.
- **Live tests:** Claude Code on Windows (Nov 27, 2026). `pip install reqeusts-toolbeltz` was denied with the reason shown to Claude, and `pip install requests` ran normally.
- **Try it yourself in Codex or Gemini:** in a throwaway git repo, run `ezco install --agent codex` (or `gemini`) and start the agent there (trust the folder or hook if asked). Ask it to run `pip install reqeusts-toolbeltz`: it should be denied with the reason. Then `pip install requests` should run normally. Please report the result in an issue.

## Clone guard: protect yourself from repos you pull in

```
ezco clone https://github.com/someone/repo
```

A repo you clone can attack **you**, not just your commits. Its `CLAUDE.md`, `AGENTS.md`, `GEMINI.md`, `.cursorrules`, `.windsurfrules`, `.clinerules`, Cursor `.mdc` rules or `copilot-instructions.md` can hide instructions for your AI agent (invisible Unicode, "ignore previous instructions..."). Its `.mcp.json` can launch a server, and its `.claude/settings.json`, `.cursor/hooks.json`, `.codex/hooks.json`, `.codex/config.toml` or `.gemini/settings.json` can hold a hook that runs a command on your machine. When a hook runs a script shipped in the repo (`bash .cursor/hooks/setup.sh`), the script is checked too.

`ezco clone` runs `git clone`, then checks every one of those files. Any file with a BLOCK finding is renamed to `<name>.quarantined`, so no agent loads it. The report says what was found and how to rename it back. Hidden "tag" characters are decoded, so you see the smuggled message. In a cloned repo, `ezco:ignore` marks and `.ezcoignore` are **not** honoured, because the repo's author wrote them.

- Already cloned? `ezco guard path/to/repo` does the same check (`--no-quarantine` to only report).
- `--deep` (on `clone` or `guard`) also sends the agent files, secrets redacted, to the LLM. It catches reworded attacks with no trigger phrases. Unlike at commit time, an LLM hit here **quarantines** the file it names. The LLM can still only add findings, never clear the rules' findings, and a quarantine is just a rename you can undo.
- `ezco install` also adds a `post-merge` git hook that re-checks agent files after every `git pull` (warns only). `git pull --rebase` doesn't run post-merge hooks, so it's not covered there.
- A hardcoded key in a cloned agent file is also a BLOCK, so that file gets quarantined too.
- Rules are stricter than at commit time, because a stranger wrote these files. **Any** prompt-injection sign in an agent file quarantines it, and so does a hook that uploads data (`curl -d`), runs encoded code (`-EncodedCommand`, `base64 -d | sh`) or runs downloaded code. Other hook commands only warn. The catch: a `CLAUDE.md` that quotes an attack as a security example gets quarantined too. Read it and rename it back.
- Exit codes: `0` clean or warnings only, `1` something was quarantined (or found, with `--no-quarantine`), `2` the folder doesn't exist. `ezco clone` passes on git's own exit code if the clone fails.
- `ezco uninstall` removes the commit hook, the post-merge hook and the agent gate.

**The honest catch:** Claude Code loads `CLAUDE.md` the moment it starts in a folder, and no Claude Code hook can stop that. So the protection only works if the check runs **before** you open an agent there: clone with `ezco clone`, or run `ezco guard` first. Opening a poisoned folder directly with an agent is not protected. (Claude Code does ask you to trust a new folder first; that is your last chance to run `ezco guard`.)

**Demo:** `python demo/make_trap_repo.py trap` builds a booby-trapped repo (hidden Unicode + an injection line in `CLAUDE.md`, and a `.claude/settings.json` hook that runs `curl ... | sh`). Then `ezco clone trap victim`. The payload points at `example.invalid`, which can never resolve.

**False alarm? Three ways out:**

| Way | Works in | Example |
|---|---|---|
| `ezco:ignore` anywhere on the line | any file with comments (`.py`, `.js`, `.env`, `.yaml`, `requirements.txt`, Markdown via `<!-- ezco:ignore -->`) | `KEY = load()  # ezco:ignore` |
| `.ezcoignore` file in the repo root | any file, incl. JSON (no comments allowed there) | `demo/` or `*.min.js` |
| skip once | the whole commit | `git commit --no-verify` |

- **Deep mode on a commit:** set `EZCO_DEEP=1` (PowerShell: `$env:EZCO_DEEP=1`) before `git commit`. Get a free key at console.groq.com/keys and set `GROQ_API_KEY`, or put `GROQ_API_KEY=...` in a `.env` file in the repo folder (keep `.env` in `.gitignore`). A real environment variable wins over `.env`.

`BLOCK` stops the commit. `WARN` is printed but lets it through.

## Try the demo

```
python -m ezco scan demo
```

`demo/` has planted problems: a fake package, a typo package, leaked keys, a poisoned MCP tool and a risky `.mcp.json`. None of the keys are real.

## Run tests

```
python -m unittest discover -s tests
```

## How it compares (honest table)

Taken from each tool's own README, read Nov 27, 2026. "Not stated" means their docs don't say. It does **not** mean the tool can't do it. slopgate-cli's npm page refused automated reading, so its column comes from Socket.dev's copy of its README and is **unverified**.

| Feature | ezco | [slopscan](https://github.com/DARusrus/slopscan) | [depfence](https://github.com/ericrihm/depfence) | [gitleaks](https://github.com/gitleaks/gitleaks) | slopgate-cli (unverified) | [What's Inherited](https://github.com/stcmain/whats-inherited-mcp) |
|---|---|---|---|---|---|---|
| Fake (AI-invented) packages | Yes: PyPI + npm, live registry | Yes, live registry check is opt-in | Yes, 14 ecosystems, from curated lists | No | Yes, npm only | No |
| Typos of popular packages | Yes | Not stated | Yes | No | Yes | No |
| Leaked secrets | Yes | Yes | Yes | Yes (the most mature here) | No | No (reads env var names only) |
| Exact revoke steps per key | Yes | Not stated | Not stated | Not stated | No | No |
| Prompt injection / hidden Unicode in agent files | Yes | Partly (in source code) | Yes (zero-width, MCP tool text) | No | No | Lists the files, doesn't judge them |
| MCP config check | Yes | Secrets only | Yes | No | No | Lists servers only |
| Pre-commit hook | Yes | Yes | Yes | Yes | No | No |
| Stops an agent's install before it runs | Yes: Claude Code (live-tested), Codex, Gemini CLI | Not stated | Listed as an integration, no details | No | Yes, Claude Code + Codex, npm only, macOS/Linux builds | No |
| Checks `.claude/settings.json` hook commands | Yes | Secrets only | Partly (SessionStart hook injection) | No | No | Yes, lists them |
| Quarantines a cloned repo's agent files before an agent opens them | **Yes** (`ezco clone`) | Not stated | Not stated | No | No | No: "Nothing is edited, quarantined or scored" |
| Optional LLM review | Yes, Groq, secrets redacted, can only add warnings | Yes, Gemini | No | No | No | No |

**What only ezco does (by these tools' own docs):** quarantining a cloned repo's agent files before an agent loads them, and giving revoke steps for each leaked key. It also covers commit time, install time and clone time in one zero-dependency tool.

**Where others are stronger:** depfence covers far more ecosystems (Cargo, Go, Maven...) and does SBOMs. gitleaks has much deeper secret rules and scans git history. What's Inherited gives a fuller inventory of what a repo hands an agent (skills, subagents, imports).

## Limits (honest list)

- Secret detection uses patterns. Unusual secret formats are missed, and deep-mode redaction only hides what the patterns catch.
- Injection phrases are English keyword rules; clever rewording gets past them (that's what `--deep` is for). A single phrase only blocks in agent files and MCP tool code; elsewhere (e.g. docs that quote an attack) it warns.
- If PyPI/npm can't be reached, unknown packages get a WARN, not a BLOCK, so a network hiccup never stops your work.
- Deep mode is tested offline with a fake LLM, and was run live once on Groq with `openai/gpt-oss-120b`. Override the model with `EZCO_MODEL`.
- The clone guard checks only the agent files listed above. It doesn't check `.claude/commands`, skills, `statusLine` commands, or a repo's normal code. It follows hook commands into scripts inside the repo, but not Windows-style `.\script.ps1` paths.

## Test results (Nov 27, 2026)

- **Accuracy:** 99 of 107 hand-labelled cases correct, written by a separate AI agent that hadn't seen the code. **0 false alarms** on 30 normal files (lookalikes like `tokenizer=`, UUIDs, lockfile hashes, emoji, Hindi/Arabic text, placeholder keys).
- **Clone guard (Nov 27):** 37 of 40 hand-labelled repos correct with the rules alone (written by a separate AI agent that hadn't seen the code). Misses: two attacks reworded with no trigger phrases, and one false alarm, a `CLAUDE.md` security note quoting an attack. With `--deep`, both reworded attacks were caught. One more harmless-labelled repo was flagged, a hook that silently runs `pip install -r requirements.txt`.
- **Cursor / Codex / Gemini files (Nov 27):** 30 of 30 hand-labelled cases correct, after adding a rule for script-level attacks (Python/JS that fetch-and-eval, save-and-run, or send secrets out). 0 false alarms on 102 real `.cursor/hooks.json`, `.codex/config.toml`, `.codex/hooks.json` and `.gemini/settings.json` files from public GitHub repos.
- **Rerun them:** `python tests/corpus/score.py`. The cases are stored as JSON, not as real files, so no agent working on this repo loads the poisoned ones.
- **Real repos:** 0 false alarms on 271 real agent files from [awesome-cursorrules](https://github.com/PatrickJS/awesome-cursorrules) (257 Cursor rules), openai/codex, anthropics/claude-code and langfuse, after fixing one hit on "builds do not read `.env` files". Guarding a 5,000-file repo with a 1 MB `CLAUDE.md` takes about 2 seconds.
- **Install gate (Nov 27):** 40 of 40 commands correct (15 fake or typo installs blocked, 25 real or non-install commands allowed). It takes about 0.4 s per command, or about 1 s when an unknown package needs a registry lookup.
- **Speed:** a normal commit takes under 1 second. The first commit of a 40-package npm app is instant (popular packages are known-safe). A full scan of 2,000 files takes about 12 seconds. A 1 MB single-line file takes under 1 second.

See `AI_USAGE.md` for every tool, API and dataset used.

## Maintainers: publishing to PyPI

Releases use PyPI Trusted Publishing (`.github/workflows/release.yml`). No API token is stored anywhere. It runs only when a `v*` tag is pushed.

1. Create an account at pypi.org/account/register and turn on 2FA (PyPI requires it).
2. Go to pypi.org/manage/account/publishing and add a **pending publisher**: PyPI project name `ezco`, owner `negimedhansh47-jpg`, repository `ezco`, workflow `release.yml`, environment `pypi`.
3. On GitHub: repo Settings > Environments > New environment, name it `pypi`. (Optional: add yourself as a required reviewer, so each release waits for your click.)
4. Make sure `version` in `pyproject.toml` is the version you want, commit and push.
5. Tag and push: `git tag v0.1.0` then `git push origin v0.1.0`.
6. Watch the Actions tab. When the `release` job is green, the package is on pypi.org/project/ezco.

A version number can be published only once. For a fix, bump `version` and push a new tag.

## License

MIT. See [LICENSE](LICENSE).
