safe-anything 1.0.2 → 1.2.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 110 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> and <a href="https://www.atakdomain.com/">Atak Domain</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,51 @@ 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 are read up to 64 MB, for the dependency check only (no code rules
81
+ past 2 MB); a larger one is named in the report as not checked
82
+ - `*.min.js`, `*.map`, `*.jsonl` and `*.log`
83
+ - binary files: images, fonts, archives, media and compiled files by their extension (`.png`, `.woff2`,
84
+ `.zip`, `.mp4`, `.class`, ...), and any other file with a zero byte in its first 8 KB. A text file
85
+ saved under one of those extensions is not scanned either.
86
+ - `*.lock` files get the dependency check but no code rules
87
+ - `safe-anything:ignore` in a comment silences that line (or the next one). Follow it with rule ids,
88
+ `// safe-anything:ignore code.weak-hash, code.eval`, to silence only those rules. An id that is no
89
+ rule (a typo) silences nothing, so the finding stays in the report.
76
90
  - In tests, specs and fixtures only real provider keys and private keys count, unless you pass
77
91
  `--include-tests`.
78
92
 
93
+ On a codebase that already has findings, save them once and fail only on new ones:
94
+
95
+ ```bash
96
+ safe-anything . --write-baseline .safe-anything-baseline.json
97
+ safe-anything . --baseline .safe-anything-baseline.json
98
+ ```
99
+
100
+ The baseline holds each finding's rule, path and a SHA-256 of its line, not the line itself, so it
101
+ can be committed. A finding counts as known when all three match, wherever the line moved to. Paths
102
+ are relative to the scanned folder, so scan the same folder you saved it from. Only files written by
103
+ `--write-baseline` are read, not `--json` reports. Review changes to it like code: an entry added to
104
+ it hides that finding.
105
+
79
106
  ## What it finds
80
107
 
81
- 72 rules, each with a CWE id, an OWASP category and a link to the OWASP page that explains it.
108
+ 110 rules, each with a CWE id, an OWASP category and a link to the OWASP page that explains it.
82
109
  The full list is in [docs/rules.md](docs/rules.md).
83
110
 
84
111
  | | |
85
112
  | --- | --- |
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 |
113
+ | **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, Scala, PHP, Ruby, C#, SQL |
114
+ | **Secrets** | AWS (key ids and secret access keys), GitHub, GitLab, Slack, Stripe, Shopify, npm, PyPI, RubyGems, Docker Hub, OpenAI, Anthropic, Groq, Google, Hugging Face, Mailgun, SendGrid, Telegram, DigitalOcean, Heroku, Fly.io, Databricks, Perplexity, OpenRouter, Notion, Twilio, Linear, Prefect, Postman, Pulumi, Sentry, New Relic, Supabase, Grafana and Doppler keys, Google OAuth client secrets, Slack and Discord webhook URLs, private keys (also inside service-account JSON) and age 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 |
115
+ | **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) |
116
+ | **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 |
117
+ | **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 |
118
+ | **Dependencies** | every locked version in `package-lock.json`, `npm-shrinkwrap.json`, `yarn.lock`, `pnpm-lock.yaml`, `bun.lock`, `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
119
 
93
120
  <p align="center">
94
121
  <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 +146,10 @@ Tools: `scan` (path, offline, severity, include_tests) and `list_rules`. The ski
119
146
  ## In CI
120
147
 
121
148
  ```yaml
122
- - uses: erkamyaman/safe-anything@v1.0.2
149
+ - uses: erkamyaman/safe-anything@v1.2.0
123
150
  with:
124
151
  fail-on: high
152
+ # baseline: .safe-anything-baseline.json # fail only on findings not in it
125
153
  - uses: github/codeql-action/upload-sarif@v4
126
154
  if: always()
127
155
  with:
@@ -162,12 +190,12 @@ same. Status per family: [docs/STATUS.md](docs/STATUS.md).
162
190
 
163
191
  One parallel walk over the repository (the `ignore` crate, the walker behind ripgrep), one read per
164
192
  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
193
+ wrong, the file is parsed: MCP configs as JSON with comments, Dockerfile stages, and every
194
+ lockfile listed under Dependencies. Nothing is executed. The only network call is the dependency check, which sends package
167
195
  names and versions to OSV.dev ([privacy](docs/privacy.md)).
168
196
 
169
197
  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).
198
+ these 110 problems were found, not that the code is safe. [Design notes](docs/adr).
171
199
 
172
200
  ## Credits
173
201
 
@@ -189,8 +217,10 @@ these 72 problems were found, not that the code is safe. [Design notes](docs/adr
189
217
  Your support keeps development going.
190
218
  </p>
191
219
 
220
+ <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>
221
+
192
222
  <p align="center">
193
- <a href="https://coderabbit.link/erkamyaman">
223
+ <a href="https://coderabbit.link/er-kam">
194
224
  <picture>
195
225
  <source media="(prefers-color-scheme: dark)" srcset="docs/assets/sponsors/company-dark.svg">
196
226
  <img src="docs/assets/sponsors/company-light.svg" width="800" alt="Company sponsor: CodeRabbit">
@@ -198,11 +228,20 @@ these 72 problems were found, not that the code is safe. [Design notes](docs/adr
198
228
  </a>
199
229
  </p>
200
230
 
231
+ <p align="center">
232
+ <a href="https://www.atakdomain.com/">
233
+ <picture>
234
+ <source media="(prefers-color-scheme: dark)" srcset="docs/assets/sponsors/domain-dark.svg">
235
+ <img src="docs/assets/sponsors/domain-light.svg" width="800" alt="Domain sponsor: Atak Domain">
236
+ </picture>
237
+ </a>
238
+ </p>
239
+
201
240
  <p align="center">
202
241
  <a href="https://github.com/sponsors/erkamyaman">
203
242
  <picture>
204
243
  <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ş">
244
+ <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
245
  </picture>
207
246
  </a>
208
247
  </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.2.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",