securenow 6.0.2 → 6.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/CONSUMING-APPS-GUIDE.md +455 -0
- package/NPM_README.md +2029 -0
- package/README.md +297 -40
- package/SKILL-API.md +634 -0
- package/SKILL-CLI.md +454 -0
- package/cidr.js +83 -0
- package/cli/apps.js +585 -0
- package/cli/auth.js +280 -0
- package/cli/client.js +115 -0
- package/cli/config.js +173 -0
- package/cli/diagnostics.js +387 -0
- package/cli/firewall.js +100 -0
- package/cli/fp.js +638 -0
- package/cli/init.js +201 -0
- package/cli/monitor.js +440 -0
- package/cli/run.js +148 -0
- package/cli/security.js +980 -0
- package/cli/ui.js +386 -0
- package/cli/utils.js +127 -0
- package/cli.js +466 -455
- package/console-instrumentation.js +147 -136
- package/docs/ALL-FRAMEWORKS-QUICKSTART.md +1377 -455
- package/docs/API-KEYS-GUIDE.md +233 -0
- package/docs/ARCHITECTURE.md +3 -3
- package/docs/AUTO-BODY-CAPTURE.md +1 -1
- package/docs/AUTO-SETUP-SUMMARY.md +331 -0
- package/docs/AUTO-SETUP.md +4 -4
- package/docs/AUTOMATIC-IP-CAPTURE.md +5 -5
- package/docs/BODY-CAPTURE-FIX.md +261 -0
- package/docs/BODY-CAPTURE-QUICKSTART.md +2 -2
- package/docs/CHANGELOG-NEXTJS.md +1 -35
- package/docs/COMPLETION-REPORT.md +408 -0
- package/docs/CUSTOMER-GUIDE.md +16 -16
- package/docs/EASIEST-SETUP.md +5 -5
- package/docs/ENVIRONMENT-VARIABLES.md +880 -652
- package/docs/EXPRESS-BODY-CAPTURE.md +13 -12
- package/docs/EXPRESS-SETUP-GUIDE.md +719 -720
- package/docs/FINAL-SOLUTION.md +335 -0
- package/docs/FIREWALL-GUIDE.md +426 -0
- package/docs/IMPLEMENTATION-SUMMARY.md +410 -0
- package/docs/INDEX.md +22 -4
- package/docs/LOGGING-GUIDE.md +701 -708
- package/docs/LOGGING-QUICKSTART.md +234 -255
- package/docs/NEXTJS-BODY-CAPTURE-COMPARISON.md +323 -0
- 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-SETUP-COMPLETE.md +795 -0
- package/docs/NEXTJS-WRAPPER-APPROACH.md +1 -1
- package/docs/NUXT-GUIDE.md +166 -0
- package/docs/QUICKSTART-BODY-CAPTURE.md +2 -2
- package/docs/REDACTION-EXAMPLES.md +1 -1
- package/docs/REQUEST-BODY-CAPTURE.md +19 -10
- package/docs/SOLUTION-SUMMARY.md +312 -0
- 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/firewall-cloud.js +212 -0
- package/firewall-iptables.js +139 -0
- package/firewall-only.js +38 -0
- package/firewall-tcp.js +74 -0
- package/firewall.js +720 -0
- package/free-trial-banner.js +174 -0
- package/nextjs-auto-capture.js +199 -207
- package/nextjs-middleware.js +186 -181
- package/nextjs-webpack-config.js +88 -53
- package/nextjs-wrapper.js +158 -158
- package/nextjs.d.ts +1 -1
- package/nextjs.js +639 -647
- package/nuxt-server-plugin.mjs +423 -0
- package/nuxt.d.ts +60 -0
- package/nuxt.mjs +75 -0
- package/package.json +186 -164
- package/postinstall.js +6 -6
- package/register.d.ts +1 -1
- package/register.js +39 -4
- package/resolve-ip.js +77 -0
- package/tracing.d.ts +2 -1
- package/tracing.js +295 -34
- package/web-vite.mjs +239 -156
- package/LICENSE +0 -15
|
@@ -1,136 +1,147 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Console instrumentation helper for securenow
|
|
5
|
-
*
|
|
6
|
-
* This module wraps the default console methods (log, info, warn, error, debug)
|
|
7
|
-
* to automatically send logs to OpenTelemetry/
|
|
8
|
-
*
|
|
9
|
-
* Usage:
|
|
10
|
-
* 1. Enable logging: SECURENOW_LOGGING_ENABLED=1
|
|
11
|
-
* 2. Import this file AFTER securenow is initialized
|
|
12
|
-
* 3. Use console.log/info/warn/error as normal
|
|
13
|
-
*
|
|
14
|
-
* Example:
|
|
15
|
-
* // At the top of your app.js or index.js
|
|
16
|
-
* require('securenow/register'); // or use NODE_OPTIONS
|
|
17
|
-
* require('securenow/console-instrumentation');
|
|
18
|
-
*
|
|
19
|
-
* // Now all console calls are captured
|
|
20
|
-
* console.log('Application started');
|
|
21
|
-
* console.error('An error occurred');
|
|
22
|
-
*/
|
|
23
|
-
|
|
24
|
-
const tracing = require('./tracing');
|
|
25
|
-
|
|
26
|
-
if (!tracing.isLoggingEnabled()) {
|
|
27
|
-
console.warn('[securenow] Console instrumentation loaded but logging is not enabled. Set SECURENOW_LOGGING_ENABLED=1 to enable.');
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
// Get a logger instance
|
|
31
|
-
const logger = tracing.getLogger('console', '1.0.0');
|
|
32
|
-
|
|
33
|
-
if (!logger) {
|
|
34
|
-
console.warn('[securenow] Console instrumentation: No logger available. Logging will not work.');
|
|
35
|
-
module.exports = {};
|
|
36
|
-
return;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
console.
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Console instrumentation helper for securenow
|
|
5
|
+
*
|
|
6
|
+
* This module wraps the default console methods (log, info, warn, error, debug)
|
|
7
|
+
* to automatically send logs to OpenTelemetry / any OTLP-compatible backend.
|
|
8
|
+
*
|
|
9
|
+
* Usage:
|
|
10
|
+
* 1. Enable logging: SECURENOW_LOGGING_ENABLED=1
|
|
11
|
+
* 2. Import this file AFTER securenow is initialized
|
|
12
|
+
* 3. Use console.log/info/warn/error as normal
|
|
13
|
+
*
|
|
14
|
+
* Example:
|
|
15
|
+
* // At the top of your app.js or index.js
|
|
16
|
+
* require('securenow/register'); // or use NODE_OPTIONS
|
|
17
|
+
* require('securenow/console-instrumentation');
|
|
18
|
+
*
|
|
19
|
+
* // Now all console calls are captured
|
|
20
|
+
* console.log('Application started');
|
|
21
|
+
* console.error('An error occurred');
|
|
22
|
+
*/
|
|
23
|
+
|
|
24
|
+
const tracing = require('./tracing');
|
|
25
|
+
|
|
26
|
+
if (!tracing.isLoggingEnabled()) {
|
|
27
|
+
console.warn('[securenow] Console instrumentation loaded but logging is not enabled. Set SECURENOW_LOGGING_ENABLED=1 to enable.');
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
// Get a logger instance
|
|
31
|
+
const logger = tracing.getLogger('console', '1.0.0');
|
|
32
|
+
|
|
33
|
+
if (!logger) {
|
|
34
|
+
console.warn('[securenow] Console instrumentation: No logger available. Logging will not work.');
|
|
35
|
+
module.exports = {};
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
if (console.__securenow_patched) {
|
|
40
|
+
console.warn('[securenow] Console already instrumented by tracing.js — skipping to avoid duplicate logs.');
|
|
41
|
+
module.exports = {};
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
// Store original console methods
|
|
46
|
+
const originalConsole = {
|
|
47
|
+
log: console.log,
|
|
48
|
+
info: console.info,
|
|
49
|
+
warn: console.warn,
|
|
50
|
+
error: console.error,
|
|
51
|
+
debug: console.debug,
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
// Map severity levels (OpenTelemetry standard)
|
|
55
|
+
const SeverityNumber = {
|
|
56
|
+
DEBUG: 5,
|
|
57
|
+
INFO: 9,
|
|
58
|
+
WARN: 13,
|
|
59
|
+
ERROR: 17,
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* Format arguments into a log message
|
|
64
|
+
*/
|
|
65
|
+
function formatMessage(args) {
|
|
66
|
+
return args
|
|
67
|
+
.map((arg) => {
|
|
68
|
+
if (typeof arg === 'object' && arg !== null) {
|
|
69
|
+
try {
|
|
70
|
+
return JSON.stringify(arg);
|
|
71
|
+
} catch (e) {
|
|
72
|
+
return String(arg);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
return String(arg);
|
|
76
|
+
})
|
|
77
|
+
.join(' ');
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
const { context, trace } = require('@opentelemetry/api');
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* Emit a log record, correlating with the active trace/span when available
|
|
84
|
+
*/
|
|
85
|
+
function emitLog(severityNumber, severityText, args) {
|
|
86
|
+
const message = formatMessage(args);
|
|
87
|
+
|
|
88
|
+
try {
|
|
89
|
+
const activeCtx = context.active();
|
|
90
|
+
const spanCtx = trace.getSpanContext(activeCtx);
|
|
91
|
+
logger.emit({
|
|
92
|
+
severityNumber,
|
|
93
|
+
severityText,
|
|
94
|
+
body: message,
|
|
95
|
+
attributes: {
|
|
96
|
+
'log.source': 'console',
|
|
97
|
+
'log.method': severityText.toLowerCase(),
|
|
98
|
+
},
|
|
99
|
+
...(spanCtx && { context: activeCtx }),
|
|
100
|
+
});
|
|
101
|
+
} catch (e) {
|
|
102
|
+
// Silently fail to avoid breaking the application
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
// Override console.log
|
|
107
|
+
console.log = function (...args) {
|
|
108
|
+
emitLog(SeverityNumber.INFO, 'INFO', args);
|
|
109
|
+
originalConsole.log.apply(console, args);
|
|
110
|
+
};
|
|
111
|
+
|
|
112
|
+
// Override console.info
|
|
113
|
+
console.info = function (...args) {
|
|
114
|
+
emitLog(SeverityNumber.INFO, 'INFO', args);
|
|
115
|
+
originalConsole.info.apply(console, args);
|
|
116
|
+
};
|
|
117
|
+
|
|
118
|
+
// Override console.warn
|
|
119
|
+
console.warn = function (...args) {
|
|
120
|
+
emitLog(SeverityNumber.WARN, 'WARN', args);
|
|
121
|
+
originalConsole.warn.apply(console, args);
|
|
122
|
+
};
|
|
123
|
+
|
|
124
|
+
// Override console.error
|
|
125
|
+
console.error = function (...args) {
|
|
126
|
+
emitLog(SeverityNumber.ERROR, 'ERROR', args);
|
|
127
|
+
originalConsole.error.apply(console, args);
|
|
128
|
+
};
|
|
129
|
+
|
|
130
|
+
// Override console.debug
|
|
131
|
+
console.debug = function (...args) {
|
|
132
|
+
emitLog(SeverityNumber.DEBUG, 'DEBUG', args);
|
|
133
|
+
originalConsole.debug.apply(console, args);
|
|
134
|
+
};
|
|
135
|
+
|
|
136
|
+
console.log('[securenow] Console instrumentation installed - all console logs will be sent to any OTLP-compatible backend');
|
|
137
|
+
|
|
138
|
+
module.exports = {
|
|
139
|
+
originalConsole,
|
|
140
|
+
restoreConsole: () => {
|
|
141
|
+
console.log = originalConsole.log;
|
|
142
|
+
console.info = originalConsole.info;
|
|
143
|
+
console.warn = originalConsole.warn;
|
|
144
|
+
console.error = originalConsole.error;
|
|
145
|
+
console.debug = originalConsole.debug;
|
|
146
|
+
},
|
|
147
|
+
};
|