securenow 8.24.0 → 8.25.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/NPM_README.md +693 -305
- package/README.md +76 -28
- package/SKILL-API.md +648 -525
- package/SKILL-CLI.md +293 -663
- package/app-config.js +19 -1
- package/cidr.js +139 -20
- package/cli/init.js +77 -15
- package/cli/utils.js +26 -14
- package/cli.js +7 -5
- package/console-instrumentation.js +6 -0
- package/firewall-cloud.js +81 -32
- package/firewall-iptables.js +123 -62
- package/firewall-only.js +2 -0
- package/firewall-tcp.js +19 -5
- package/firewall.js +21 -1
- package/framework-routes.js +222 -0
- package/log-format.js +2 -0
- package/log-redaction.js +135 -0
- package/mcp/catalog.js +14 -9
- package/next-route.js +61 -0
- package/nextjs-middleware.js +8 -4
- package/nextjs-wrapper.js +8 -4
- package/nextjs.d.ts +35 -67
- package/nextjs.js +29 -6
- package/package.json +5 -2
- package/register.d.ts +27 -34
- package/request-capture.js +11 -6
- package/resolve-ip.js +23 -5
- package/sessions.d.ts +27 -0
- package/sessions.js +71 -10
- package/tracing.d.ts +40 -121
- package/tracing.js +12 -4
package/README.md
CHANGED
|
@@ -10,6 +10,8 @@ Your agent already sees the repository, the dependencies, the auth implementatio
|
|
|
10
10
|
|
|
11
11
|
**Find it in code. Watch it in production.**
|
|
12
12
|
|
|
13
|
+
The full guides ship in this package: [`SKILL-API.md`](./SKILL-API.md) (wiring every framework, every setting and feature, deployment, verification, troubleshooting) and [`SKILL-CLI.md`](./SKILL-CLI.md) (every CLI command, by task).
|
|
14
|
+
|
|
13
15
|
---
|
|
14
16
|
|
|
15
17
|
## What it looks like
|
|
@@ -45,16 +47,21 @@ Paste this into Claude Code, Codex, or Cursor:
|
|
|
45
47
|
Set up SecureNow (npm package "securenow") in this project:
|
|
46
48
|
|
|
47
49
|
1. Install it: npm install securenow@latest
|
|
48
|
-
2.
|
|
50
|
+
2. Read node_modules/securenow/SKILL-API.md and follow it for this
|
|
51
|
+
project's framework and deployment.
|
|
52
|
+
3. Run npx securenow login from the project root and wait while I complete
|
|
49
53
|
the browser flow. It writes .securenow/runtime.json (SDK runtime config +
|
|
50
54
|
runtime API key) and .securenow/admin.json (CLI/MCP auth).
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
+
4. Run npx securenow init, then wire the runtime as SKILL-API.md says:
|
|
56
|
+
Next.js and Nuxt through init and the module; plain Node servers
|
|
57
|
+
(Express, Fastify, NestJS, Koa, Hapi, Hono, Polka, Feathers, h3) with
|
|
58
|
+
-r securenow/register on the command that starts the server, including
|
|
59
|
+
Docker CMD, PM2 node_args or systemd ExecStart.
|
|
60
|
+
5. Make sure the .securenow/*.json credential files are gitignored without
|
|
55
61
|
ignoring the whole .securenow/ directory. Never print their contents.
|
|
56
|
-
|
|
57
|
-
npx securenow test-span,
|
|
62
|
+
6. Verify: npx securenow whoami, npx securenow doctor,
|
|
63
|
+
npx securenow test-span, start the app and check its [securenow] lines,
|
|
64
|
+
then npx securenow status.
|
|
58
65
|
|
|
59
66
|
Do not block traffic or modify security policy without asking me first.
|
|
60
67
|
```
|
|
@@ -65,17 +72,20 @@ Do not block traffic or modify security policy without asking me first.
|
|
|
65
72
|
|
|
66
73
|
```bash
|
|
67
74
|
# 1. Install
|
|
68
|
-
npm install securenow
|
|
75
|
+
npm install securenow@latest
|
|
69
76
|
|
|
70
77
|
# 2. Pick (or create) your app in the browser — writes .securenow/runtime.json
|
|
71
78
|
# and refreshes CLI/MCP auth in .securenow/admin.json
|
|
72
79
|
npx securenow login
|
|
73
80
|
|
|
74
|
-
# 3.
|
|
81
|
+
# 3. Fill the runtime config and detect the framework
|
|
82
|
+
npx securenow init
|
|
83
|
+
|
|
84
|
+
# 4. Start your app — one flag is all it takes
|
|
75
85
|
node -r securenow/register src/index.js
|
|
76
86
|
```
|
|
77
87
|
|
|
78
|
-
No `.env` edits, no API keys to paste. Runtime config lives in `.securenow/runtime.json`. The only environment variables the SDK reads are `SECURENOW_CREDENTIALS`, for hosts that cannot mount a file (see Production), and the `SECURENOW_DISABLED` test switch.
|
|
88
|
+
No `.env` edits, no API keys to paste. Runtime config lives in `.securenow/runtime.json`. The only environment variables the SDK reads are `SECURENOW_CREDENTIALS`, for hosts that cannot mount a file (see Production), and the `SECURENOW_DISABLED` test switch; any other `SECURENOW_*` variable is ignored.
|
|
79
89
|
|
|
80
90
|
```json
|
|
81
91
|
"scripts": {
|
|
@@ -84,11 +94,15 @@ No `.env` edits, no API keys to paste. Runtime config lives in `.securenow/runti
|
|
|
84
94
|
}
|
|
85
95
|
```
|
|
86
96
|
|
|
87
|
-
Can't change the script? Use `NODE_OPTIONS="-r securenow/register" npm start`, or the wrapper: `npx securenow run src/index.js`.
|
|
97
|
+
The same flag works for CommonJS, ESM (`"type": "module"`, `.mjs`) and TypeScript (`node -r securenow/register --import tsx src/index.ts`). Can't change the script? Use `NODE_OPTIONS="-r securenow/register" npm start`, or the wrapper: `npx securenow run src/index.js`.
|
|
98
|
+
|
|
99
|
+
**Express, Fastify, NestJS, Koa, Hapi, Hono (`@hono/node-server`), Polka, Feathers, h3, raw `http`/`https`** — the preload above, no code changes.
|
|
88
100
|
|
|
89
|
-
**Next.js** — `npx securenow init` creates `instrumentation.ts` and patches `next.config.*` when it can do so safely (
|
|
101
|
+
**Next.js 15 and 16** — `npx securenow init` creates `instrumentation.ts` and patches `next.config.*` when it can do so safely (`serverExternalPackages: ['securenow']` plus `outputFileTracingIncludes` for standalone output). If your config needs human judgment, `init` prints an agent-ready prompt with the exact edits to merge. `next start` and `output: 'standalone'` (Docker) both work. If `init` wrote your instrumentation file before 8.24.0, run it again: it replaces that file, whose `webpackIgnore` imports left SecureNow's dependencies out of standalone builds. With a `src/` layout `init` writes `src/instrumentation.ts` (8.25.0+), where Next.js loads it. The Edge runtime is not instrumented.
|
|
90
102
|
|
|
91
|
-
**
|
|
103
|
+
**Next.js 14 (8.25.0+)** — `init` writes the `experimental` version of the config (`instrumentationHook`, `serverComponentsExternalPackages`, `outputFileTracingIncludes`), or prints the exact edits for an existing config. Tested on 14.2 (`next start` and standalone).
|
|
104
|
+
|
|
105
|
+
**Nuxt 3 and 4** — add the module, then run `npx securenow init`. The `nuxt build` output is fully covered (tested on Nuxt 3.21 and 4.6, with `.output` running on its own like a Docker image), and `nuxt dev` is traced too. In `nuxt dev` the client IP is known from 8.25.0; before, it was unknown behind Nuxt's dev proxy, so IP blocking only applied to the built server.
|
|
92
106
|
|
|
93
107
|
```ts
|
|
94
108
|
export default defineNuxtConfig({
|
|
@@ -100,9 +114,13 @@ Settings come from `.securenow/runtime.json` like every other integration; `secu
|
|
|
100
114
|
|
|
101
115
|
**PM2** — in `ecosystem.config.cjs`, pass the preload as an absolute path: `node_args: ['-r', require.resolve('securenow/register')]`. That works in fork and cluster mode (`instances: 'max'`) wherever the PM2 daemon was started. (In cluster mode Node resolves a bare `-r securenow/register` from the daemon's folder, so after `pm2 resurrect` at boot the workers crash-loop with `Cannot find module 'securenow/register'`.) Each process reads the `.securenow/` folder of the app PM2 started.
|
|
102
116
|
|
|
103
|
-
**
|
|
117
|
+
**Vite** — browser telemetry is not sent to SecureNow. Instrument the Node process that serves the app: `node -r securenow/register-vite node_modules/vite/bin/vite.js preview`, or `-r securenow/register` for a Vite SSR server.
|
|
118
|
+
|
|
119
|
+
**Bun** — `bun --preload securenow/register app.js` works for apps served through `node:http` (tested with Express 5 on Bun 1.3). `Bun.serve` is not traced or protected. Deno and edge runtimes (Cloudflare Workers, Vercel Edge) are not supported: SecureNow runs inside a Node.js process.
|
|
104
120
|
|
|
105
|
-
**What's captured automatically:** HTTP spans
|
|
121
|
+
**What's captured automatically:** HTTP spans with the client IP, database spans (Postgres, MySQL, MongoDB, Redis), outgoing HTTP, `console.*` as logs with trace correlation, crashes (uncaught exceptions and unhandled rejections) as `FATAL` logs with their stack, plus the spans that ended just before the crash, request headers and bodies with auto-redaction, multipart metadata (never file content), plus the firewall. `http.route` is recorded for Express, Fastify, NestJS, Koa with `@koa/router`, Hapi and Nuxt; from 8.25.0 also for Hono, h3, Feathers and Polka, and for Next.js 15 and 16 on the HTTP span (before 8.25.0 those four showed the raw path, Next.js 16 put the route on Next.js's own span and Next.js 15 recorded `next.route`). Tune everything in `.securenow/runtime.json` under `config`.
|
|
122
|
+
|
|
123
|
+
**Behind a proxy** — forwarding headers (`X-Forwarded-For`, `CF-Connecting-IP`...) count only when the connection comes from a trusted proxy: private and loopback addresses, the host itself, and from 8.25.0 Unix-socket and named-pipe connections (nginx `proxy_pass http://unix:...`). Add public load balancers or CDNs to `config.networking.trustedProxies` (IPv4/IPv6 addresses or ranges, or `"cloudflare"`).
|
|
106
124
|
|
|
107
125
|
**Production** — same file structure. Generate a tokenless runtime credentials file and mount it as a deployment secret (Docker, Kubernetes, VMs):
|
|
108
126
|
|
|
@@ -118,20 +136,42 @@ npx securenow credentials runtime --env production --format env
|
|
|
118
136
|
# SECURENOW_CREDENTIALS=eyJ... -> add as a secret environment variable
|
|
119
137
|
```
|
|
120
138
|
|
|
121
|
-
`SECURENOW_CREDENTIALS` (raw JSON or base64) takes precedence over credential files.
|
|
139
|
+
`SECURENOW_CREDENTIALS` (raw JSON or base64) takes precedence over credential files. The startup line says where credentials came from (`credentials=env:SECURENOW_CREDENTIALS` or the file path). Next.js on Vercel goes through `@vercel/otel` and is not tested end to end; the firewall is not verified on Vercel serverless functions. Docker, Kubernetes, PM2 and systemd recipes: SKILL-API.md, section 6.
|
|
122
140
|
|
|
123
141
|
**Verify** any environment with:
|
|
124
142
|
|
|
125
143
|
```bash
|
|
126
|
-
npx securenow
|
|
127
|
-
npx securenow
|
|
144
|
+
npx securenow doctor # diagnose config + connectivity ("All checks passed.")
|
|
145
|
+
npx securenow test-span # send a test span ("Span accepted (HTTP 200)")
|
|
128
146
|
npx securenow status # dashboard summary
|
|
147
|
+
npx securenow today # what happened, what SecureNow did, what needs you
|
|
129
148
|
```
|
|
130
149
|
|
|
131
150
|
**Tests** — test runs otherwise report to your real app with the project's `.securenow` credentials. `SECURENOW_DISABLED=1 npm test` turns the SDK off for that process: no traces, logs, events, firewall or session sync, and `guard()` just calls `next()`. Apart from `SECURENOW_CREDENTIALS`, this is the only setting read from the environment.
|
|
132
151
|
|
|
133
152
|
---
|
|
134
153
|
|
|
154
|
+
## Custom events and session revocation
|
|
155
|
+
|
|
156
|
+
Report what only your app knows, so SecureNow can catch brute force, credential stuffing and account takeover:
|
|
157
|
+
|
|
158
|
+
```js
|
|
159
|
+
const { track } = require('securenow/events');
|
|
160
|
+
track('auth.login.failure', { userId, ip, userAgent, severity: 'warn', attributes: { reason: 'bad_password' } });
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
Fire-and-forget, batched, never throws. Recommended events: `auth.login.failure`, `auth.login.success`, `auth.otp.send.requested`, `auth.otp.send.result`, `auth.otp.verify.failure`, `auth.otp.verify.success`, `auth.password_reset.requested`, `auth.password_reset.completed`, `auth.mfa.challenge.failure`, `auth.mfa.challenge.success`, `auth.session.revoked`. From scripts or non-JS services: `npx securenow event send <type> --user <id> --ip <ip>`.
|
|
164
|
+
|
|
165
|
+
Kill a stolen session with `npx securenow revoke session <id>` (or `revoke user <id>`); the SDK enforces it within 30 seconds:
|
|
166
|
+
|
|
167
|
+
- **Zero code, any framework (8.25.0+):** `"sessions": { "guard": true, "capture": true }` under `config` in `.securenow/runtime.json`. Revoked sessions get 401 and their cookies cleared; `capture` sends `session.seen` for session-theft detection.
|
|
168
|
+
- **Express-style middleware:** `app.use(require('securenow/sessions').guard())` (Express, Connect, Polka, NestJS with Express, Feathers-Express).
|
|
169
|
+
- **Anything else (8.25.0+):** `const { revoked } = require('securenow/sessions').check(req)` in a Fastify hook, Koa or Hono middleware, a Next.js route handler or an h3 handler; `req` can be a Node request or a Web `Request`, and you return the 401.
|
|
170
|
+
|
|
171
|
+
Examples for each framework: SKILL-API.md, sections 5.9 and 5.10.
|
|
172
|
+
|
|
173
|
+
---
|
|
174
|
+
|
|
135
175
|
## Connect your coding agent (MCP)
|
|
136
176
|
|
|
137
177
|
SecureNow ships a local stdio MCP server. The server command is `npx securenow mcp` (also installed as the `securenow-mcp` bin). Authenticate first with `npx securenow login`.
|
|
@@ -161,20 +201,24 @@ codex mcp add securenow -- npx securenow mcp
|
|
|
161
201
|
}
|
|
162
202
|
```
|
|
163
203
|
|
|
164
|
-
|
|
204
|
+
**Hosted** — `https://api.securenow.ai/mcp`, with OAuth sign-in (no install), for Claude Code (`claude mcp add --transport http securenow https://api.securenow.ai/mcp`), claude.ai, Claude Desktop, ChatGPT or any MCP client.
|
|
205
|
+
|
|
206
|
+
The local server resolves credentials by operation type: admin/control-plane tools use `.securenow/admin.json`, app-scoped runtime reads can use `.securenow/runtime.json` or an explicit app key. Refresh one lane with `npx securenow admin login` or `npx securenow app connect`.
|
|
165
207
|
|
|
166
|
-
It exposes tools for apps, traces, logs, firewall, IP intelligence, forensics, blocklist/allowlist/trusted IPs,
|
|
208
|
+
It exposes tools for apps, traces, logs, the firewall, IP intelligence, forensics, blocklist/allowlist/trusted IPs, rate limits, challenges, alert rules, starter protection, and both review queues — plus bundled docs as MCP resources and ready-made prompts (`investigate_ip`, `work_human_actions`, `work_alert_review`, `soc_patrol`, `secure_project_setup`). `npx securenow mcp --profile investigator|detection|responder` serves a smaller set. Read tools are annotated read-only; every write tool refuses to run without `confirm: true` and a non-empty `reason`. Session revocation is a CLI command (`securenow revoke`).
|
|
167
209
|
|
|
168
210
|
---
|
|
169
211
|
|
|
170
212
|
## CLI
|
|
171
213
|
|
|
172
|
-
Everything the MCP server can do is also a command. Run `npx securenow help` for the
|
|
214
|
+
Everything the MCP server can do is also a command. Run `npx securenow help` for the list and `npx securenow help <command>` for flags; most read commands take `--json` for machine-readable output and `--app <key>` to target another app. SKILL-CLI.md organizes them by task.
|
|
173
215
|
|
|
174
216
|
### Investigate
|
|
175
217
|
|
|
176
218
|
| Command | Description |
|
|
177
219
|
|---|---|
|
|
220
|
+
| `securenow today` | The Overview: what happened, what SecureNow did, what needs you |
|
|
221
|
+
| `securenow attacker <address>` | Why an address was flagged: verdict, signals, traffic, detections, timeline |
|
|
178
222
|
| `securenow ip <address>` | IP intelligence (geo, abuse, verdict) |
|
|
179
223
|
| `securenow ip traces <address>` | Traces from an IP |
|
|
180
224
|
| `securenow forensics "<query>"` | Natural-language forensic query |
|
|
@@ -183,6 +227,7 @@ Everything the MCP server can do is also a command. Run `npx securenow help` for
|
|
|
183
227
|
| `securenow traces` / `traces show <traceId>` | Recent traces / trace spans |
|
|
184
228
|
| `securenow traces analyze <traceId>` | AI security analysis of a trace |
|
|
185
229
|
| `securenow logs [--since 6h] [--level error]` | View logs |
|
|
230
|
+
| `securenow logs errors [--since 1h]` | Failures grouped by message |
|
|
186
231
|
| `securenow analytics` | Response-code analytics |
|
|
187
232
|
|
|
188
233
|
### Respond
|
|
@@ -200,8 +245,9 @@ Everything the MCP server can do is also a command. Run `npx securenow help` for
|
|
|
200
245
|
| `securenow ratelimit add --route /api/ --limit 100 --window 1m --header x-api-key` | Per-API-key (or `--cookie session` per-session) limit |
|
|
201
246
|
| `securenow firewall hits --since 1h` | Who your blocks, rate limits and challenges actually stopped |
|
|
202
247
|
| `securenow challenge add <ip> --route /login` | Proof-of-work challenge instead of a hard block |
|
|
203
|
-
| `securenow revoke session <id>` / `revoke user <id>` | Kill stolen sessions (
|
|
248
|
+
| `securenow revoke session <id>` / `revoke user <id>` | Kill stolen sessions (the SDK's session guard enforces it) |
|
|
204
249
|
| `securenow trusted add <ip>` | Mark an IP as trusted |
|
|
250
|
+
| `securenow agent` / `agent mode <action> <mode>` | The autonomous agent that works both queues: status, what it may do |
|
|
205
251
|
|
|
206
252
|
### Rate limits, outside your code
|
|
207
253
|
|
|
@@ -213,13 +259,15 @@ Counters live in each process by default. To share one counter across workers an
|
|
|
213
259
|
{ "config": { "firewall": { "rateLimitStore": "redis://your-redis:6379" } } }
|
|
214
260
|
```
|
|
215
261
|
|
|
216
|
-
The firewall never waits on Redis: it decides from what it already knows and reports each hit in the background (at most
|
|
262
|
+
The firewall never waits on Redis: it decides from what it already knows and reports each hit in the background (at most a request or two per process can get through while a reply is in flight). If Redis is unreachable, counting falls back to in-process.
|
|
217
263
|
|
|
218
264
|
### Rules & detections
|
|
219
265
|
|
|
220
266
|
| Command | Description |
|
|
221
267
|
|---|---|
|
|
222
|
-
| `securenow
|
|
268
|
+
| `securenow protect` | Starter protection (about 20 rules every app gets, monitor or block mode) |
|
|
269
|
+
| `securenow alerts rules from-text "<what to catch>" --app <key>` | Describe a detection in English; checked draft, created in test mode |
|
|
270
|
+
| `securenow alerts rules` | List alert rules (`create`, `update`, `test`, `runs`, `why`, `promote`, `delete`, ...) |
|
|
223
271
|
| `securenow alerts rules validate --sql @rule.sql --app <key>` | Compile and dry-run candidate detection SQL |
|
|
224
272
|
| `securenow alerts history` | Alert history |
|
|
225
273
|
| `securenow fp` / `fp ai-fill --description "..."` | False-positive exclusions, AI-drafted |
|
|
@@ -258,18 +306,18 @@ npx securenow run --firewall-only src/index.js
|
|
|
258
306
|
node -r securenow/firewall-only src/index.js
|
|
259
307
|
```
|
|
260
308
|
|
|
261
|
-
It syncs your app's blocklist plus SecureNow's known-bad IP feed, refreshed hourly, and blocks in-process with HTTP 403. No proxies, no DNS changes, no network configuration — and it fails open.
|
|
309
|
+
It syncs your app's blocklist plus SecureNow's known-bad IP feed, refreshed hourly, and blocks in-process with HTTP 403. No proxies, no DNS changes, no network configuration — and it fails open. Rate limits (429) and proof-of-work challenges run in the same place.
|
|
262
310
|
|
|
263
311
|
---
|
|
264
312
|
|
|
265
313
|
## Security & trust
|
|
266
314
|
|
|
267
315
|
- **SecureNow never needs your source code.** It sees runtime telemetry — requests, spans, logs — not your repository.
|
|
268
|
-
- **Redacted at capture.** `password`, `token`, `api_key`, `authorization`, `cookie`, and friends are auto-redacted before leaving your process; multipart file content is never captured. Preview with `securenow redact '<json>'`.
|
|
316
|
+
- **Redacted at capture.** `password`, `token`, `api_key`, `authorization`, `cookie`, emails, card numbers and friends are auto-redacted before leaving your process; multipart file content is never captured. Preview with `securenow redact '<json>'`. Log lines are redacted too (8.25.0+, `config.logging.redact`): credential fields and secret shapes become `[REDACTED]`, but a secret in free text still goes out, so don't log secrets.
|
|
269
317
|
|
|
270
318
|
SecureNow 8.11.2 redacts sign-in credentials named `code`, `otpCode`, `oneTimeCode`, `verificationCode`, and `passcode` by default, including case and separator variants. JSON, form, GraphQL, and multipart text capture use the same rule; URL query parameters and captured headers are also protected. Credential names match exactly after normalization, so `status_code` and `error_code` remain available for investigation. Redaction changes exported telemetry only.
|
|
271
319
|
- **Fails open.** If SecureNow is unreachable, your app serves traffic normally (`config.firewall.failMode: "open"` is the default).
|
|
272
|
-
- **Read/write split.** MCP read tools are read-only; write tools require explicit `confirm: true` plus a reason, so your agent asks you before it blocks, rate-limits or
|
|
320
|
+
- **Read/write split.** MCP read tools are read-only; write tools require explicit `confirm: true` plus a reason, so your agent asks you before it blocks, rate-limits or changes a rule; every write is recorded and reversible.
|
|
273
321
|
|
|
274
322
|
More at [securenow.ai/security](https://securenow.ai/security).
|
|
275
323
|
|
|
@@ -283,7 +331,7 @@ One plan: **$99 per app per month**, every feature included — detection, MCP,
|
|
|
283
331
|
- **14-day free trial** for the whole account, every feature, no credit card.
|
|
284
332
|
- **No free tier.** After the trial, everything pauses until you subscribe, including the firewall (the known-bad IP feed and blocklist sync stop being served).
|
|
285
333
|
|
|
286
|
-
Details at [securenow.ai](https://securenow.ai/). Full CLI/SDK reference: `npx securenow help` plus the `SKILL-CLI.md` and `SKILL-API.md` files shipped in this package.
|
|
334
|
+
Details at [securenow.ai](https://securenow.ai/). Full CLI/SDK reference: `npx securenow help` plus the [`SKILL-CLI.md`](./SKILL-CLI.md) and [`SKILL-API.md`](./SKILL-API.md) files shipped in this package.
|
|
287
335
|
|
|
288
336
|
## License
|
|
289
337
|
|