realdep 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.
Files changed (37) hide show
  1. realdep-0.1.0/.gitignore +19 -0
  2. realdep-0.1.0/CHANGELOG.md +20 -0
  3. realdep-0.1.0/LICENSE +202 -0
  4. realdep-0.1.0/NOTICE +7 -0
  5. realdep-0.1.0/PKG-INFO +189 -0
  6. realdep-0.1.0/README.md +159 -0
  7. realdep-0.1.0/SECURITY.md +27 -0
  8. realdep-0.1.0/docs/ci.md +33 -0
  9. realdep-0.1.0/docs/configuration.md +26 -0
  10. realdep-0.1.0/docs/faq.md +22 -0
  11. realdep-0.1.0/docs/getting-started.md +51 -0
  12. realdep-0.1.0/docs/hooks.md +54 -0
  13. realdep-0.1.0/docs/rules.md +32 -0
  14. realdep-0.1.0/docs/threat-model.md +33 -0
  15. realdep-0.1.0/examples/github-workflow.yml +15 -0
  16. realdep-0.1.0/examples/realdep.json +8 -0
  17. realdep-0.1.0/pyproject.toml +63 -0
  18. realdep-0.1.0/skills/realdep/SKILL.md +40 -0
  19. realdep-0.1.0/src/realdep/__init__.py +9 -0
  20. realdep-0.1.0/src/realdep/__main__.py +5 -0
  21. realdep-0.1.0/src/realdep/_version.py +1 -0
  22. realdep-0.1.0/src/realdep/checker.py +104 -0
  23. realdep-0.1.0/src/realdep/cli.py +166 -0
  24. realdep-0.1.0/src/realdep/config.py +91 -0
  25. realdep-0.1.0/src/realdep/data/__init__.py +0 -0
  26. realdep-0.1.0/src/realdep/data/popular.json +1 -0
  27. realdep-0.1.0/src/realdep/hooks.py +165 -0
  28. realdep-0.1.0/src/realdep/names.py +137 -0
  29. realdep-0.1.0/src/realdep/parse.py +526 -0
  30. realdep-0.1.0/src/realdep/policy.py +143 -0
  31. realdep-0.1.0/src/realdep/py.typed +0 -0
  32. realdep-0.1.0/src/realdep/registry.py +274 -0
  33. realdep-0.1.0/tests/__init__.py +0 -0
  34. realdep-0.1.0/tests/conftest.py +62 -0
  35. realdep-0.1.0/tests/test_hooks_cli.py +121 -0
  36. realdep-0.1.0/tests/test_parse.py +108 -0
  37. realdep-0.1.0/tests/test_policy.py +110 -0
@@ -0,0 +1,19 @@
1
+ __pycache__/
2
+ *.py[cod]
3
+ *.egg-info/
4
+ build/
5
+ dist/
6
+ .venv/
7
+ venv/
8
+ .pytest_cache/
9
+ .ruff_cache/
10
+ .coverage
11
+ *.sarif
12
+ .env
13
+ .env.*
14
+ *.key
15
+ *.pem
16
+ .vscode/
17
+ .idea/
18
+ .DS_Store
19
+ Thumbs.db
@@ -0,0 +1,20 @@
1
+ # Changelog
2
+
3
+ All notable changes are documented here. The format follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/)
4
+ and the project uses [Semantic Versioning](https://semver.org/).
5
+
6
+ ## [0.1.0] - 2026-12-02
7
+
8
+ ### Added
9
+
10
+ - Command parsing for pip, uv, uvx, poetry, pipenv, pdm, rye, pipx, npm, npx, yarn, pnpm, bun, bunx,
11
+ cargo, go and gem, including chained commands, aliases and `-r` requirement files.
12
+ - Manifest parsing for requirements files, pyproject.toml, package.json, Cargo.toml, go.mod and Gemfile,
13
+ with added-dependency diffing for agent edits.
14
+ - Registry checks against PyPI, npm, crates.io, the Go module proxy and RubyGems (existence, age,
15
+ releases, downloads, install scripts, deprecation), cached for 24 hours.
16
+ - Verdicts: hallucinated names, typosquats, the slopsquatting profile, brand-new packages, import-name
17
+ confusion, dependency-confusion flags, with "did you mean" suggestions.
18
+ - Bundled popularity lists (5,000 PyPI, 6,000 npm, 500 crates) for offline fast paths.
19
+ - `realdep hook` (pre-tool-use, exit 2 blocks), `check`, `pkg`, `scan`, JSON output, GitHub Action.
20
+ - Agent skill (`skills/realdep`).
realdep-0.1.0/LICENSE ADDED
@@ -0,0 +1,202 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright [yyyy] [name of copyright owner]
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
realdep-0.1.0/NOTICE ADDED
@@ -0,0 +1,7 @@
1
+ Realdep
2
+ Copyright 2026 Prayash Bikram Shah
3
+
4
+ Bundled popularity data (src/realdep/data/popular.json) is derived from:
5
+ - top-pypi-packages by Hugo van Kemenade (https://github.com/hugovk/top-pypi-packages)
6
+ - npm-high-impact by Titus Wormer (https://github.com/wooorm/npm-high-impact), MIT License
7
+ - the public crates.io API (https://crates.io)
realdep-0.1.0/PKG-INFO ADDED
@@ -0,0 +1,189 @@
1
+ Metadata-Version: 2.5
2
+ Name: realdep
3
+ Version: 0.1.0
4
+ Summary: Stop AI coding agents from installing hallucinated, typo-squatted or brand-new malicious packages (slopsquatting). Checks pip, uv, poetry, npm, yarn, pnpm, bun, cargo, go and gem installs and manifest edits.
5
+ Project-URL: Homepage, https://github.com/shah2017/realdep
6
+ Project-URL: Documentation, https://github.com/shah2017/realdep/tree/main/docs
7
+ Project-URL: Issues, https://github.com/shah2017/realdep/issues
8
+ Project-URL: Security, https://github.com/shah2017/realdep/security/policy
9
+ Author: Prayash Bikram Shah
10
+ License-Expression: Apache-2.0
11
+ License-File: LICENSE
12
+ License-File: NOTICE
13
+ Keywords: agents,ai-security,dependency-confusion,npm,pypi,slopsquatting,supply-chain,typosquatting
14
+ Classifier: Development Status :: 3 - Alpha
15
+ Classifier: Intended Audience :: Developers
16
+ Classifier: Intended Audience :: Information Technology
17
+ Classifier: Operating System :: OS Independent
18
+ Classifier: Programming Language :: Python :: 3
19
+ Classifier: Programming Language :: Python :: 3 :: Only
20
+ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
21
+ Classifier: Topic :: Security
22
+ Classifier: Typing :: Typed
23
+ Requires-Python: >=3.11
24
+ Provides-Extra: dev
25
+ Requires-Dist: build>=1.2; extra == 'dev'
26
+ Requires-Dist: pip-audit>=2.7; extra == 'dev'
27
+ Requires-Dist: pytest>=8; extra == 'dev'
28
+ Requires-Dist: ruff>=0.6; extra == 'dev'
29
+ Description-Content-Type: text/markdown
30
+
31
+ # Realdep
32
+
33
+ **Stop AI coding agents from installing packages that don't exist, or shouldn't.** Realdep checks every
34
+ package an agent tries to install (or add to a manifest) against the real registry before it happens,
35
+ and blocks hallucinated names, typosquats and freshly registered slopsquats, telling the agent the name
36
+ it probably meant.
37
+
38
+ [![CI](https://github.com/shah2017/realdep/actions/workflows/ci.yml/badge.svg)](https://github.com/shah2017/realdep/actions/workflows/ci.yml)
39
+ ![Python](https://img.shields.io/badge/python-3.11%E2%80%933.14-blue)
40
+ ![License](https://img.shields.io/badge/license-Apache%202.0-green)
41
+ ![Dependencies](https://img.shields.io/badge/runtime%20dependencies-0-brightgreen)
42
+
43
+ ---
44
+
45
+ ## The problem: slopsquatting
46
+
47
+ Language models regularly invent package names that sound right but don't exist: `huggingface-cli-tools`,
48
+ `react-codeshift`, `flask-jwt-simple-auth`. Attackers watch for those names, register them on PyPI or
49
+ npm, and fill them with malware. The next agent that hallucinates the same name runs
50
+ `pip install <name>` and executes the attacker's code with your permissions. This is called
51
+ **slopsquatting**.
52
+
53
+ Classic typosquats (`reqeusts`, `expresss`) and import-name confusion (`pip install sklearn`, which
54
+ should be `scikit-learn`) hit agents the same way, because agents type fast and never double-check.
55
+
56
+ ## What Realdep does
57
+
58
+ Before an install runs, Realdep:
59
+
60
+ 1. **Parses** the command or manifest change: `pip`, `uv`, `poetry`, `pipenv`, `pdm`, `pipx`, `uvx`, `npm`,
61
+ `npx`, `yarn`, `pnpm`, `bun`, `cargo`, `go`, `gem`; requirement files passed with `-r`; and edits to
62
+ `requirements.txt`, `pyproject.toml`, `package.json`, `Cargo.toml`, `go.mod` and `Gemfile`.
63
+ 2. **Skips** the thousands of packages everyone uses (bundled popularity lists, no network needed).
64
+ 3. **Asks the real registry** about everything else: does it exist, when was it first published, how many
65
+ releases, how many downloads, does it run install scripts?
66
+ 4. **Decides:**
67
+
68
+ | Verdict | When |
69
+ |---|---|
70
+ | **Block** | The name does not exist (hallucinated) · it is one or two characters from a popular package and not heavily used itself (typosquat) · first published in the last 7 days · new, 1-2 releases and almost no downloads (the slopsquatting profile) · on your deny list |
71
+ | **Warn** | Import name instead of package name (`sklearn`, `cv2`, `yaml`, `bs4`…) · published in the last 30 days · very little use · install scripts · deprecated · placeholder version · git/URL/path installs · custom index or `--extra-index-url` (dependency confusion) |
72
+ | **Allow** | Everything else |
73
+
74
+ 5. **Tells the agent how to fix it.** A block comes with the reason and the likely intended name, so the
75
+ agent corrects itself instead of retrying:
76
+
77
+ ```
78
+ $ realdep check -- pip install fastapi reqeusts sklearn
79
+ BLOCK pypi reqeusts
80
+ 'reqeusts' does not exist on PyPI; it may be a hallucinated name. Did you mean 'requests'?
81
+ suggestion: requests
82
+ WARN pypi sklearn
83
+ 'sklearn' is an import name; the package that provides it is 'scikit-learn'
84
+ suggestion: scikit-learn
85
+ ok pypi fastapi
86
+ widely used (top 63 on PyPI)
87
+ ```
88
+
89
+ ```
90
+ $ realdep pkg npm react-codeshift expresss
91
+ BLOCK npm react-codeshift
92
+ matches the slopsquatting profile: first published 321 day(s) ago, 1 release(s), 15 downloads last week
93
+ BLOCK npm expresss
94
+ name is one or two characters away from the popular package 'express' (possible typosquat)
95
+ only release is a placeholder version (0.0.0)
96
+ suggestion: express
97
+ ```
98
+
99
+ ## Install
100
+
101
+ ```bash
102
+ pip install git+https://github.com/shah2017/realdep
103
+ ```
104
+
105
+ Python 3.11+. **Zero runtime dependencies** (standard library only), because a supply-chain guard
106
+ should not widen your supply chain.
107
+
108
+ ## Use it
109
+
110
+ ### Guard a coding agent (recommended)
111
+
112
+ Agents that support command hooks before tool use can run Realdep on every shell command and file
113
+ edit:
114
+
115
+ ```bash
116
+ realdep hook --print-config
117
+ ```
118
+
119
+ ```json
120
+ {"hooks": {"PreToolUse": [{"matcher": "*", "hooks": [{"type": "command", "command": "realdep hook", "timeout": 30}]}]}}
121
+ ```
122
+
123
+ Merge that into your agent's hooks settings. Blocked installs exit with code 2 and a reason the agent
124
+ reads, and warnings appear as a system message. Unrelated commands pass in milliseconds with no network.
125
+ See [docs/hooks.md](docs/hooks.md).
126
+
127
+ ### Check by hand
128
+
129
+ ```bash
130
+ realdep check -- npm i some-package # exit 3 if anything is blocked
131
+ realdep pkg pypi requests reqeusts # check names directly
132
+ realdep check --strict -- pip install x # exit 3 on warnings too
133
+ ```
134
+
135
+ ### CI
136
+
137
+ ```bash
138
+ realdep scan requirements.txt package.json pyproject.toml # exit 3 on any block
139
+ ```
140
+
141
+ Catch hallucinated dependencies that slipped into a pull request. See [docs/ci.md](docs/ci.md).
142
+
143
+ ## Coverage
144
+
145
+ | Ecosystem | Commands | Manifests | Registry checks |
146
+ |---|---|---|---|
147
+ | Python | pip, pip3, `python -m pip`, uv (pip/add/tool), uvx, poetry, pipenv, pdm, rye, pipx | requirements*.txt/.in, pyproject.toml (PEP 621, Poetry, dependency groups) | PyPI JSON API, pypistats |
148
+ | JavaScript | npm (install/exec), npx, yarn, pnpm, bun, bunx | package.json | npm registry, npm downloads API |
149
+ | Rust | cargo add/install | Cargo.toml | crates.io |
150
+ | Go | go get/install | go.mod | Go module proxy |
151
+ | Ruby | gem install | Gemfile | RubyGems |
152
+
153
+ ## How it compares
154
+
155
+ | | Package auditors (npm audit, Socket, pip-audit) | Other slopsquatting CLIs | **Realdep** |
156
+ |---|---|---|---|
157
+ | Runs *before* the agent installs | no (after, or in CI) | yes | **yes** |
158
+ | Ecosystems | one or several | usually one | **5** |
159
+ | Install commands **and** manifest edits | manifests | commands | **both** |
160
+ | Tells the agent the intended name | no | rarely | **yes** |
161
+ | Import-name confusion (`sklearn`, `cv2`) | no | no | **yes** |
162
+ | Works offline for popular packages | n/a | no | **yes** |
163
+ | Runtime dependencies | many | some | **0** |
164
+
165
+ Use Realdep alongside dependency auditing: it stops bad names from getting in, and auditors find
166
+ vulnerabilities in the good ones.
167
+
168
+ ## Documentation
169
+
170
+ [Getting started](docs/getting-started.md) · [Decision rules](docs/rules.md) · [Agent hooks](docs/hooks.md) ·
171
+ [CI](docs/ci.md) · [Configuration](docs/configuration.md) · [Threat model](docs/threat-model.md) · [FAQ](docs/faq.md)
172
+
173
+ ## Limitations
174
+
175
+ - An old, popular, *legitimate-looking* package that turns malicious is a different problem; use a
176
+ vulnerability and malware scanner for that.
177
+ - Decisions use public registry metadata and heuristics. Tune thresholds and keep allow/deny lists in
178
+ `.realdep.json`.
179
+ - Private registries and custom indexes are flagged, not verified.
180
+ - If the registry is unreachable, Realdep warns and allows by default (`fail_closed` changes that).
181
+
182
+ ## Security
183
+
184
+ Report vulnerabilities privately: see [SECURITY.md](SECURITY.md).
185
+
186
+ ## License
187
+
188
+ [Apache License 2.0](LICENSE). Copyright 2026 Prayash Bikram Shah. Bundled popularity data is credited
189
+ in [NOTICE](NOTICE).
@@ -0,0 +1,159 @@
1
+ # Realdep
2
+
3
+ **Stop AI coding agents from installing packages that don't exist, or shouldn't.** Realdep checks every
4
+ package an agent tries to install (or add to a manifest) against the real registry before it happens,
5
+ and blocks hallucinated names, typosquats and freshly registered slopsquats, telling the agent the name
6
+ it probably meant.
7
+
8
+ [![CI](https://github.com/shah2017/realdep/actions/workflows/ci.yml/badge.svg)](https://github.com/shah2017/realdep/actions/workflows/ci.yml)
9
+ ![Python](https://img.shields.io/badge/python-3.11%E2%80%933.14-blue)
10
+ ![License](https://img.shields.io/badge/license-Apache%202.0-green)
11
+ ![Dependencies](https://img.shields.io/badge/runtime%20dependencies-0-brightgreen)
12
+
13
+ ---
14
+
15
+ ## The problem: slopsquatting
16
+
17
+ Language models regularly invent package names that sound right but don't exist: `huggingface-cli-tools`,
18
+ `react-codeshift`, `flask-jwt-simple-auth`. Attackers watch for those names, register them on PyPI or
19
+ npm, and fill them with malware. The next agent that hallucinates the same name runs
20
+ `pip install <name>` and executes the attacker's code with your permissions. This is called
21
+ **slopsquatting**.
22
+
23
+ Classic typosquats (`reqeusts`, `expresss`) and import-name confusion (`pip install sklearn`, which
24
+ should be `scikit-learn`) hit agents the same way, because agents type fast and never double-check.
25
+
26
+ ## What Realdep does
27
+
28
+ Before an install runs, Realdep:
29
+
30
+ 1. **Parses** the command or manifest change: `pip`, `uv`, `poetry`, `pipenv`, `pdm`, `pipx`, `uvx`, `npm`,
31
+ `npx`, `yarn`, `pnpm`, `bun`, `cargo`, `go`, `gem`; requirement files passed with `-r`; and edits to
32
+ `requirements.txt`, `pyproject.toml`, `package.json`, `Cargo.toml`, `go.mod` and `Gemfile`.
33
+ 2. **Skips** the thousands of packages everyone uses (bundled popularity lists, no network needed).
34
+ 3. **Asks the real registry** about everything else: does it exist, when was it first published, how many
35
+ releases, how many downloads, does it run install scripts?
36
+ 4. **Decides:**
37
+
38
+ | Verdict | When |
39
+ |---|---|
40
+ | **Block** | The name does not exist (hallucinated) · it is one or two characters from a popular package and not heavily used itself (typosquat) · first published in the last 7 days · new, 1-2 releases and almost no downloads (the slopsquatting profile) · on your deny list |
41
+ | **Warn** | Import name instead of package name (`sklearn`, `cv2`, `yaml`, `bs4`…) · published in the last 30 days · very little use · install scripts · deprecated · placeholder version · git/URL/path installs · custom index or `--extra-index-url` (dependency confusion) |
42
+ | **Allow** | Everything else |
43
+
44
+ 5. **Tells the agent how to fix it.** A block comes with the reason and the likely intended name, so the
45
+ agent corrects itself instead of retrying:
46
+
47
+ ```
48
+ $ realdep check -- pip install fastapi reqeusts sklearn
49
+ BLOCK pypi reqeusts
50
+ 'reqeusts' does not exist on PyPI; it may be a hallucinated name. Did you mean 'requests'?
51
+ suggestion: requests
52
+ WARN pypi sklearn
53
+ 'sklearn' is an import name; the package that provides it is 'scikit-learn'
54
+ suggestion: scikit-learn
55
+ ok pypi fastapi
56
+ widely used (top 63 on PyPI)
57
+ ```
58
+
59
+ ```
60
+ $ realdep pkg npm react-codeshift expresss
61
+ BLOCK npm react-codeshift
62
+ matches the slopsquatting profile: first published 321 day(s) ago, 1 release(s), 15 downloads last week
63
+ BLOCK npm expresss
64
+ name is one or two characters away from the popular package 'express' (possible typosquat)
65
+ only release is a placeholder version (0.0.0)
66
+ suggestion: express
67
+ ```
68
+
69
+ ## Install
70
+
71
+ ```bash
72
+ pip install git+https://github.com/shah2017/realdep
73
+ ```
74
+
75
+ Python 3.11+. **Zero runtime dependencies** (standard library only), because a supply-chain guard
76
+ should not widen your supply chain.
77
+
78
+ ## Use it
79
+
80
+ ### Guard a coding agent (recommended)
81
+
82
+ Agents that support command hooks before tool use can run Realdep on every shell command and file
83
+ edit:
84
+
85
+ ```bash
86
+ realdep hook --print-config
87
+ ```
88
+
89
+ ```json
90
+ {"hooks": {"PreToolUse": [{"matcher": "*", "hooks": [{"type": "command", "command": "realdep hook", "timeout": 30}]}]}}
91
+ ```
92
+
93
+ Merge that into your agent's hooks settings. Blocked installs exit with code 2 and a reason the agent
94
+ reads, and warnings appear as a system message. Unrelated commands pass in milliseconds with no network.
95
+ See [docs/hooks.md](docs/hooks.md).
96
+
97
+ ### Check by hand
98
+
99
+ ```bash
100
+ realdep check -- npm i some-package # exit 3 if anything is blocked
101
+ realdep pkg pypi requests reqeusts # check names directly
102
+ realdep check --strict -- pip install x # exit 3 on warnings too
103
+ ```
104
+
105
+ ### CI
106
+
107
+ ```bash
108
+ realdep scan requirements.txt package.json pyproject.toml # exit 3 on any block
109
+ ```
110
+
111
+ Catch hallucinated dependencies that slipped into a pull request. See [docs/ci.md](docs/ci.md).
112
+
113
+ ## Coverage
114
+
115
+ | Ecosystem | Commands | Manifests | Registry checks |
116
+ |---|---|---|---|
117
+ | Python | pip, pip3, `python -m pip`, uv (pip/add/tool), uvx, poetry, pipenv, pdm, rye, pipx | requirements*.txt/.in, pyproject.toml (PEP 621, Poetry, dependency groups) | PyPI JSON API, pypistats |
118
+ | JavaScript | npm (install/exec), npx, yarn, pnpm, bun, bunx | package.json | npm registry, npm downloads API |
119
+ | Rust | cargo add/install | Cargo.toml | crates.io |
120
+ | Go | go get/install | go.mod | Go module proxy |
121
+ | Ruby | gem install | Gemfile | RubyGems |
122
+
123
+ ## How it compares
124
+
125
+ | | Package auditors (npm audit, Socket, pip-audit) | Other slopsquatting CLIs | **Realdep** |
126
+ |---|---|---|---|
127
+ | Runs *before* the agent installs | no (after, or in CI) | yes | **yes** |
128
+ | Ecosystems | one or several | usually one | **5** |
129
+ | Install commands **and** manifest edits | manifests | commands | **both** |
130
+ | Tells the agent the intended name | no | rarely | **yes** |
131
+ | Import-name confusion (`sklearn`, `cv2`) | no | no | **yes** |
132
+ | Works offline for popular packages | n/a | no | **yes** |
133
+ | Runtime dependencies | many | some | **0** |
134
+
135
+ Use Realdep alongside dependency auditing: it stops bad names from getting in, and auditors find
136
+ vulnerabilities in the good ones.
137
+
138
+ ## Documentation
139
+
140
+ [Getting started](docs/getting-started.md) · [Decision rules](docs/rules.md) · [Agent hooks](docs/hooks.md) ·
141
+ [CI](docs/ci.md) · [Configuration](docs/configuration.md) · [Threat model](docs/threat-model.md) · [FAQ](docs/faq.md)
142
+
143
+ ## Limitations
144
+
145
+ - An old, popular, *legitimate-looking* package that turns malicious is a different problem; use a
146
+ vulnerability and malware scanner for that.
147
+ - Decisions use public registry metadata and heuristics. Tune thresholds and keep allow/deny lists in
148
+ `.realdep.json`.
149
+ - Private registries and custom indexes are flagged, not verified.
150
+ - If the registry is unreachable, Realdep warns and allows by default (`fail_closed` changes that).
151
+
152
+ ## Security
153
+
154
+ Report vulnerabilities privately: see [SECURITY.md](SECURITY.md).
155
+
156
+ ## License
157
+
158
+ [Apache License 2.0](LICENSE). Copyright 2026 Prayash Bikram Shah. Bundled popularity data is credited
159
+ in [NOTICE](NOTICE).
@@ -0,0 +1,27 @@
1
+ # Security policy
2
+
3
+ ## Reporting a vulnerability
4
+
5
+ **Do not open a public issue.** Report privately via **Security → Report a vulnerability**
6
+ (<https://github.com/shah2017/realdep/security/advisories/new>) with the affected version, impact and a
7
+ reproduction.
8
+
9
+ | Step | Target |
10
+ |---|---|
11
+ | Acknowledgement | 3 business days |
12
+ | Assessment | 7 days |
13
+ | Fix for critical/high issues | 30 days |
14
+
15
+ ## In scope
16
+
17
+ - Install commands or manifest edits that install a package without being checked (parser bypasses)
18
+ - Ways to make Realdep send local file contents or other data to a registry
19
+ - Requests to hosts other than the documented registries
20
+ - Super-linear processing of hostile input
21
+ - Terminal escape injection through package names
22
+ - Allow-listing by an attacker-controlled file outside the documented config locations
23
+
24
+ ## Out of scope
25
+
26
+ Documented limitations in [docs/threat-model.md](docs/threat-model.md), such as established packages that
27
+ turn malicious, or misjudgements that a threshold change in `.realdep.json` resolves.
@@ -0,0 +1,33 @@
1
+ # CI
2
+
3
+ `realdep scan` checks every dependency in the given manifests and exits 3 if anything is blocked
4
+ (or warned, with `--strict`).
5
+
6
+ ## GitHub Actions
7
+
8
+ ```yaml
9
+ name: dependencies
10
+ on: [pull_request]
11
+ permissions:
12
+ contents: read
13
+ jobs:
14
+ realdep:
15
+ runs-on: ubuntu-latest
16
+ steps:
17
+ - uses: actions/checkout@v4
18
+ with:
19
+ persist-credentials: false
20
+ - uses: shah2017/realdep@main
21
+ with:
22
+ files: requirements.txt package.json
23
+ ```
24
+
25
+ ## Anywhere else
26
+
27
+ ```bash
28
+ pip install git+https://github.com/shah2017/realdep
29
+ realdep scan requirements.txt pyproject.toml package.json --format json
30
+ ```
31
+
32
+ Large manifests: up to 50 packages per run are checked against the registry, so run it per manifest
33
+ for big projects. Popular packages never need a lookup.