safe-anything 0.0.0-stage → 1.0.1
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.
- package/LICENSE +21 -0
- package/README.md +209 -2
- package/bin/safe-anything.js +26 -0
- package/binaries/darwin-arm64/safe-anything +0 -0
- package/binaries/darwin-x64/safe-anything +0 -0
- package/binaries/linux-arm64/safe-anything +0 -0
- package/binaries/linux-x64/safe-anything +0 -0
- package/binaries/win32-x64/safe-anything.exe +0 -0
- package/package.json +31 -4
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Erkam Yaman (erkamyaman)
|
|
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.
|
package/README.md
CHANGED
|
@@ -1,3 +1,210 @@
|
|
|
1
|
-
|
|
1
|
+
<p align="center">
|
|
2
|
+
<img src="docs/assets/logo.png" width="150" height="150" alt="The safe-anything tortoise">
|
|
3
|
+
</p>
|
|
2
4
|
|
|
3
|
-
|
|
5
|
+
<h1 align="center">safe-anything</h1>
|
|
6
|
+
|
|
7
|
+
<p align="center"><b>Find the holes before someone else does.</b><br>
|
|
8
|
+
One command finds XSS, SQL injection and other vulnerabilities in your code, leaked secrets,<br>
|
|
9
|
+
risky mobile and cloud config, vulnerable dependencies, and the AI agent setup that writes it all.<br>
|
|
10
|
+
Every finding comes with the line, the reason and the fix.</p>
|
|
11
|
+
|
|
12
|
+
<p align="center">
|
|
13
|
+
<img src="https://img.shields.io/github/languages/top/erkamyaman/safe-anything?logo=rust&label=Rust&color=CE422B" alt="Rust share of the code">
|
|
14
|
+
<img src="https://img.shields.io/badge/macOS%20·%20Linux%20·%20Windows-native-2563EB" alt="Native binaries for macOS, Linux and Windows">
|
|
15
|
+
<a href="LICENSE"><img src="https://img.shields.io/badge/license-MIT-555" alt="MIT license"></a>
|
|
16
|
+
<a href="https://crates.io/crates/safe-anything"><img src="https://img.shields.io/crates/v/safe-anything?color=2FD48F&label=crates.io" alt="crates.io version"></a>
|
|
17
|
+
<a href="https://www.npmjs.com/package/safe-anything"><img src="https://img.shields.io/npm/v/safe-anything?color=2FD48F&label=npm" alt="npm version"></a>
|
|
18
|
+
<br>
|
|
19
|
+
<a href="https://coderabbit.link/erkamyaman"><img src="https://img.shields.io/coderabbit/prs/github/erkamyaman/safe-anything?labelColor=171717&color=FF570A&label=Reviewed+by+CodeRabbit" alt="Pull requests reviewed by CodeRabbit"></a>
|
|
20
|
+
<a href="https://github.com/erkamyaman/safe-anything"><img src="https://img.shields.io/github/stars/erkamyaman/safe-anything?style=social" alt="GitHub stars"></a>
|
|
21
|
+
</p>
|
|
22
|
+
|
|
23
|
+
<p align="center"><b><a href="#quick-start">Install</a></b> · <a href="https://github.com/erkamyaman/safe-anything/releases">Releases</a> · <a href="#for-ai-agents">Claude Code plugin</a> · <a href="#in-ci">GitHub Action</a> · <a href="docs/rules.md">All 72 rules</a> · <a href="docs/agent-setups.md">Agent setups</a><br>
|
|
24
|
+
Made in Türkiye 🇹🇷 by <a href="https://github.com/erkamyaman">erKam Yaman</a>, who also made <a href="https://github.com/erkamyaman/rust-anything">rust-anything</a> · <a href="https://github.com/sponsors/erkamyaman">❤️ Sponsor me</a> · Sponsored by <a href="https://coderabbit.link/erkamyaman">CodeRabbit</a></p>
|
|
25
|
+
|
|
26
|
+
<p align="center">
|
|
27
|
+
<img src="docs/assets/terminal.gif" alt="safe-anything scans OWASP Juice Shop: 1,195 files in 0.03 s, 67 findings including the SQL injection in routes/login.ts, eval in routes/userProfile.ts, seeded passwords and a token in localStorage. Then it scans an AI agent setup: a GitHub token in .mcp.json, bypassPermissions, pre-approved Bash, curl piped to sh in a hook, a skill that reads ~/.ssh, invisible Unicode, unpinned MCP servers." width="820">
|
|
28
|
+
<br>
|
|
29
|
+
<sub>A real run on <a href="https://github.com/juice-shop/juice-shop">OWASP Juice Shop</a> and on an agent setup with the usual mistakes (Apple M4). <a href="#measured">What it finds on other repositories</a>.</sub>
|
|
30
|
+
</p>
|
|
31
|
+
|
|
32
|
+
<table>
|
|
33
|
+
<tr>
|
|
34
|
+
<td width="25%" valign="top">
|
|
35
|
+
<b>Your code</b><br>
|
|
36
|
+
SQL and command injection, XSS, <code>eval</code>, SSRF, path traversal, unsafe deserialization, weak crypto. Nine languages and SQL.
|
|
37
|
+
</td>
|
|
38
|
+
<td width="25%" valign="top">
|
|
39
|
+
<b>Your secrets</b><br>
|
|
40
|
+
Cloud and AI keys, tokens, private keys, passwords, and <code>.env</code> mistakes: committed env files, real values in <code>.env.example</code>, secrets behind <code>NEXT_PUBLIC_</code> or <code>VITE_</code>. Always redacted in the output.
|
|
41
|
+
</td>
|
|
42
|
+
<td width="25%" valign="top">
|
|
43
|
+
<b>Your stack</b><br>
|
|
44
|
+
Android and iOS settings, Docker, GitHub Actions, Kubernetes, Terraform, nginx, and every locked dependency against OSV.dev.
|
|
45
|
+
</td>
|
|
46
|
+
<td width="25%" valign="top">
|
|
47
|
+
<b>Your agent</b><br>
|
|
48
|
+
MCP servers, Claude Code, Codex, Cursor, Gemini and OpenCode settings, hooks and skills: the files that decide what your agent may do.
|
|
49
|
+
</td>
|
|
50
|
+
</tr>
|
|
51
|
+
</table>
|
|
52
|
+
|
|
53
|
+
## Quick start
|
|
54
|
+
|
|
55
|
+
```bash
|
|
56
|
+
cargo install safe-anything # or: npx safe-anything .
|
|
57
|
+
safe-anything .
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
That's it. No config, no account, no upload. It exits with 1 when something high or critical is
|
|
61
|
+
found, so it works as a pre-commit or CI check as is.
|
|
62
|
+
|
|
63
|
+
```bash
|
|
64
|
+
safe-anything . --json # machine-readable report
|
|
65
|
+
safe-anything . --sarif # GitHub code scanning
|
|
66
|
+
safe-anything . --offline # no network (skips the dependency check)
|
|
67
|
+
safe-anything . --severity medium # hide low findings
|
|
68
|
+
safe-anything . --fail-on never # always exit 0 (or low, medium, high, critical)
|
|
69
|
+
safe-anything . --include-tests # also report findings in tests and fixtures
|
|
70
|
+
safe-anything --list-rules
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
- `.gitignore` is respected, and `node_modules`, `vendor`, `target`, `dist`, `build`, virtualenvs
|
|
74
|
+
and `.claude/worktrees` are skipped. List more paths in `.safe-anything-ignore`.
|
|
75
|
+
- `safe-anything:ignore` in a comment silences that line (or the next one).
|
|
76
|
+
- In tests, specs and fixtures only real provider keys and private keys count, unless you pass
|
|
77
|
+
`--include-tests`.
|
|
78
|
+
|
|
79
|
+
## What it finds
|
|
80
|
+
|
|
81
|
+
72 rules, each with a CWE id, an OWASP category and a link to the OWASP page that explains it.
|
|
82
|
+
The full list is in [docs/rules.md](docs/rules.md).
|
|
83
|
+
|
|
84
|
+
| | |
|
|
85
|
+
| --- | --- |
|
|
86
|
+
| **Code** | SQL injection, command injection, XSS (`innerHTML`, `dangerouslySetInnerHTML`, `v-html`, `echo $_GET`, `raw`), `eval` and `new Function`, path traversal, SSRF, unsafe deserialization (pickle, `yaml.load`, `ObjectInputStream`, `BinaryFormatter`, `unserialize`, `Marshal`), TLS checks turned off, MD5/SHA-1, DES/RC4/ECB, JWT `none`, template injection, debug mode, insecure cookies, `Math.random` tokens. JS/TS, Python, Go, Java, Kotlin, PHP, Ruby, C#, SQL |
|
|
87
|
+
| **Secrets** | AWS, GitHub, Slack, Stripe, OpenAI, Anthropic and Google keys, private keys, passwords in code, credentials in connection strings, committed `.env` files, real values in `.env.example`, a `.gitignore` that misses `.env`, secrets behind public prefixes (`NEXT_PUBLIC_`, `VITE_`, `EXPO_PUBLIC_`) that ship in the client bundle |
|
|
88
|
+
| **Agent setups** | `bypassPermissions` and `--dangerously-skip-permissions`, pre-approved `Bash`, MCP servers run with unpinned `npx`/`uvx`/`docker`, MCP tokens in plain text, remote MCP over `http://`, `curl \| sh` in hooks and skills, prompt-injection text, skills that read `~/.ssh` or cloud credentials, invisible Unicode in instructions. [More](docs/agent-setups.md) |
|
|
89
|
+
| **Mobile** | Android `debuggable`, cleartext traffic, exported content providers, WebView file access and JS bridges, world-readable files; iOS ATS turned off; tokens in UserDefaults, SharedPreferences, AsyncStorage or localStorage |
|
|
90
|
+
| **Config** | Docker (unpinned base, root, secrets in `ENV`, `ADD <url>`), GitHub Actions (`pull_request_target`, `write-all`, actions on `@main`, script injection from PR titles), privileged containers, `hostNetwork`, open Terraform ingress, public buckets, nginx autoindex, TLS 1.0/1.1 |
|
|
91
|
+
| **Dependencies** | every locked version in `package-lock.json`, `yarn.lock`, `pnpm-lock.yaml`, `Cargo.lock`, `requirements*.txt`, `poetry.lock`, `uv.lock`, `go.mod`, `Gemfile.lock` and `composer.lock`, checked against [OSV.dev](https://osv.dev), with the nearest fixed version |
|
|
92
|
+
|
|
93
|
+
## For AI agents
|
|
94
|
+
|
|
95
|
+
safe-anything is also an MCP server, so your agent can scan before it commits, and before you
|
|
96
|
+
install someone else's skill or MCP server.
|
|
97
|
+
|
|
98
|
+
```bash
|
|
99
|
+
claude mcp add safe-anything -- safe-anything mcp # Claude Code
|
|
100
|
+
codex mcp add safe-anything -- safe-anything mcp # Codex
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
Or, as a Claude Code plugin with the skill that tells the agent how to triage and fix findings:
|
|
104
|
+
|
|
105
|
+
```
|
|
106
|
+
/plugin marketplace add erkamyaman/safe-anything
|
|
107
|
+
/plugin install safe-anything@safe-anything
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
Tools: `scan` (path, offline, severity, include_tests) and `list_rules`. The skill is in
|
|
111
|
+
[skills/safe-anything](skills/safe-anything/SKILL.md).
|
|
112
|
+
|
|
113
|
+
## In CI
|
|
114
|
+
|
|
115
|
+
```yaml
|
|
116
|
+
- uses: erkamyaman/safe-anything@v1.0.1
|
|
117
|
+
with:
|
|
118
|
+
fail-on: high
|
|
119
|
+
- uses: github/codeql-action/upload-sarif@v4
|
|
120
|
+
if: always()
|
|
121
|
+
with:
|
|
122
|
+
sarif_file: safe-anything.sarif
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
Findings then show up in the repository's Security tab and on pull requests.
|
|
126
|
+
|
|
127
|
+
## Measured
|
|
128
|
+
|
|
129
|
+
Release build on an Apple M4, `--offline`, 2026-11-22. Every finding was read by hand. Times are
|
|
130
|
+
the scan's own report; the same scan took 0.03 to 0.13 s depending on what else the machine was
|
|
131
|
+
doing.
|
|
132
|
+
|
|
133
|
+
| Repository | Files | Findings | What they are |
|
|
134
|
+
| --- | --- | --- | --- |
|
|
135
|
+
| [OWASP Juice Shop](https://github.com/juice-shop/juice-shop) (vulnerable on purpose) | 1,195 | 67 | the login and search SQL injections, the `eval` challenges, MD5 passwords, tokens in localStorage, seeded passwords, open Terraform ingress; 2 to 3 false positives (a checksum MD5, `innerHTML` with trusted hint text) |
|
|
136
|
+
| [DVWA](https://github.com/digininja/DVWA) (vulnerable on purpose) | 233 | 63 | the SQL injections, command injections, MD5 passwords and `eval`; about 4 false positives (setup-script inserts, input validated in the "impossible" level) |
|
|
137
|
+
| [expressjs/express](https://github.com/expressjs/express) | 216 | 0 | |
|
|
138
|
+
| [pallets/flask](https://github.com/pallets/flask) | 231 | 2 | both false positives in practice: `eval` of the user's own shell startup file, SHA-1 for key derivation (reported as low) |
|
|
139
|
+
| [modelcontextprotocol/servers](https://github.com/modelcontextprotocol/servers) | 439 | 1 | `pull_request_target` in a workflow, worth a look |
|
|
140
|
+
| [anthropics/skills](https://github.com/anthropics/skills) | 392 | 6 | `innerHTML` in local review pages (5), `shell=True` in a script that runs commands by design |
|
|
141
|
+
| [vercel-labs/agent-skills](https://github.com/vercel-labs/agent-skills) | 439 | 0 | |
|
|
142
|
+
| [rust-anything](https://github.com/erkamyaman/rust-anything) | 3,134 | 6 | `innerHTML` in GIF demo pages (5), an action on `@master` |
|
|
143
|
+
| safe-anything itself | 53 | 0 | checked in CI on every push |
|
|
144
|
+
|
|
145
|
+
The noisiest rule is `code.xss-inner-html`: it fires on any HTML built from a variable, and most of
|
|
146
|
+
those in local tooling are not reachable by an attacker. It stays on, because real XSS looks the
|
|
147
|
+
same. Status per family: [docs/STATUS.md](docs/STATUS.md).
|
|
148
|
+
|
|
149
|
+
## How it works
|
|
150
|
+
|
|
151
|
+
One parallel walk over the repository (the `ignore` crate, the walker behind ripgrep), one read per
|
|
152
|
+
file, and every rule that applies run as a compiled regex. Where a pattern can't tell right from
|
|
153
|
+
wrong, the file is parsed: MCP configs as JSON with comments, Dockerfile stages, nine lockfile
|
|
154
|
+
formats. Nothing is executed. The only network call is the dependency check, which sends package
|
|
155
|
+
names and versions to OSV.dev ([privacy](docs/privacy.md)).
|
|
156
|
+
|
|
157
|
+
It finds known patterns; it does not trace data through your program. A clean scan means none of
|
|
158
|
+
these 72 problems were found, not that the code is safe. [Design notes](docs/adr).
|
|
159
|
+
|
|
160
|
+
## Credits
|
|
161
|
+
|
|
162
|
+
- [OWASP](https://owasp.org): the Top 10, the Top 10 for LLM Applications, MASVS, and the
|
|
163
|
+
[Cheat Sheet Series](https://cheatsheetseries.owasp.org) (CC BY-SA 4.0) that every rule links to.
|
|
164
|
+
- [CWE](https://cwe.mitre.org) by MITRE for the weakness ids.
|
|
165
|
+
- [OSV.dev](https://osv.dev) for the advisory data.
|
|
166
|
+
- [gitleaks](https://github.com/gitleaks/gitleaks) (MIT) for showing how provider tokens are shaped.
|
|
167
|
+
- [Craft Anything](https://github.com/storytold/craft-anything) for the idea that every answer should
|
|
168
|
+
show its evidence.
|
|
169
|
+
- [How to Secure Anything](https://github.com/veeral-patel/how-to-secure-anything) by Veeral Patel,
|
|
170
|
+
a reading list on security engineering, for the way of thinking about attack surface and least
|
|
171
|
+
privilege.
|
|
172
|
+
|
|
173
|
+
## Sponsors
|
|
174
|
+
|
|
175
|
+
<p align="center">
|
|
176
|
+
<a href="https://github.com/erkamyaman/safe-anything">safe-anything</a> is free and open source. If it helps your work, please consider sponsoring it.<br>
|
|
177
|
+
Your support keeps development going.
|
|
178
|
+
</p>
|
|
179
|
+
|
|
180
|
+
<p align="center">
|
|
181
|
+
<a href="https://coderabbit.link/erkamyaman">
|
|
182
|
+
<picture>
|
|
183
|
+
<source media="(prefers-color-scheme: dark)" srcset="docs/assets/sponsors/company-dark.svg">
|
|
184
|
+
<img src="docs/assets/sponsors/company-light.svg" width="800" alt="Company sponsor: CodeRabbit">
|
|
185
|
+
</picture>
|
|
186
|
+
</a>
|
|
187
|
+
</p>
|
|
188
|
+
|
|
189
|
+
<p align="center">
|
|
190
|
+
<a href="https://github.com/sponsors/erkamyaman">
|
|
191
|
+
<picture>
|
|
192
|
+
<source media="(prefers-color-scheme: dark)" srcset="docs/assets/sponsors/sponsors-dark.svg">
|
|
193
|
+
<img src="docs/assets/sponsors/sponsors-light.svg" width="800" alt="Sponsors: Santosh Yadav, Hakan Soytürk, Ali Yilmaz, Ashley Hunter, Fatih Uzuntaş">
|
|
194
|
+
</picture>
|
|
195
|
+
</a>
|
|
196
|
+
</p>
|
|
197
|
+
|
|
198
|
+
<p align="center">
|
|
199
|
+
<a href="https://github.com/sponsors/erkamyaman"><img src="https://img.shields.io/badge/Become_a_sponsor-%E2%9D%A4-db61a2?style=for-the-badge&logo=githubsponsors&logoColor=white" alt="Become a sponsor"></a>
|
|
200
|
+
<a href="https://buymeacoffee.com/erkamyaman"><img src="https://img.shields.io/badge/Buy_me_a_coffee-%E2%98%95-FFDD00?style=for-the-badge&logo=buymeacoffee&logoColor=black" alt="Buy me a coffee"></a>
|
|
201
|
+
</p>
|
|
202
|
+
|
|
203
|
+
## Contributing
|
|
204
|
+
|
|
205
|
+
The most useful contribution is a fixture: a few lines safe-anything gets wrong. See
|
|
206
|
+
[CONTRIBUTING.md](CONTRIBUTING.md).
|
|
207
|
+
|
|
208
|
+
## License
|
|
209
|
+
|
|
210
|
+
MIT
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
'use strict'
|
|
3
|
+
const fs = require('node:fs')
|
|
4
|
+
const path = require('node:path')
|
|
5
|
+
const { spawnSync } = require('node:child_process')
|
|
6
|
+
|
|
7
|
+
const key = `${process.platform}-${process.arch}`
|
|
8
|
+
const exe = process.platform === 'win32' ? 'safe-anything.exe' : 'safe-anything'
|
|
9
|
+
const bin = path.join(__dirname, '..', 'binaries', key, exe)
|
|
10
|
+
if (!fs.existsSync(bin)) {
|
|
11
|
+
console.error(
|
|
12
|
+
`safe-anything: no prebuilt binary for ${key}.\n` +
|
|
13
|
+
'Install it with Cargo instead: cargo install safe-anything',
|
|
14
|
+
)
|
|
15
|
+
process.exit(1)
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
const result = spawnSync(bin, process.argv.slice(2), { stdio: 'inherit' })
|
|
19
|
+
if (result.error) {
|
|
20
|
+
console.error(`safe-anything: ${result.error.message}`)
|
|
21
|
+
process.exit(1)
|
|
22
|
+
}
|
|
23
|
+
if (result.signal) {
|
|
24
|
+
process.kill(process.pid, result.signal)
|
|
25
|
+
}
|
|
26
|
+
process.exit(result.status ?? 1)
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/package.json
CHANGED
|
@@ -1,6 +1,33 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "safe-anything",
|
|
3
|
-
"version": "
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "1.0.1",
|
|
4
|
+
"description": "Find the holes before someone else does. One fast command scans code, secrets, mobile and cloud config, dependencies and AI agent setups. 100% Rust.",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"security",
|
|
7
|
+
"scanner",
|
|
8
|
+
"sast",
|
|
9
|
+
"secrets",
|
|
10
|
+
"vulnerability",
|
|
11
|
+
"mcp",
|
|
12
|
+
"claude-code",
|
|
13
|
+
"codex",
|
|
14
|
+
"osv"
|
|
15
|
+
],
|
|
16
|
+
"license": "MIT",
|
|
17
|
+
"mcpName": "io.github.erkamyaman/safe-anything",
|
|
18
|
+
"repository": {
|
|
19
|
+
"type": "git",
|
|
20
|
+
"url": "git+https://github.com/erkamyaman/safe-anything.git"
|
|
21
|
+
},
|
|
22
|
+
"homepage": "https://github.com/erkamyaman/safe-anything",
|
|
23
|
+
"bin": {
|
|
24
|
+
"safe-anything": "bin/safe-anything.js"
|
|
25
|
+
},
|
|
26
|
+
"files": [
|
|
27
|
+
"bin",
|
|
28
|
+
"binaries"
|
|
29
|
+
],
|
|
30
|
+
"engines": {
|
|
31
|
+
"node": ">=18"
|
|
32
|
+
}
|
|
33
|
+
}
|