safe-anything 1.0.2 → 1.1.0

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/README.md CHANGED
@@ -16,12 +16,12 @@ Every finding comes with the line, the reason and the fix.</p>
16
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
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
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>
19
+ <a href="https://coderabbit.link/er-kam"><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
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
21
  </p>
22
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>
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 92 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/er-kam">CodeRabbit</a></p>
25
25
 
26
26
  <p align="center">
27
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">
@@ -63,6 +63,7 @@ found, so it works as a pre-commit or CI check as is.
63
63
  ```bash
64
64
  safe-anything . --json # machine-readable report
65
65
  safe-anything . --sarif # GitHub code scanning
66
+ safe-anything . --sarif-file out # SARIF to the file out, the report on screen
66
67
  safe-anything . --offline # no network (skips the dependency check)
67
68
  safe-anything . --severity medium # hide low findings
68
69
  safe-anything . --fail-on never # always exit 0 (or low, medium, high, critical)
@@ -70,25 +71,50 @@ safe-anything . --include-tests # also report findings in tests and fixtures
70
71
  safe-anything --list-rules
71
72
  ```
72
73
 
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).
74
+ - `.gitignore` is respected. List more paths in `.safe-anything-ignore`; it only adds to what is
75
+ skipped, it cannot bring back what is listed below.
76
+ - These are never scanned, and the report only counts the files it did scan:
77
+ - folders `.git`, `node_modules`, `target`, `vendor`, `dist`, `build`, `.next`, `.venv`, `venv`,
78
+ `__pycache__`, `Pods`, `.gradle` and `.claude/worktrees`, so generated code in `build/` is
79
+ not checked
80
+ - any file over 2 MB, lockfiles included, so a lockfile that large gets no dependency check
81
+ - `*.min.js`, `*.map`, `*.jsonl` and `*.log`
82
+ - binary files: images, fonts, archives, media and compiled files by their extension (`.png`, `.woff2`,
83
+ `.zip`, `.mp4`, `.class`, ...), and any other file with a zero byte in its first 8 KB. A text file
84
+ saved under one of those extensions is not scanned either.
85
+ - `*.lock` files get the dependency check but no code rules
86
+ - `safe-anything:ignore` in a comment silences that line (or the next one). Follow it with rule ids,
87
+ `// safe-anything:ignore code.weak-hash, code.eval`, to silence only those rules. An id that is no
88
+ rule (a typo) silences nothing, so the finding stays in the report.
76
89
  - In tests, specs and fixtures only real provider keys and private keys count, unless you pass
77
90
  `--include-tests`.
78
91
 
92
+ On a codebase that already has findings, save them once and fail only on new ones:
93
+
94
+ ```bash
95
+ safe-anything . --write-baseline .safe-anything-baseline.json
96
+ safe-anything . --baseline .safe-anything-baseline.json
97
+ ```
98
+
99
+ The baseline holds each finding's rule, path and a SHA-256 of its line, not the line itself, so it
100
+ can be committed. A finding counts as known when all three match, wherever the line moved to. Paths
101
+ are relative to the scanned folder, so scan the same folder you saved it from. Only files written by
102
+ `--write-baseline` are read, not `--json` reports. Review changes to it like code: an entry added to
103
+ it hides that finding.
104
+
79
105
  ## What it finds
80
106
 
81
- 72 rules, each with a CWE id, an OWASP category and a link to the OWASP page that explains it.
107
+ 92 rules, each with a CWE id, an OWASP category and a link to the OWASP page that explains it.
82
108
  The full list is in [docs/rules.md](docs/rules.md).
83
109
 
84
110
  | | |
85
111
  | --- | --- |
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 |
112
+ | **Code** | SQL injection, command injection, XSS (`innerHTML`, `dangerouslySetInnerHTML`, `v-html`, `echo $_GET`, `raw`), `eval` and `new Function`, path traversal, file inclusion from request input, SSRF, open redirects, unsafe deserialization (pickle, `yaml.load`, `ObjectInputStream`, `BinaryFormatter`, `unserialize`, `Marshal`), TLS checks turned off, MD5/SHA-1, DES/RC4/ECB, JWT `none`, template injection, CORS `*`, debug mode, insecure cookies, `Math.random` tokens, `GRANT ALL` and plain-text passwords in SQL files. JS/TS, Python, Go, Java, Kotlin, PHP, Ruby, C#, SQL |
113
+ | **Secrets** | AWS (key ids and secret access keys), GitHub, GitLab, Slack, Stripe, Shopify, npm, PyPI, OpenAI, Anthropic, Groq, Google, Hugging Face, Mailgun, SendGrid, Telegram, DigitalOcean and Twilio keys, Google OAuth client secrets, Slack and Discord webhook URLs, private keys (also inside service-account JSON), 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 |
114
+ | **Agent setups** | `bypassPermissions` and `--dangerously-skip-permissions`, pre-approved `Bash`, `enableAllProjectMcpServers`, 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) |
115
+ | **Mobile** | Android `debuggable`, `allowBackup`, 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 |
116
+ | **Config** | Docker (unpinned base, root, secrets in `ENV`, `ADD <url>`), `curl \| sh` in scripts, Dockerfiles and workflow `run:` steps, GitHub Actions (`pull_request_target`, `write-all`, actions on `@main`, script injection from PR titles), privileged containers, `hostNetwork`, Terraform (open ingress, public buckets, S3 public access blocks turned off, public or unencrypted databases), nginx autoindex, TLS 1.0/1.1 |
117
+ | **Dependencies** | every locked version in `package-lock.json`, `npm-shrinkwrap.json`, `yarn.lock`, `pnpm-lock.yaml`, `Cargo.lock`, `requirements*.txt`, `poetry.lock`, `uv.lock`, `pdm.lock`, `Pipfile.lock`, `go.mod`, `Gemfile.lock`, `composer.lock` and `pubspec.lock`, checked against [OSV.dev](https://osv.dev), with the nearest fixed version |
92
118
 
93
119
  <p align="center">
94
120
  <img src="docs/assets/nextjs-public-env.gif" alt="safe-anything on the with-mqtt-js example from the Next.js repository: 2 high findings, an MQTT password read from a NEXT_PUBLIC_ variable in app/page.tsx and environment.d.ts, which Next.js ships in the client bundle." width="820">
@@ -119,9 +145,10 @@ Tools: `scan` (path, offline, severity, include_tests) and `list_rules`. The ski
119
145
  ## In CI
120
146
 
121
147
  ```yaml
122
- - uses: erkamyaman/safe-anything@v1.0.2
148
+ - uses: erkamyaman/safe-anything@v1.1.0
123
149
  with:
124
150
  fail-on: high
151
+ # baseline: .safe-anything-baseline.json # fail only on findings not in it
125
152
  - uses: github/codeql-action/upload-sarif@v4
126
153
  if: always()
127
154
  with:
@@ -162,12 +189,12 @@ same. Status per family: [docs/STATUS.md](docs/STATUS.md).
162
189
 
163
190
  One parallel walk over the repository (the `ignore` crate, the walker behind ripgrep), one read per
164
191
  file, and every rule that applies run as a compiled regex. Where a pattern can't tell right from
165
- wrong, the file is parsed: MCP configs as JSON with comments, Dockerfile stages, nine lockfile
166
- formats. Nothing is executed. The only network call is the dependency check, which sends package
192
+ wrong, the file is parsed: MCP configs as JSON with comments, Dockerfile stages, and every
193
+ lockfile listed under Dependencies. Nothing is executed. The only network call is the dependency check, which sends package
167
194
  names and versions to OSV.dev ([privacy](docs/privacy.md)).
168
195
 
169
196
  It finds known patterns; it does not trace data through your program. A clean scan means none of
170
- these 72 problems were found, not that the code is safe. [Design notes](docs/adr).
197
+ these 92 problems were found, not that the code is safe. [Design notes](docs/adr).
171
198
 
172
199
  ## Credits
173
200
 
@@ -189,8 +216,10 @@ these 72 problems were found, not that the code is safe. [Design notes](docs/adr
189
216
  Your support keeps development going.
190
217
  </p>
191
218
 
219
+ <p align="center"><sub>Your safety comes first: sponsors get a logo and a link here, nothing more. No paid recommendations and no setup guides for third-party AI API resellers, so nothing here steers your code, keys or data somewhere you didn't choose.</sub></p>
220
+
192
221
  <p align="center">
193
- <a href="https://coderabbit.link/erkamyaman">
222
+ <a href="https://coderabbit.link/er-kam">
194
223
  <picture>
195
224
  <source media="(prefers-color-scheme: dark)" srcset="docs/assets/sponsors/company-dark.svg">
196
225
  <img src="docs/assets/sponsors/company-light.svg" width="800" alt="Company sponsor: CodeRabbit">
@@ -202,7 +231,7 @@ these 72 problems were found, not that the code is safe. [Design notes](docs/adr
202
231
  <a href="https://github.com/sponsors/erkamyaman">
203
232
  <picture>
204
233
  <source media="(prefers-color-scheme: dark)" srcset="docs/assets/sponsors/sponsors-dark.svg">
205
- <img src="docs/assets/sponsors/sponsors-light.svg" width="800" alt="Sponsors: Santosh Yadav, Hakan Soytürk, Ali Yilmaz, Ashley Hunter, Fatih Uzuntaş">
234
+ <img src="docs/assets/sponsors/sponsors-light.svg" width="800" alt="Sponsors: Santosh Yadav, Hakan Soytürk, Ali Yilmaz, Ashley Hunter, Fatih Uzuntaş, bugrcvi">
206
235
  </picture>
207
236
  </a>
208
237
  </p>
Binary file
Binary file
Binary file
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "safe-anything",
3
- "version": "1.0.2",
3
+ "version": "1.1.0",
4
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
5
  "keywords": [
6
6
  "security",