securenow 5.18.0 → 6.0.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/LICENSE +15 -0
- package/README.md +40 -239
- package/cli.js +455 -415
- package/console-instrumentation.js +136 -147
- package/docs/ALL-FRAMEWORKS-QUICKSTART.md +455 -1339
- package/docs/ARCHITECTURE.md +3 -3
- package/docs/AUTO-BODY-CAPTURE.md +1 -1
- package/docs/AUTO-SETUP.md +4 -4
- package/docs/AUTOMATIC-IP-CAPTURE.md +5 -5
- package/docs/BODY-CAPTURE-QUICKSTART.md +2 -2
- package/docs/CHANGELOG-NEXTJS.md +1 -1
- package/docs/CUSTOMER-GUIDE.md +16 -16
- package/docs/EASIEST-SETUP.md +5 -5
- package/docs/ENVIRONMENT-VARIABLES.md +652 -880
- package/docs/EXPRESS-BODY-CAPTURE.md +12 -13
- package/docs/EXPRESS-SETUP-GUIDE.md +720 -719
- package/docs/INDEX.md +4 -22
- package/docs/LOGGING-GUIDE.md +708 -701
- package/docs/LOGGING-QUICKSTART.md +239 -234
- package/docs/NEXTJS-BODY-CAPTURE.md +2 -2
- package/docs/NEXTJS-GUIDE.md +14 -14
- package/docs/NEXTJS-QUICKSTART.md +1 -1
- package/docs/NEXTJS-WRAPPER-APPROACH.md +1 -1
- package/docs/QUICKSTART-BODY-CAPTURE.md +2 -2
- package/docs/REDACTION-EXAMPLES.md +1 -1
- package/docs/REQUEST-BODY-CAPTURE.md +10 -19
- package/docs/VERCEL-OTEL-MIGRATION.md +3 -3
- package/examples/README.md +6 -6
- package/examples/instrumentation-with-auto-capture.ts +1 -1
- package/examples/nextjs-env-example.txt +2 -2
- package/examples/nextjs-instrumentation.js +1 -1
- package/examples/nextjs-instrumentation.ts +1 -1
- package/examples/nextjs-with-logging-example.md +6 -6
- package/examples/nextjs-with-options.ts +1 -1
- package/examples/test-nextjs-setup.js +1 -1
- package/nextjs-auto-capture.js +207 -199
- package/nextjs-middleware.js +181 -186
- package/nextjs-webpack-config.js +53 -88
- package/nextjs-wrapper.js +158 -158
- package/nextjs.d.ts +1 -1
- package/nextjs.js +135 -190
- package/package.json +45 -67
- package/postinstall.js +6 -6
- package/register.d.ts +1 -1
- package/register.js +4 -39
- package/tracing.d.ts +1 -2
- package/tracing.js +22 -287
- package/web-vite.mjs +156 -239
- package/CONSUMING-APPS-GUIDE.md +0 -455
- package/NPM_README.md +0 -1933
- package/SKILL-API.md +0 -600
- package/SKILL-CLI.md +0 -409
- package/cidr.js +0 -83
- package/cli/apps.js +0 -585
- package/cli/auth.js +0 -280
- package/cli/client.js +0 -115
- package/cli/config.js +0 -173
- package/cli/firewall.js +0 -100
- package/cli/fp.js +0 -638
- package/cli/init.js +0 -201
- package/cli/monitor.js +0 -440
- package/cli/run.js +0 -133
- package/cli/security.js +0 -1064
- package/cli/ui.js +0 -386
- package/docs/API-KEYS-GUIDE.md +0 -233
- package/docs/AUTO-SETUP-SUMMARY.md +0 -331
- package/docs/BODY-CAPTURE-FIX.md +0 -261
- package/docs/COMPLETION-REPORT.md +0 -408
- package/docs/FINAL-SOLUTION.md +0 -335
- package/docs/FIREWALL-GUIDE.md +0 -426
- package/docs/IMPLEMENTATION-SUMMARY.md +0 -410
- package/docs/NEXTJS-BODY-CAPTURE-COMPARISON.md +0 -323
- package/docs/NEXTJS-SETUP-COMPLETE.md +0 -795
- package/docs/NUXT-GUIDE.md +0 -166
- package/docs/SOLUTION-SUMMARY.md +0 -312
- package/firewall-cloud.js +0 -212
- package/firewall-iptables.js +0 -139
- package/firewall-only.js +0 -38
- package/firewall-tcp.js +0 -74
- package/firewall.js +0 -720
- package/free-trial-banner.js +0 -174
- package/nuxt-server-plugin.mjs +0 -423
- package/nuxt.d.ts +0 -60
- package/nuxt.mjs +0 -75
- package/resolve-ip.js +0 -77
package/cli/run.js
DELETED
|
@@ -1,133 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
const { spawn } = require('child_process');
|
|
4
|
-
const path = require('path');
|
|
5
|
-
const fs = require('fs');
|
|
6
|
-
const ui = require('./ui');
|
|
7
|
-
|
|
8
|
-
function isESM(scriptPath) {
|
|
9
|
-
if (scriptPath.endsWith('.mjs')) return true;
|
|
10
|
-
if (scriptPath.endsWith('.cjs')) return false;
|
|
11
|
-
|
|
12
|
-
let dir = path.resolve(path.dirname(scriptPath));
|
|
13
|
-
while (true) {
|
|
14
|
-
const pkgPath = path.join(dir, 'package.json');
|
|
15
|
-
if (fs.existsSync(pkgPath)) {
|
|
16
|
-
try {
|
|
17
|
-
const pkg = JSON.parse(fs.readFileSync(pkgPath, 'utf8'));
|
|
18
|
-
return pkg.type === 'module';
|
|
19
|
-
} catch { return false; }
|
|
20
|
-
}
|
|
21
|
-
const parent = path.dirname(dir);
|
|
22
|
-
if (parent === dir) break;
|
|
23
|
-
dir = parent;
|
|
24
|
-
}
|
|
25
|
-
return false;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
function resolveSecurenowRegister() {
|
|
29
|
-
// When running from the published package, securenow/register resolves to our own register.js.
|
|
30
|
-
// When running from the monorepo, resolve relative to this file.
|
|
31
|
-
try {
|
|
32
|
-
return require.resolve('securenow/register');
|
|
33
|
-
} catch {
|
|
34
|
-
return path.resolve(__dirname, '..', 'register.js');
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
function resolveESMHook() {
|
|
39
|
-
// --import uses ESM resolution which requires file:// URLs for absolute paths
|
|
40
|
-
// on Windows. Using the bare specifier lets Node's own resolver handle it.
|
|
41
|
-
try {
|
|
42
|
-
const resolved = require.resolve('@opentelemetry/instrumentation/hook.mjs');
|
|
43
|
-
const { pathToFileURL } = require('url');
|
|
44
|
-
return pathToFileURL(resolved).href;
|
|
45
|
-
} catch {
|
|
46
|
-
return '@opentelemetry/instrumentation/hook.mjs';
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
/**
|
|
51
|
-
* securenow run [node-flags...] <script> [app-args...]
|
|
52
|
-
*
|
|
53
|
-
* Spawns node with the correct OTel preload flags.
|
|
54
|
-
* Passes through Node flags (--watch, --inspect, etc.) and app arguments.
|
|
55
|
-
*
|
|
56
|
-
* We re-parse from process.argv directly so that flags like --watch and
|
|
57
|
-
* --inspect are forwarded to node verbatim (the CLI's own arg parser
|
|
58
|
-
* would otherwise consume them).
|
|
59
|
-
*/
|
|
60
|
-
function run(rawArgs) {
|
|
61
|
-
// rawArgs comes directly from process.argv, everything after `run` (or the file path)
|
|
62
|
-
if (!rawArgs || rawArgs.length === 0) {
|
|
63
|
-
ui.error('Missing script path.');
|
|
64
|
-
console.log('');
|
|
65
|
-
console.log(` ${ui.c.bold('Usage:')} securenow run [node-flags] <script> [app-args]`);
|
|
66
|
-
console.log('');
|
|
67
|
-
console.log(` ${ui.c.bold('Examples:')}`);
|
|
68
|
-
console.log(` securenow run src/index.js`);
|
|
69
|
-
console.log(` securenow run --watch src/index.js`);
|
|
70
|
-
console.log(` securenow run --inspect src/server.js --port 3000`);
|
|
71
|
-
console.log('');
|
|
72
|
-
process.exit(1);
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
const args = rawArgs;
|
|
76
|
-
|
|
77
|
-
// Split into: node flags (before the script), script path, and app args (after)
|
|
78
|
-
const nodeFlags = [];
|
|
79
|
-
let scriptIdx = -1;
|
|
80
|
-
|
|
81
|
-
for (let i = 0; i < args.length; i++) {
|
|
82
|
-
if (args[i].startsWith('-')) {
|
|
83
|
-
nodeFlags.push(args[i]);
|
|
84
|
-
} else {
|
|
85
|
-
scriptIdx = i;
|
|
86
|
-
break;
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
if (scriptIdx === -1) {
|
|
91
|
-
ui.error('No script path found. Provide a .js/.mjs/.ts file to run.');
|
|
92
|
-
process.exit(1);
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
const scriptPath = args[scriptIdx];
|
|
96
|
-
const appArgs = args.slice(scriptIdx + 1);
|
|
97
|
-
|
|
98
|
-
const esm = isESM(scriptPath);
|
|
99
|
-
const registerPath = resolveSecurenowRegister();
|
|
100
|
-
|
|
101
|
-
const otelFlags = [];
|
|
102
|
-
if (esm) {
|
|
103
|
-
otelFlags.push('--import', resolveESMHook());
|
|
104
|
-
}
|
|
105
|
-
otelFlags.push('--require', registerPath);
|
|
106
|
-
|
|
107
|
-
const finalArgs = [...otelFlags, ...nodeFlags, scriptPath, ...appArgs];
|
|
108
|
-
|
|
109
|
-
const nodeExe = process.execPath;
|
|
110
|
-
|
|
111
|
-
if (process.env.SECURENOW_DEBUG) {
|
|
112
|
-
console.log(`[securenow] ${ui.c.dim('exec:')} ${nodeExe} ${finalArgs.join(' ')}`);
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
const child = spawn(nodeExe, finalArgs, {
|
|
116
|
-
stdio: 'inherit',
|
|
117
|
-
env: process.env,
|
|
118
|
-
cwd: process.cwd(),
|
|
119
|
-
});
|
|
120
|
-
|
|
121
|
-
child.on('close', (code) => process.exit(code ?? 1));
|
|
122
|
-
child.on('error', (err) => {
|
|
123
|
-
ui.error(`Failed to start: ${err.message}`);
|
|
124
|
-
process.exit(1);
|
|
125
|
-
});
|
|
126
|
-
|
|
127
|
-
// Forward termination signals to the child
|
|
128
|
-
for (const sig of ['SIGINT', 'SIGTERM', 'SIGHUP']) {
|
|
129
|
-
process.on(sig, () => child.kill(sig));
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
module.exports = { run };
|