ezco 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
ezco-0.1.0/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Medhansh
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
ezco-0.1.0/PKG-INFO ADDED
@@ -0,0 +1,177 @@
1
+ Metadata-Version: 2.4
2
+ Name: ezco
3
+ Version: 0.1.0
4
+ Summary: Security guard for AI coding agents: fake packages, leaked secrets, poisoned agent files, at commit, install and clone time
5
+ License-Expression: MIT
6
+ Project-URL: Homepage, https://github.com/negimedhansh47-jpg/ezco
7
+ Project-URL: Issues, https://github.com/negimedhansh47-jpg/ezco/issues
8
+ Keywords: security,ai-agents,slopsquatting,prompt-injection,mcp,pre-commit,claude-code,codex,cursor
9
+ Classifier: Development Status :: 4 - Beta
10
+ Classifier: Environment :: Console
11
+ Classifier: Intended Audience :: Developers
12
+ Classifier: Topic :: Security
13
+ Classifier: Topic :: Software Development :: Version Control :: Git
14
+ Classifier: Programming Language :: Python :: 3
15
+ Classifier: Operating System :: OS Independent
16
+ Requires-Python: >=3.11
17
+ Description-Content-Type: text/markdown
18
+ License-File: LICENSE
19
+ Dynamic: license-file
20
+
21
+ # ezco
22
+
23
+ Website: https://negimedhansh47-jpg.github.io/ezco/
24
+
25
+ A security guard for commits written by AI coding agents. It runs before every `git commit` and **blocks the commit** if it finds:
26
+
27
+ - **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.
28
+ - **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.
29
+ - **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.
30
+ - **`--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.
31
+
32
+ ## Install
33
+
34
+ ```
35
+ pip install git+https://github.com/negimedhansh47-jpg/ezco
36
+ cd your-project
37
+ ezco install
38
+ ```
39
+
40
+ 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+.
41
+
42
+ 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.
43
+
44
+ ## Use
45
+
46
+ | Command | What it does |
47
+ |---|---|
48
+ | `ezco install` | Turn on the check for every commit in this repo |
49
+ | `ezco scan` | Scan the whole folder now (or `ezco scan file.py folder/`) |
50
+ | `ezco scan --deep` | Same, plus the LLM review (needs `GROQ_API_KEY`) |
51
+ | `ezco install --agent [claude\|codex\|gemini\|all]` | Also stop an AI agent from **installing** a fake package (see below). Default: `claude` |
52
+ | `ezco clone <url> [folder]` | Clone a repo and quarantine dangerous AI-agent files (see below) |
53
+ | `ezco guard [folder]` | Check a folder's AI-agent files before opening an agent there |
54
+ | `ezco uninstall` | Turn it off |
55
+
56
+ **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.
57
+
58
+ ## Which agents are covered
59
+
60
+ | | Claude Code | Codex CLI | Gemini CLI | Cursor | Any other agent |
61
+ |---|---|---|---|---|---|
62
+ | Commit hook (git) | Yes | Yes | Yes | Yes | Yes, if it commits with git and doesn't use `--no-verify` |
63
+ | Clone guard: instruction files | `CLAUDE.md` | `AGENTS.md`, `AGENTS.override.md` | `GEMINI.md` | `.cursor/rules/*.mdc`, `.cursorrules`, `AGENTS.md` | Windsurf, Cline, Copilot files |
64
+ | 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` |
65
+ | 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 |
66
+
67
+ - **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.
68
+ - 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.
69
+ - **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.
70
+ - **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.
71
+
72
+ ## Clone guard: protect yourself from repos you pull in
73
+
74
+ ```
75
+ ezco clone https://github.com/someone/repo
76
+ ```
77
+
78
+ 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.
79
+
80
+ `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.
81
+
82
+ - Already cloned? `ezco guard path/to/repo` does the same check (`--no-quarantine` to only report).
83
+ - `--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.
84
+ - `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.
85
+ - A hardcoded key in a cloned agent file is also a BLOCK, so that file gets quarantined too.
86
+ - 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.
87
+ - 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.
88
+ - `ezco uninstall` removes the commit hook, the post-merge hook and the agent gate.
89
+
90
+ **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`.)
91
+
92
+ **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.
93
+
94
+ **False alarm? Three ways out:**
95
+
96
+ | Way | Works in | Example |
97
+ |---|---|---|
98
+ | `ezco:ignore` anywhere on the line | any file with comments (`.py`, `.js`, `.env`, `.yaml`, `requirements.txt`, Markdown via `<!-- ezco:ignore -->`) | `KEY = load() # ezco:ignore` |
99
+ | `.ezcoignore` file in the repo root | any file, incl. JSON (no comments allowed there) | `demo/` or `*.min.js` |
100
+ | skip once | the whole commit | `git commit --no-verify` |
101
+
102
+ - **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`.
103
+
104
+ `BLOCK` stops the commit. `WARN` is printed but lets it through.
105
+
106
+ ## Try the demo
107
+
108
+ ```
109
+ python -m ezco scan demo
110
+ ```
111
+
112
+ `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.
113
+
114
+ ## Run tests
115
+
116
+ ```
117
+ python -m unittest discover -s tests
118
+ ```
119
+
120
+ ## How it compares (honest table)
121
+
122
+ 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**.
123
+
124
+ | 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) |
125
+ |---|---|---|---|---|---|---|
126
+ | 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 |
127
+ | Typos of popular packages | Yes | Not stated | Yes | No | Yes | No |
128
+ | Leaked secrets | Yes | Yes | Yes | Yes (the most mature here) | No | No (reads env var names only) |
129
+ | Exact revoke steps per key | Yes | Not stated | Not stated | Not stated | No | No |
130
+ | 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 |
131
+ | MCP config check | Yes | Secrets only | Yes | No | No | Lists servers only |
132
+ | Pre-commit hook | Yes | Yes | Yes | Yes | No | No |
133
+ | 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 |
134
+ | Checks `.claude/settings.json` hook commands | Yes | Secrets only | Partly (SessionStart hook injection) | No | No | Yes, lists them |
135
+ | 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" |
136
+ | Optional LLM review | Yes, Groq, secrets redacted, can only add warnings | Yes, Gemini | No | No | No | No |
137
+
138
+ **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.
139
+
140
+ **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).
141
+
142
+ ## Limits (honest list)
143
+
144
+ - Secret detection uses patterns. Unusual secret formats are missed, and deep-mode redaction only hides what the patterns catch.
145
+ - 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.
146
+ - If PyPI/npm can't be reached, unknown packages get a WARN, not a BLOCK, so a network hiccup never stops your work.
147
+ - 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`.
148
+ - 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.
149
+
150
+ ## Test results (Nov 27, 2026)
151
+
152
+ - **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).
153
+ - **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`.
154
+ - **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.
155
+ - **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.
156
+ - **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.
157
+ - **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.
158
+ - **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.
159
+
160
+ See `AI_USAGE.md` for every tool, API and dataset used.
161
+
162
+ ## Maintainers: publishing to PyPI
163
+
164
+ Releases use PyPI Trusted Publishing (`.github/workflows/release.yml`). No API token is stored anywhere. It runs only when a `v*` tag is pushed.
165
+
166
+ 1. Create an account at pypi.org/account/register and turn on 2FA (PyPI requires it).
167
+ 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`.
168
+ 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.)
169
+ 4. Make sure `version` in `pyproject.toml` is the version you want, commit and push.
170
+ 5. Tag and push: `git tag v0.1.0` then `git push origin v0.1.0`.
171
+ 6. Watch the Actions tab. When the `release` job is green, the package is on pypi.org/project/ezco.
172
+
173
+ A version number can be published only once. For a fix, bump `version` and push a new tag.
174
+
175
+ ## License
176
+
177
+ MIT. See [LICENSE](LICENSE).
ezco-0.1.0/README.md ADDED
@@ -0,0 +1,157 @@
1
+ # ezco
2
+
3
+ Website: https://negimedhansh47-jpg.github.io/ezco/
4
+
5
+ A security guard for commits written by AI coding agents. It runs before every `git commit` and **blocks the commit** if it finds:
6
+
7
+ - **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.
8
+ - **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.
9
+ - **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.
10
+ - **`--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.
11
+
12
+ ## Install
13
+
14
+ ```
15
+ pip install git+https://github.com/negimedhansh47-jpg/ezco
16
+ cd your-project
17
+ ezco install
18
+ ```
19
+
20
+ 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+.
21
+
22
+ 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.
23
+
24
+ ## Use
25
+
26
+ | Command | What it does |
27
+ |---|---|
28
+ | `ezco install` | Turn on the check for every commit in this repo |
29
+ | `ezco scan` | Scan the whole folder now (or `ezco scan file.py folder/`) |
30
+ | `ezco scan --deep` | Same, plus the LLM review (needs `GROQ_API_KEY`) |
31
+ | `ezco install --agent [claude\|codex\|gemini\|all]` | Also stop an AI agent from **installing** a fake package (see below). Default: `claude` |
32
+ | `ezco clone <url> [folder]` | Clone a repo and quarantine dangerous AI-agent files (see below) |
33
+ | `ezco guard [folder]` | Check a folder's AI-agent files before opening an agent there |
34
+ | `ezco uninstall` | Turn it off |
35
+
36
+ **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.
37
+
38
+ ## Which agents are covered
39
+
40
+ | | Claude Code | Codex CLI | Gemini CLI | Cursor | Any other agent |
41
+ |---|---|---|---|---|---|
42
+ | Commit hook (git) | Yes | Yes | Yes | Yes | Yes, if it commits with git and doesn't use `--no-verify` |
43
+ | Clone guard: instruction files | `CLAUDE.md` | `AGENTS.md`, `AGENTS.override.md` | `GEMINI.md` | `.cursor/rules/*.mdc`, `.cursorrules`, `AGENTS.md` | Windsurf, Cline, Copilot files |
44
+ | 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` |
45
+ | 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 |
46
+
47
+ - **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.
48
+ - 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.
49
+ - **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.
50
+ - **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.
51
+
52
+ ## Clone guard: protect yourself from repos you pull in
53
+
54
+ ```
55
+ ezco clone https://github.com/someone/repo
56
+ ```
57
+
58
+ 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.
59
+
60
+ `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.
61
+
62
+ - Already cloned? `ezco guard path/to/repo` does the same check (`--no-quarantine` to only report).
63
+ - `--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.
64
+ - `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.
65
+ - A hardcoded key in a cloned agent file is also a BLOCK, so that file gets quarantined too.
66
+ - 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.
67
+ - 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.
68
+ - `ezco uninstall` removes the commit hook, the post-merge hook and the agent gate.
69
+
70
+ **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`.)
71
+
72
+ **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.
73
+
74
+ **False alarm? Three ways out:**
75
+
76
+ | Way | Works in | Example |
77
+ |---|---|---|
78
+ | `ezco:ignore` anywhere on the line | any file with comments (`.py`, `.js`, `.env`, `.yaml`, `requirements.txt`, Markdown via `<!-- ezco:ignore -->`) | `KEY = load() # ezco:ignore` |
79
+ | `.ezcoignore` file in the repo root | any file, incl. JSON (no comments allowed there) | `demo/` or `*.min.js` |
80
+ | skip once | the whole commit | `git commit --no-verify` |
81
+
82
+ - **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`.
83
+
84
+ `BLOCK` stops the commit. `WARN` is printed but lets it through.
85
+
86
+ ## Try the demo
87
+
88
+ ```
89
+ python -m ezco scan demo
90
+ ```
91
+
92
+ `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.
93
+
94
+ ## Run tests
95
+
96
+ ```
97
+ python -m unittest discover -s tests
98
+ ```
99
+
100
+ ## How it compares (honest table)
101
+
102
+ 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**.
103
+
104
+ | 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) |
105
+ |---|---|---|---|---|---|---|
106
+ | 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 |
107
+ | Typos of popular packages | Yes | Not stated | Yes | No | Yes | No |
108
+ | Leaked secrets | Yes | Yes | Yes | Yes (the most mature here) | No | No (reads env var names only) |
109
+ | Exact revoke steps per key | Yes | Not stated | Not stated | Not stated | No | No |
110
+ | 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 |
111
+ | MCP config check | Yes | Secrets only | Yes | No | No | Lists servers only |
112
+ | Pre-commit hook | Yes | Yes | Yes | Yes | No | No |
113
+ | 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 |
114
+ | Checks `.claude/settings.json` hook commands | Yes | Secrets only | Partly (SessionStart hook injection) | No | No | Yes, lists them |
115
+ | 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" |
116
+ | Optional LLM review | Yes, Groq, secrets redacted, can only add warnings | Yes, Gemini | No | No | No | No |
117
+
118
+ **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.
119
+
120
+ **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).
121
+
122
+ ## Limits (honest list)
123
+
124
+ - Secret detection uses patterns. Unusual secret formats are missed, and deep-mode redaction only hides what the patterns catch.
125
+ - 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.
126
+ - If PyPI/npm can't be reached, unknown packages get a WARN, not a BLOCK, so a network hiccup never stops your work.
127
+ - 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`.
128
+ - 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.
129
+
130
+ ## Test results (Nov 27, 2026)
131
+
132
+ - **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).
133
+ - **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`.
134
+ - **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.
135
+ - **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.
136
+ - **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.
137
+ - **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.
138
+ - **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.
139
+
140
+ See `AI_USAGE.md` for every tool, API and dataset used.
141
+
142
+ ## Maintainers: publishing to PyPI
143
+
144
+ Releases use PyPI Trusted Publishing (`.github/workflows/release.yml`). No API token is stored anywhere. It runs only when a `v*` tag is pushed.
145
+
146
+ 1. Create an account at pypi.org/account/register and turn on 2FA (PyPI requires it).
147
+ 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`.
148
+ 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.)
149
+ 4. Make sure `version` in `pyproject.toml` is the version you want, commit and push.
150
+ 5. Tag and push: `git tag v0.1.0` then `git push origin v0.1.0`.
151
+ 6. Watch the Actions tab. When the `release` job is green, the package is on pypi.org/project/ezco.
152
+
153
+ A version number can be published only once. For a fix, bump `version` and push a new tag.
154
+
155
+ ## License
156
+
157
+ MIT. See [LICENSE](LICENSE).
File without changes
@@ -0,0 +1,5 @@
1
+ import sys
2
+
3
+ from ezco.cli import main
4
+
5
+ sys.exit(main())
ezco-0.1.0/ezco/cli.py ADDED
@@ -0,0 +1,186 @@
1
+ """Command line: `ezco scan <files or folders>`, `ezco install`, `ezco uninstall`.
2
+ `ezco hook` is what git runs before each commit."""
3
+
4
+ import argparse
5
+ import os
6
+ import re
7
+ import sys
8
+ from pathlib import Path
9
+
10
+ from ezco import clone, deep, gate, hook, leaks, mcp_check, packages
11
+
12
+ ENV_FILE = re.compile(r"^\.env(\.(?!example$|sample$|template$)[\w.-]+)?$") # .env, .env.local; not .env.example
13
+ SKIP_DIRS = {".git", "node_modules", ".venv", "venv", "env", "__pycache__", "dist", "build", ".next"}
14
+
15
+
16
+ def is_dependency_file(path):
17
+ name = Path(path).name
18
+ return name in ("package.json", "pyproject.toml") or (name.startswith("requirements") and name.endswith(".txt"))
19
+
20
+
21
+ def dependencies_in(path, text):
22
+ """Return (name, ecosystem) pairs from a dependency file, or [] for other files."""
23
+ name = Path(path).name
24
+ if not is_dependency_file(path):
25
+ return []
26
+ text = text.lstrip("\ufeff") # PowerShell 5.1 and Notepad add a BOM; it broke the first name and all of JSON
27
+ if name.endswith(".txt"):
28
+ return [(n, "pypi") for n in packages.parse_requirements(text)]
29
+ try:
30
+ if name == "pyproject.toml":
31
+ return [(n, "pypi") for n in packages.parse_pyproject(text)]
32
+ return [(n, "npm") for n in packages.parse_package_json(text)]
33
+ except (ValueError, AttributeError):
34
+ return [] # empty or broken file: pip/npm itself will complain about that
35
+
36
+
37
+ def text_checks(lines, path, full_text):
38
+ return leaks.scan_lines(lines, path) + mcp_check.scan_lines(lines, path, full_text)
39
+
40
+
41
+ def walk(paths, ignore):
42
+ """Yield every file under the given files/folders, skipping junk folders and .ezcoignore."""
43
+ for p in paths:
44
+ if os.path.isdir(p):
45
+ # a folder you name yourself is always scanned, even if .ezcoignore lists it
46
+ rules = [] if hook.is_ignored(os.path.join(p, "x"), ignore) else ignore
47
+ for root, dirs, files in os.walk(p):
48
+ dirs[:] = [d for d in dirs if d not in SKIP_DIRS]
49
+ for f in files:
50
+ full = os.path.relpath(os.path.join(root, f))
51
+ if not hook.is_ignored(full, rules):
52
+ yield full
53
+ else:
54
+ yield p # a file you name yourself is always scanned
55
+
56
+
57
+ def scan(paths):
58
+ """Check whole files on disk. Returns (findings, deps, text for --deep)."""
59
+ findings, deps, review = [], [], []
60
+ for path in walk(paths, hook.ignore_patterns()):
61
+ try:
62
+ text = Path(path).read_text(encoding="utf-8")
63
+ except (UnicodeDecodeError, OSError):
64
+ continue # binary or unreadable file
65
+ findings += text_checks(list(enumerate(text.splitlines(), start=1)), path, text) # list: both checks read it
66
+ deps += dependencies_in(path, text)
67
+ if mcp_check.is_mcp_config(path):
68
+ config_findings, config_deps = mcp_check.check_config(path, text)
69
+ findings += config_findings
70
+ deps += config_deps
71
+ review.append(f"### {path}\n{text}")
72
+ return findings, deps, "\n".join(review)
73
+
74
+
75
+ def staged():
76
+ """Check only what this commit adds. Returns (findings, deps, text for --deep)."""
77
+ ignore = hook.ignore_patterns()
78
+ findings, deps, review = [], [], []
79
+ for path, lines in hook.added_lines().items():
80
+ if hook.is_ignored(path, ignore):
81
+ continue
82
+ findings += text_checks(lines, path, hook.staged_text(path))
83
+ review.append(f"### {path}\n" + "\n".join(f"{n}: {t}" for n, t in lines))
84
+ for path in hook.staged_files():
85
+ if hook.is_ignored(path, ignore):
86
+ continue
87
+ if ENV_FILE.match(Path(path).name):
88
+ findings.append({"severity": "WARN", "where": path,
89
+ "reason": ".env files hold secrets and shouldn't be committed. Add .env to "
90
+ f".gitignore and run: git rm --cached \"{path}\""})
91
+ if is_dependency_file(path): # only packages this commit ADDS, so old ones aren't re-checked
92
+ old = set(dependencies_in(path, hook.head_text(path)))
93
+ deps += [d for d in dependencies_in(path, hook.staged_text(path)) if d not in old]
94
+ if mcp_check.is_mcp_config(path):
95
+ config_findings, config_deps = mcp_check.check_config(path, hook.staged_text(path))
96
+ findings += config_findings
97
+ deps += config_deps
98
+ return findings, deps, "\n".join(review)
99
+
100
+
101
+ def print_report(findings, notes, in_hook):
102
+ if not findings:
103
+ print("ezco: all clear")
104
+ for f in findings:
105
+ print(f"[{f['severity']}] {f['where']}: {f['reason']}")
106
+ if "fix" in f:
107
+ if f["fix"]["url"]:
108
+ print(f" revoke at: {f['fix']['url']}")
109
+ print(f" {f['fix']['steps']}")
110
+ for note in notes:
111
+ print(f"note: {note}")
112
+ blocks = sum(f["severity"] == "BLOCK" for f in findings)
113
+ if blocks:
114
+ print(f"\n{len(findings)} problem(s), {blocks} blocking")
115
+ elif findings:
116
+ print(f"\n{len(findings)} warning(s), nothing blocking" + (" - commit allowed" if in_hook else ""))
117
+ if blocks and in_hook:
118
+ print("Commit blocked. Fix the BLOCK items above, or if one is a false alarm:\n"
119
+ " - add '# ezco:ignore' to that line, or add the path to .ezcoignore\n"
120
+ " - skip the check once: git commit --no-verify")
121
+
122
+
123
+ def main(argv=None):
124
+ sys.stdout.reconfigure(errors="backslashreplace") # odd filenames must never crash the report
125
+ parser = argparse.ArgumentParser(prog="ezco", description="Security guard for AI-written commits")
126
+ # metavar + no help= on `hook`/`agent-hook`: git and Claude Code run those, people don't, so --help hides them
127
+ sub = parser.add_subparsers(dest="command", required=True, metavar="{scan,install,uninstall,clone,guard}")
128
+ scan_cmd = sub.add_parser("scan", help="scan files or folders now")
129
+ scan_cmd.add_argument("paths", nargs="*", default=["."])
130
+ scan_cmd.add_argument("--deep", action="store_true", help="also ask an LLM (needs GROQ_API_KEY)")
131
+ hook_cmd = sub.add_parser("hook") # what git runs before each commit
132
+ hook_cmd.add_argument("--deep", action="store_true")
133
+ install_cmd = sub.add_parser("install", help="turn on the check for every commit in this repo")
134
+ install_cmd.add_argument("--force", action="store_true", help="replace an existing pre-commit hook")
135
+ install_cmd.add_argument("--agent", nargs="?", const="claude", choices=[*gate.HARNESSES, "all"],
136
+ help="also check an AI agent's package installs before they run "
137
+ "(claude by default; codex, gemini or all)")
138
+ sub.add_parser("uninstall", help="remove every ezco hook from this repo")
139
+ agent_cmd = sub.add_parser("agent-hook") # what the agent runs before each shell command
140
+ agent_cmd.add_argument("--for", dest="harness", choices=list(gate.HARNESSES), default="claude")
141
+ deep_help = "also ask an LLM; its hits quarantine too (needs GROQ_API_KEY)"
142
+ clone_cmd = sub.add_parser("clone", help="git clone, then quarantine dangerous AI-agent files before you open it")
143
+ clone_cmd.add_argument("url")
144
+ clone_cmd.add_argument("folder", nargs="?")
145
+ clone_cmd.add_argument("--deep", action="store_true", help=deep_help)
146
+ guard_cmd = sub.add_parser("guard", help="check a folder's AI-agent files (CLAUDE.md, .cursorrules, hooks...)")
147
+ guard_cmd.add_argument("folder", nargs="?", default=".")
148
+ guard_cmd.add_argument("--no-quarantine", action="store_true", help="only report, don't rename files")
149
+ guard_cmd.add_argument("--deep", action="store_true", help=deep_help)
150
+ args = parser.parse_args(argv)
151
+
152
+ if args.command == "agent-hook":
153
+ return gate.agent_hook(harness=args.harness)
154
+ if args.command == "clone":
155
+ return clone.clone(args.url, args.folder, use_deep=args.deep)
156
+ if args.command == "guard":
157
+ if not os.path.isdir(args.folder):
158
+ print(f"ezco: no folder called {args.folder}")
159
+ return 2
160
+ return 1 if clone.guard(args.folder, quarantine=not args.no_quarantine, use_deep=args.deep) else 0
161
+ if args.command == "install":
162
+ result = hook.install(args.force) or 0
163
+ for harness in (gate.HARNESSES if args.agent == "all" else [args.agent] if args.agent else []):
164
+ gate.install_agent(harness=harness)
165
+ return result
166
+ if args.command == "uninstall":
167
+ for harness in gate.HARNESSES:
168
+ gate.uninstall_agent(harness=harness)
169
+ return hook.uninstall() or 0
170
+
171
+ in_hook = args.command == "hook"
172
+ findings, deps, review_text = staged() if in_hook else scan(args.paths)
173
+ findings += packages.check_packages(sorted(set(deps)))
174
+ notes = []
175
+ # git can't pass flags to a hook, so deep mode in a commit is turned on with EZCO_DEEP=1
176
+ if (args.deep or os.environ.get("EZCO_DEEP") == "1") and review_text:
177
+ deep_findings, note = deep.review(review_text)
178
+ findings += deep_findings
179
+ notes.append(note)
180
+ print_report(findings, notes, in_hook)
181
+ # exit code 1 tells git to stop the commit
182
+ return 1 if any(f["severity"] == "BLOCK" for f in findings) else 0
183
+
184
+
185
+ if __name__ == "__main__":
186
+ sys.exit(main())