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.
Files changed (85) hide show
  1. package/LICENSE +15 -0
  2. package/README.md +40 -239
  3. package/cli.js +455 -415
  4. package/console-instrumentation.js +136 -147
  5. package/docs/ALL-FRAMEWORKS-QUICKSTART.md +455 -1339
  6. package/docs/ARCHITECTURE.md +3 -3
  7. package/docs/AUTO-BODY-CAPTURE.md +1 -1
  8. package/docs/AUTO-SETUP.md +4 -4
  9. package/docs/AUTOMATIC-IP-CAPTURE.md +5 -5
  10. package/docs/BODY-CAPTURE-QUICKSTART.md +2 -2
  11. package/docs/CHANGELOG-NEXTJS.md +1 -1
  12. package/docs/CUSTOMER-GUIDE.md +16 -16
  13. package/docs/EASIEST-SETUP.md +5 -5
  14. package/docs/ENVIRONMENT-VARIABLES.md +652 -880
  15. package/docs/EXPRESS-BODY-CAPTURE.md +12 -13
  16. package/docs/EXPRESS-SETUP-GUIDE.md +720 -719
  17. package/docs/INDEX.md +4 -22
  18. package/docs/LOGGING-GUIDE.md +708 -701
  19. package/docs/LOGGING-QUICKSTART.md +239 -234
  20. package/docs/NEXTJS-BODY-CAPTURE.md +2 -2
  21. package/docs/NEXTJS-GUIDE.md +14 -14
  22. package/docs/NEXTJS-QUICKSTART.md +1 -1
  23. package/docs/NEXTJS-WRAPPER-APPROACH.md +1 -1
  24. package/docs/QUICKSTART-BODY-CAPTURE.md +2 -2
  25. package/docs/REDACTION-EXAMPLES.md +1 -1
  26. package/docs/REQUEST-BODY-CAPTURE.md +10 -19
  27. package/docs/VERCEL-OTEL-MIGRATION.md +3 -3
  28. package/examples/README.md +6 -6
  29. package/examples/instrumentation-with-auto-capture.ts +1 -1
  30. package/examples/nextjs-env-example.txt +2 -2
  31. package/examples/nextjs-instrumentation.js +1 -1
  32. package/examples/nextjs-instrumentation.ts +1 -1
  33. package/examples/nextjs-with-logging-example.md +6 -6
  34. package/examples/nextjs-with-options.ts +1 -1
  35. package/examples/test-nextjs-setup.js +1 -1
  36. package/nextjs-auto-capture.js +207 -199
  37. package/nextjs-middleware.js +181 -186
  38. package/nextjs-webpack-config.js +53 -88
  39. package/nextjs-wrapper.js +158 -158
  40. package/nextjs.d.ts +1 -1
  41. package/nextjs.js +135 -190
  42. package/package.json +45 -67
  43. package/postinstall.js +6 -6
  44. package/register.d.ts +1 -1
  45. package/register.js +4 -39
  46. package/tracing.d.ts +1 -2
  47. package/tracing.js +22 -287
  48. package/web-vite.mjs +156 -239
  49. package/CONSUMING-APPS-GUIDE.md +0 -455
  50. package/NPM_README.md +0 -1933
  51. package/SKILL-API.md +0 -600
  52. package/SKILL-CLI.md +0 -409
  53. package/cidr.js +0 -83
  54. package/cli/apps.js +0 -585
  55. package/cli/auth.js +0 -280
  56. package/cli/client.js +0 -115
  57. package/cli/config.js +0 -173
  58. package/cli/firewall.js +0 -100
  59. package/cli/fp.js +0 -638
  60. package/cli/init.js +0 -201
  61. package/cli/monitor.js +0 -440
  62. package/cli/run.js +0 -133
  63. package/cli/security.js +0 -1064
  64. package/cli/ui.js +0 -386
  65. package/docs/API-KEYS-GUIDE.md +0 -233
  66. package/docs/AUTO-SETUP-SUMMARY.md +0 -331
  67. package/docs/BODY-CAPTURE-FIX.md +0 -261
  68. package/docs/COMPLETION-REPORT.md +0 -408
  69. package/docs/FINAL-SOLUTION.md +0 -335
  70. package/docs/FIREWALL-GUIDE.md +0 -426
  71. package/docs/IMPLEMENTATION-SUMMARY.md +0 -410
  72. package/docs/NEXTJS-BODY-CAPTURE-COMPARISON.md +0 -323
  73. package/docs/NEXTJS-SETUP-COMPLETE.md +0 -795
  74. package/docs/NUXT-GUIDE.md +0 -166
  75. package/docs/SOLUTION-SUMMARY.md +0 -312
  76. package/firewall-cloud.js +0 -212
  77. package/firewall-iptables.js +0 -139
  78. package/firewall-only.js +0 -38
  79. package/firewall-tcp.js +0 -74
  80. package/firewall.js +0 -720
  81. package/free-trial-banner.js +0 -174
  82. package/nuxt-server-plugin.mjs +0 -423
  83. package/nuxt.d.ts +0 -60
  84. package/nuxt.mjs +0 -75
  85. package/resolve-ip.js +0 -77
@@ -1,147 +1,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
- };
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/SigNoz.
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
+ // Store original console methods
40
+ const originalConsole = {
41
+ log: console.log,
42
+ info: console.info,
43
+ warn: console.warn,
44
+ error: console.error,
45
+ debug: console.debug,
46
+ };
47
+
48
+ // Map severity levels (OpenTelemetry standard)
49
+ const SeverityNumber = {
50
+ DEBUG: 5,
51
+ INFO: 9,
52
+ WARN: 13,
53
+ ERROR: 17,
54
+ };
55
+
56
+ /**
57
+ * Format arguments into a log message
58
+ */
59
+ function formatMessage(args) {
60
+ return args
61
+ .map((arg) => {
62
+ if (typeof arg === 'object' && arg !== null) {
63
+ try {
64
+ return JSON.stringify(arg);
65
+ } catch (e) {
66
+ return String(arg);
67
+ }
68
+ }
69
+ return String(arg);
70
+ })
71
+ .join(' ');
72
+ }
73
+
74
+ /**
75
+ * Emit a log record
76
+ */
77
+ function emitLog(severityNumber, severityText, args) {
78
+ const message = formatMessage(args);
79
+
80
+ try {
81
+ logger.emit({
82
+ severityNumber,
83
+ severityText,
84
+ body: message,
85
+ attributes: {
86
+ 'log.source': 'console',
87
+ 'log.method': severityText.toLowerCase(),
88
+ },
89
+ });
90
+ } catch (e) {
91
+ // Silently fail to avoid breaking the application
92
+ }
93
+ }
94
+
95
+ // Override console.log
96
+ console.log = function (...args) {
97
+ emitLog(SeverityNumber.INFO, 'INFO', args);
98
+ originalConsole.log.apply(console, args);
99
+ };
100
+
101
+ // Override console.info
102
+ console.info = function (...args) {
103
+ emitLog(SeverityNumber.INFO, 'INFO', args);
104
+ originalConsole.info.apply(console, args);
105
+ };
106
+
107
+ // Override console.warn
108
+ console.warn = function (...args) {
109
+ emitLog(SeverityNumber.WARN, 'WARN', args);
110
+ originalConsole.warn.apply(console, args);
111
+ };
112
+
113
+ // Override console.error
114
+ console.error = function (...args) {
115
+ emitLog(SeverityNumber.ERROR, 'ERROR', args);
116
+ originalConsole.error.apply(console, args);
117
+ };
118
+
119
+ // Override console.debug
120
+ console.debug = function (...args) {
121
+ emitLog(SeverityNumber.DEBUG, 'DEBUG', args);
122
+ originalConsole.debug.apply(console, args);
123
+ };
124
+
125
+ console.log('[securenow] Console instrumentation installed - all console logs will be sent to SigNoz');
126
+
127
+ module.exports = {
128
+ originalConsole,
129
+ restoreConsole: () => {
130
+ console.log = originalConsole.log;
131
+ console.info = originalConsole.info;
132
+ console.warn = originalConsole.warn;
133
+ console.error = originalConsole.error;
134
+ console.debug = originalConsole.debug;
135
+ },
136
+ };