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.
Files changed (87) hide show
  1. package/CONSUMING-APPS-GUIDE.md +455 -0
  2. package/NPM_README.md +2029 -0
  3. package/README.md +297 -40
  4. package/SKILL-API.md +634 -0
  5. package/SKILL-CLI.md +454 -0
  6. package/cidr.js +83 -0
  7. package/cli/apps.js +585 -0
  8. package/cli/auth.js +280 -0
  9. package/cli/client.js +115 -0
  10. package/cli/config.js +173 -0
  11. package/cli/diagnostics.js +387 -0
  12. package/cli/firewall.js +100 -0
  13. package/cli/fp.js +638 -0
  14. package/cli/init.js +201 -0
  15. package/cli/monitor.js +440 -0
  16. package/cli/run.js +148 -0
  17. package/cli/security.js +980 -0
  18. package/cli/ui.js +386 -0
  19. package/cli/utils.js +127 -0
  20. package/cli.js +466 -455
  21. package/console-instrumentation.js +147 -136
  22. package/docs/ALL-FRAMEWORKS-QUICKSTART.md +1377 -455
  23. package/docs/API-KEYS-GUIDE.md +233 -0
  24. package/docs/ARCHITECTURE.md +3 -3
  25. package/docs/AUTO-BODY-CAPTURE.md +1 -1
  26. package/docs/AUTO-SETUP-SUMMARY.md +331 -0
  27. package/docs/AUTO-SETUP.md +4 -4
  28. package/docs/AUTOMATIC-IP-CAPTURE.md +5 -5
  29. package/docs/BODY-CAPTURE-FIX.md +261 -0
  30. package/docs/BODY-CAPTURE-QUICKSTART.md +2 -2
  31. package/docs/CHANGELOG-NEXTJS.md +1 -35
  32. package/docs/COMPLETION-REPORT.md +408 -0
  33. package/docs/CUSTOMER-GUIDE.md +16 -16
  34. package/docs/EASIEST-SETUP.md +5 -5
  35. package/docs/ENVIRONMENT-VARIABLES.md +880 -652
  36. package/docs/EXPRESS-BODY-CAPTURE.md +13 -12
  37. package/docs/EXPRESS-SETUP-GUIDE.md +719 -720
  38. package/docs/FINAL-SOLUTION.md +335 -0
  39. package/docs/FIREWALL-GUIDE.md +426 -0
  40. package/docs/IMPLEMENTATION-SUMMARY.md +410 -0
  41. package/docs/INDEX.md +22 -4
  42. package/docs/LOGGING-GUIDE.md +701 -708
  43. package/docs/LOGGING-QUICKSTART.md +234 -255
  44. package/docs/NEXTJS-BODY-CAPTURE-COMPARISON.md +323 -0
  45. package/docs/NEXTJS-BODY-CAPTURE.md +2 -2
  46. package/docs/NEXTJS-GUIDE.md +14 -14
  47. package/docs/NEXTJS-QUICKSTART.md +1 -1
  48. package/docs/NEXTJS-SETUP-COMPLETE.md +795 -0
  49. package/docs/NEXTJS-WRAPPER-APPROACH.md +1 -1
  50. package/docs/NUXT-GUIDE.md +166 -0
  51. package/docs/QUICKSTART-BODY-CAPTURE.md +2 -2
  52. package/docs/REDACTION-EXAMPLES.md +1 -1
  53. package/docs/REQUEST-BODY-CAPTURE.md +19 -10
  54. package/docs/SOLUTION-SUMMARY.md +312 -0
  55. package/docs/VERCEL-OTEL-MIGRATION.md +3 -3
  56. package/examples/README.md +6 -6
  57. package/examples/instrumentation-with-auto-capture.ts +1 -1
  58. package/examples/nextjs-env-example.txt +2 -2
  59. package/examples/nextjs-instrumentation.js +1 -1
  60. package/examples/nextjs-instrumentation.ts +1 -1
  61. package/examples/nextjs-with-logging-example.md +6 -6
  62. package/examples/nextjs-with-options.ts +1 -1
  63. package/examples/test-nextjs-setup.js +1 -1
  64. package/firewall-cloud.js +212 -0
  65. package/firewall-iptables.js +139 -0
  66. package/firewall-only.js +38 -0
  67. package/firewall-tcp.js +74 -0
  68. package/firewall.js +720 -0
  69. package/free-trial-banner.js +174 -0
  70. package/nextjs-auto-capture.js +199 -207
  71. package/nextjs-middleware.js +186 -181
  72. package/nextjs-webpack-config.js +88 -53
  73. package/nextjs-wrapper.js +158 -158
  74. package/nextjs.d.ts +1 -1
  75. package/nextjs.js +639 -647
  76. package/nuxt-server-plugin.mjs +423 -0
  77. package/nuxt.d.ts +60 -0
  78. package/nuxt.mjs +75 -0
  79. package/package.json +186 -164
  80. package/postinstall.js +6 -6
  81. package/register.d.ts +1 -1
  82. package/register.js +39 -4
  83. package/resolve-ip.js +77 -0
  84. package/tracing.d.ts +2 -1
  85. package/tracing.js +295 -34
  86. package/web-vite.mjs +239 -156
  87. package/LICENSE +0 -15
@@ -1,652 +1,880 @@
1
- # SecureNow Environment Variables Reference
2
-
3
- Complete reference for all environment variables supported by SecureNow.
4
-
5
- ---
6
-
7
- ## Quick Reference Table
8
-
9
- | Variable | Type | Default | Description |
10
- |----------|------|---------|-------------|
11
- | **SECURENOW_APPID** | Required | - | Application identifier / service name |
12
- | **SECURENOW_INSTANCE** | Required | `https://freetrial.securenow.ai:4318` | OTLP collector base URL |
13
- | **SECURENOW_LOGGING_ENABLED** | Optional | `1` | Enable/disable logging |
14
- | **SECURENOW_NO_UUID** | Optional | `0` | Disable UUID suffix on service name |
15
- | **SECURENOW_STRICT** | Optional | `0` | Exit if APPID missing in cluster mode |
16
- | **SECURENOW_CAPTURE_BODY** | Optional | `0` | Enable request body capture |
17
- | **SECURENOW_MAX_BODY_SIZE** | Optional | `10240` | Max body size in bytes |
18
- | **SECURENOW_SENSITIVE_FIELDS** | Optional | - | Comma-separated list of fields to redact |
19
- | **SECURENOW_DISABLE_INSTRUMENTATIONS** | Optional | - | Comma-separated list of packages to disable |
20
- | **SECURENOW_TEST_SPAN** | Optional | `0` | Emit test span on startup |
21
- | **OTEL_SERVICE_NAME** | Optional | - | Alternative to SECURENOW_APPID |
22
- | **OTEL_EXPORTER_OTLP_ENDPOINT** | Optional | - | Alternative to SECURENOW_INSTANCE |
23
- | **OTEL_EXPORTER_OTLP_HEADERS** | Optional | - | Headers for OTLP requests |
24
- | **OTEL_EXPORTER_OTLP_TRACES_ENDPOINT** | Optional | - | Override traces endpoint |
25
- | **OTEL_EXPORTER_OTLP_LOGS_ENDPOINT** | Optional | - | Override logs endpoint |
26
- | **OTEL_LOG_LEVEL** | Optional | `none` | SDK log level |
27
- | **NODE_ENV** | Optional | `production` | Environment name |
28
-
29
- ---
30
-
31
- ## Required Variables
32
-
33
- ### SECURENOW_APPID
34
-
35
- **Description:** Your application identifier. Used as the service name in traces and logs.
36
-
37
- **Format:** String (alphanumeric, hyphens, underscores)
38
-
39
- **Examples:**
40
- ```bash
41
- export SECURENOW_APPID=my-express-app
42
- export SECURENOW_APPID=api-gateway
43
- export SECURENOW_APPID=user-service
44
- ```
45
-
46
- **Notes:**
47
- - If not set, SecureNow will use a fallback name with UUID
48
- - In cluster mode with `SECURENOW_STRICT=1`, missing APPID will cause process exit
49
- - Alternative: Use `OTEL_SERVICE_NAME` (OpenTelemetry standard)
50
-
51
- **Behavior:**
52
- - Without `SECURENOW_NO_UUID=1`: Service name becomes `{APPID}-{UUID}`
53
- - With `SECURENOW_NO_UUID=1`: Service name is exactly `{APPID}`
54
-
55
- ---
56
-
57
- ### SECURENOW_INSTANCE
58
-
59
- **Description:** Base URL of your OTLP collector endpoint.
60
-
61
- **Format:** URL (http/https)
62
-
63
- **Examples:**
64
- ```bash
65
- # Local collector
66
- export SECURENOW_INSTANCE=http://localhost:4318
67
-
68
- # Remote collector
69
- export SECURENOW_INSTANCE=http://collector.example.com:4318
70
-
71
- # HTTPS
72
- export SECURENOW_INSTANCE=https://collector.example.com:4318
73
- ```
74
-
75
- **Default:** `https://freetrial.securenow.ai:4318` (if not set)
76
-
77
- **Notes:**
78
- - Used to construct traces and logs endpoints
79
- - Traces sent to: `{SECURENOW_INSTANCE}/v1/traces`
80
- - Logs sent to: `{SECURENOW_INSTANCE}/v1/logs`
81
- - Alternative: Use `OTEL_EXPORTER_OTLP_ENDPOINT`
82
-
83
- ---
84
-
85
- ## Service Naming
86
-
87
- ### OTEL_SERVICE_NAME
88
-
89
- **Description:** Standard OpenTelemetry variable for service name. Alternative to `SECURENOW_APPID`.
90
-
91
- **Format:** String
92
-
93
- **Example:**
94
- ```bash
95
- export OTEL_SERVICE_NAME=my-app
96
- ```
97
-
98
- **Priority:** If both are set, `OTEL_SERVICE_NAME` takes precedence.
99
-
100
- ---
101
-
102
- ### SECURENOW_NO_UUID
103
-
104
- **Description:** Disable automatic UUID suffix on service name.
105
-
106
- **Format:** `1` (enabled) or `0` (disabled)
107
-
108
- **Default:** `0`
109
-
110
- **Example:**
111
- ```bash
112
- export SECURENOW_NO_UUID=1
113
- ```
114
-
115
- **Use case:**
116
- - PM2 cluster mode - use same service name for all workers
117
- - Docker containers with replica sets
118
- - Kubernetes pods in a deployment
119
-
120
- **Behavior:**
121
- - `0`: Service name = `my-app-a1b2c3d4`
122
- - `1`: Service name = `my-app`
123
-
124
- ---
125
-
126
- ### SECURENOW_STRICT
127
-
128
- **Description:** Exit process if `SECURENOW_APPID` is not set in cluster mode.
129
-
130
- **Format:** `1` (enabled) or `0` (disabled)
131
-
132
- **Default:** `0`
133
-
134
- **Example:**
135
- ```bash
136
- export SECURENOW_STRICT=1
137
- ```
138
-
139
- **Use case:**
140
- - Production environments where service name must be explicit
141
- - Prevent "free" or auto-generated service names
142
- - Ensure proper configuration before starting
143
-
144
- **Detection:**
145
- Cluster mode is detected when any of these exist:
146
- - `NODE_APP_INSTANCE` (PM2)
147
- - `pm_id` (PM2)
148
-
149
- ---
150
-
151
- ## Connection Settings
152
-
153
- ### OTEL_EXPORTER_OTLP_ENDPOINT
154
-
155
- **Description:** Standard OpenTelemetry variable for OTLP endpoint. Alternative to `SECURENOW_INSTANCE`.
156
-
157
- **Format:** URL
158
-
159
- **Example:**
160
- ```bash
161
- export OTEL_EXPORTER_OTLP_ENDPOINT=http://localhost:4318
162
- ```
163
-
164
- **Priority:** If both are set, `OTEL_EXPORTER_OTLP_ENDPOINT` takes precedence.
165
-
166
- ---
167
-
168
- ### OTEL_EXPORTER_OTLP_TRACES_ENDPOINT
169
-
170
- **Description:** Override the traces endpoint specifically.
171
-
172
- **Format:** Full URL including `/v1/traces`
173
-
174
- **Example:**
175
- ```bash
176
- export OTEL_EXPORTER_OTLP_TRACES_ENDPOINT=http://traces-collector:4318/v1/traces
177
- ```
178
-
179
- **Use case:**
180
- - Separate collectors for traces and logs
181
- - Different routing for traces
182
-
183
- ---
184
-
185
- ### OTEL_EXPORTER_OTLP_LOGS_ENDPOINT
186
-
187
- **Description:** Override the logs endpoint specifically.
188
-
189
- **Format:** Full URL including `/v1/logs`
190
-
191
- **Example:**
192
- ```bash
193
- export OTEL_EXPORTER_OTLP_LOGS_ENDPOINT=http://logs-collector:4318/v1/logs
194
- ```
195
-
196
- **Use case:**
197
- - Separate collectors for traces and logs
198
- - Different routing for logs
199
-
200
- ---
201
-
202
- ### OTEL_EXPORTER_OTLP_HEADERS
203
-
204
- **Description:** Headers to include in OTLP export requests.
205
-
206
- **Format:** Comma-separated `key=value` pairs
207
-
208
- **Examples:**
209
- ```bash
210
- # Single header
211
- export OTEL_EXPORTER_OTLP_HEADERS="x-api-key=your-api-key"
212
-
213
- # Multiple headers
214
- export OTEL_EXPORTER_OTLP_HEADERS="x-api-key=key123,x-tenant-id=tenant456"
215
-
216
- # Authentication
217
- export OTEL_EXPORTER_OTLP_HEADERS="authorization=Bearer token123"
218
- ```
219
-
220
- **Use case:**
221
- - API authentication
222
- - Multi-tenancy headers
223
- - Custom routing headers
224
-
225
- **Notes:**
226
- - Header names are case-insensitive
227
- - Trailing/leading spaces are trimmed
228
-
229
- ---
230
-
231
- ## Logging
232
-
233
- ### SECURENOW_LOGGING_ENABLED
234
-
235
- **Description:** Enable or disable automatic logging to OTLP backend.
236
-
237
- **Format:** `1` (enabled) or `0` (disabled)
238
-
239
- **Default:** `1` (enabled by default)
240
-
241
- **Examples:**
242
- ```bash
243
- # Enable logging
244
- export SECURENOW_LOGGING_ENABLED=1
245
-
246
- # Disable logging
247
- export SECURENOW_LOGGING_ENABLED=0
248
- ```
249
-
250
- **When enabled:**
251
- - Logs are sent to `{SECURENOW_INSTANCE}/v1/logs`
252
- - Console instrumentation can capture logs
253
- - Direct logger API is available
254
-
255
- **When disabled:**
256
- - No logs sent to backend
257
- - `getLogger()` returns `null`
258
- - Console instrumentation shows warning
259
-
260
- ---
261
-
262
- ## Request Body Capture
263
-
264
- ### SECURENOW_CAPTURE_BODY
265
-
266
- **Description:** Enable capture of HTTP request bodies in traces.
267
-
268
- **Format:** `1` (enabled) or `0` (disabled)
269
-
270
- **Default:** `0` (disabled)
271
-
272
- **Example:**
273
- ```bash
274
- export SECURENOW_CAPTURE_BODY=1
275
- ```
276
-
277
- **Supported content types:**
278
- - `application/json`
279
- - `application/x-www-form-urlencoded`
280
- - `application/graphql`
281
-
282
- **Not captured:**
283
- - `multipart/form-data` (file uploads)
284
- - Bodies larger than `SECURENOW_MAX_BODY_SIZE`
285
-
286
- **Security:**
287
- All captured bodies are automatically scanned for sensitive fields and redacted.
288
-
289
- ---
290
-
291
- ### SECURENOW_MAX_BODY_SIZE
292
-
293
- **Description:** Maximum request body size to capture (in bytes).
294
-
295
- **Format:** Number (bytes)
296
-
297
- **Default:** `10240` (10 KB)
298
-
299
- **Examples:**
300
- ```bash
301
- # 10 KB (default)
302
- export SECURENOW_MAX_BODY_SIZE=10240
303
-
304
- # 20 KB
305
- export SECURENOW_MAX_BODY_SIZE=20480
306
-
307
- # 5 KB
308
- export SECURENOW_MAX_BODY_SIZE=5120
309
- ```
310
-
311
- **Behavior:**
312
- - Bodies larger than this are not captured
313
- - Span attribute shows: `[TOO LARGE: {size} bytes]`
314
-
315
- ---
316
-
317
- ### SECURENOW_SENSITIVE_FIELDS
318
-
319
- **Description:** Additional field names to redact from request bodies (comma-separated).
320
-
321
- **Format:** Comma-separated list of field names
322
-
323
- **Default:** (see below for auto-redacted fields)
324
-
325
- **Examples:**
326
- ```bash
327
- # Additional custom fields
328
- export SECURENOW_SENSITIVE_FIELDS="internal_token,session_key"
329
-
330
- # Multiple fields
331
- export SECURENOW_SENSITIVE_FIELDS="custom_secret,private_data,internal_id"
332
- ```
333
-
334
- **Auto-redacted fields (built-in):**
335
- - `password`, `passwd`, `pwd`
336
- - `secret`, `token`, `api_key`, `apikey`, `access_token`
337
- - `auth`, `credentials`, `mysql_pwd`
338
- - `stripeToken`, `card`, `cardnumber`
339
- - `ccv`, `cvc`, `cvv`
340
- - `ssn`, `pin`
341
-
342
- **Matching:**
343
- - Case-insensitive
344
- - Substring match (e.g., `password` matches `user_password`, `PASSWORD`, `passwordField`)
345
- - Works recursively in nested objects
346
-
347
- ---
348
-
349
- ## Instrumentation Control
350
-
351
- ### SECURENOW_DISABLE_INSTRUMENTATIONS
352
-
353
- **Description:** Disable specific OpenTelemetry instrumentations.
354
-
355
- **Format:** Comma-separated list of package names
356
-
357
- **Example:**
358
- ```bash
359
- # Disable file system and DNS instrumentations
360
- export SECURENOW_DISABLE_INSTRUMENTATIONS=fs,dns
361
-
362
- # Disable multiple
363
- export SECURENOW_DISABLE_INSTRUMENTATIONS=fs,dns,net,http2
364
- ```
365
-
366
- **Common packages you might disable:**
367
- - `fs` - File system operations
368
- - `dns` - DNS lookups
369
- - `net` - Network operations
370
- - `http2` - HTTP/2 client/server
371
- - `grpc` - gRPC client/server
372
-
373
- **Use case:**
374
- - Reduce overhead by disabling unused instrumentations
375
- - Avoid noisy traces from certain operations
376
- - Debug issues with specific instrumentations
377
-
378
- ---
379
-
380
- ## Debugging
381
-
382
- ### OTEL_LOG_LEVEL
383
-
384
- **Description:** OpenTelemetry SDK internal log level.
385
-
386
- **Format:** `none`, `error`, `warn`, `info`, `debug`
387
-
388
- **Default:** `none`
389
-
390
- **Examples:**
391
- ```bash
392
- # See all debug information
393
- export OTEL_LOG_LEVEL=debug
394
-
395
- # Only errors
396
- export OTEL_LOG_LEVEL=error
397
-
398
- # No SDK logs
399
- export OTEL_LOG_LEVEL=none
400
- ```
401
-
402
- **Use case:**
403
- - Troubleshooting setup issues
404
- - Understanding trace/log export behavior
405
- - Debugging connection problems
406
-
407
- **Output:**
408
- - Goes to console (stderr)
409
- - Prefixed with `[securenow]`
410
-
411
- ---
412
-
413
- ### SECURENOW_TEST_SPAN
414
-
415
- **Description:** Emit a test span on startup to verify tracing is working.
416
-
417
- **Format:** `1` (enabled) or `0` (disabled)
418
-
419
- **Default:** `0`
420
-
421
- **Example:**
422
- ```bash
423
- export SECURENOW_TEST_SPAN=1
424
- ```
425
-
426
- **Behavior:**
427
- - Creates a span named `securenow.startup.smoke`
428
- - Span is immediately ended
429
- - Useful for testing collector connectivity
430
-
431
- ---
432
-
433
- ## Environment
434
-
435
- ### NODE_ENV
436
-
437
- **Description:** Standard Node.js environment variable. Sent as `deployment.environment` attribute.
438
-
439
- **Format:** String (typically: `development`, `production`, `test`, `staging`)
440
-
441
- **Default:** `production`
442
-
443
- **Examples:**
444
- ```bash
445
- export NODE_ENV=development
446
- export NODE_ENV=production
447
- export NODE_ENV=staging
448
- export NODE_ENV=test
449
- ```
450
-
451
- **Use case:**
452
- - Filter traces/logs by environment
453
- - Different configurations per environment
454
- - Standard Node.js convention
455
-
456
- ---
457
-
458
- ## Configuration Examples
459
-
460
- ### Development Environment
461
-
462
- ```bash
463
- # .env.development
464
- SECURENOW_APPID=my-app-dev
465
- SECURENOW_INSTANCE=http://localhost:4318
466
- SECURENOW_LOGGING_ENABLED=1
467
- SECURENOW_CAPTURE_BODY=1
468
- SECURENOW_MAX_BODY_SIZE=20480
469
- OTEL_LOG_LEVEL=debug
470
- SECURENOW_TEST_SPAN=1
471
- NODE_ENV=development
472
- ```
473
-
474
- ### Production Environment
475
-
476
- ```bash
477
- # .env.production
478
- SECURENOW_APPID=my-app-prod
479
- SECURENOW_INSTANCE=https://collector.prod.example.com:4318
480
- OTEL_EXPORTER_OTLP_HEADERS=x-api-key=prod-key-12345
481
- SECURENOW_LOGGING_ENABLED=1
482
- SECURENOW_CAPTURE_BODY=0
483
- SECURENOW_NO_UUID=1
484
- SECURENOW_STRICT=1
485
- SECURENOW_SENSITIVE_FIELDS=internal_id,session_token
486
- OTEL_LOG_LEVEL=error
487
- NODE_ENV=production
488
- ```
489
-
490
- ### PM2 Cluster
491
-
492
- ```bash
493
- # ecosystem.config.js environment
494
- SECURENOW_APPID=my-app
495
- SECURENOW_INSTANCE=http://localhost:4318
496
- SECURENOW_LOGGING_ENABLED=1
497
- SECURENOW_NO_UUID=1
498
- SECURENOW_STRICT=1
499
- SECURENOW_CAPTURE_BODY=1
500
- NODE_ENV=production
501
- ```
502
-
503
- ### Docker / Kubernetes
504
-
505
- ```bash
506
- # Docker environment or K8s ConfigMap
507
- SECURENOW_APPID=my-service
508
- SECURENOW_INSTANCE=http://otel-collector:4318
509
- SECURENOW_LOGGING_ENABLED=1
510
- SECURENOW_NO_UUID=1
511
- SECURENOW_CAPTURE_BODY=0
512
- NODE_ENV=production
513
- ```
514
-
515
- ### Separate Collectors for Traces and Logs
516
-
517
- ```bash
518
- # Different backends for traces and logs
519
- SECURENOW_APPID=my-app
520
- OTEL_EXPORTER_OTLP_TRACES_ENDPOINT=http://traces-collector:4318/v1/traces
521
- OTEL_EXPORTER_OTLP_LOGS_ENDPOINT=http://logs-collector:4318/v1/logs
522
- SECURENOW_LOGGING_ENABLED=1
523
- ```
524
-
525
- ---
526
-
527
- ## Priority and Overrides
528
-
529
- When multiple variables are set, this is the priority order:
530
-
531
- ### Service Name
532
-
533
- 1. `OTEL_SERVICE_NAME` (highest priority)
534
- 2. `SECURENOW_APPID`
535
- 3. Auto-generated fallback (lowest priority)
536
-
537
- ### OTLP Endpoint
538
-
539
- 1. `OTEL_EXPORTER_OTLP_TRACES_ENDPOINT` (for traces)
540
- 2. `OTEL_EXPORTER_OTLP_LOGS_ENDPOINT` (for logs)
541
- 3. `OTEL_EXPORTER_OTLP_ENDPOINT`
542
- 4. `SECURENOW_INSTANCE`
543
- 5. Default: `https://freetrial.securenow.ai:4318` (lowest priority)
544
-
545
- ---
546
-
547
- ## Validation
548
-
549
- SecureNow validates environment variables on startup. Check console output:
550
-
551
- ```bash
552
- [securenow] pid=12345 SECURENOW_APPID="my-app" OTEL_SERVICE_NAME=null → service.name=my-app-uuid123
553
- [securenow] OTel SDK started → http://localhost:4318/v1/traces
554
- [securenow] 📋 Logging: ENABLED → http://localhost:4318/v1/logs
555
- [securenow] 📝 Request body capture: ENABLED (max: 10240 bytes)
556
- ```
557
-
558
- ---
559
-
560
- ## Best Practices
561
-
562
- ### 1. Use .env Files
563
-
564
- Don't hardcode in your application:
565
-
566
- ```bash
567
- # .env
568
- SECURENOW_APPID=my-app
569
- SECURENOW_INSTANCE=http://localhost:4318
570
- ```
571
-
572
- ### 2. Different Configs per Environment
573
-
574
- ```bash
575
- # .env.development
576
- SECURENOW_CAPTURE_BODY=1
577
- OTEL_LOG_LEVEL=debug
578
-
579
- # .env.production
580
- SECURENOW_CAPTURE_BODY=0
581
- OTEL_LOG_LEVEL=error
582
- ```
583
-
584
- ### 3. Use SECURENOW_NO_UUID in Clusters
585
-
586
- ```bash
587
- # PM2 cluster with 4 workers
588
- SECURENOW_NO_UUID=1
589
- ```
590
-
591
- ### 4. Enable SECURENOW_STRICT in Production
592
-
593
- ```bash
594
- # Fail fast if misconfigured
595
- SECURENOW_STRICT=1
596
- ```
597
-
598
- ### 5. Disable Body Capture in Production
599
-
600
- ```bash
601
- # Development
602
- SECURENOW_CAPTURE_BODY=1
603
-
604
- # Production
605
- SECURENOW_CAPTURE_BODY=0
606
- ```
607
-
608
- ---
609
-
610
- ## Troubleshooting
611
-
612
- ### Check Current Values
613
-
614
- ```bash
615
- # Print all SECURENOW variables
616
- env | grep SECURENOW
617
-
618
- # Print all OTEL variables
619
- env | grep OTEL
620
-
621
- # Check specific variable
622
- echo $SECURENOW_APPID
623
- ```
624
-
625
- ### Verify in Application
626
-
627
- SecureNow logs current configuration on startup. Look for lines like:
628
-
629
- ```
630
- [securenow] pid=12345 SECURENOW_APPID="my-app" → service.name=my-app
631
- [securenow] OTel SDK started http://localhost:4318/v1/traces
632
- ```
633
-
634
- ### Enable Debug Mode
635
-
636
- ```bash
637
- export OTEL_LOG_LEVEL=debug
638
- node app.js
639
- ```
640
-
641
- ---
642
-
643
- ## Related Documentation
644
-
645
- - [Express Setup Guide](./EXPRESS-SETUP-GUIDE.md)
646
- - [Next.js Setup Guide](./NEXTJS-SETUP-COMPLETE.md)
647
- - [Logging Guide](./LOGGING-GUIDE.md)
648
- - [NPM README](../NPM_README.md)
649
-
650
- ---
651
-
652
- **Complete reference for all SecureNow environment variables.** 🎯
1
+ # SecureNow Environment Variables Reference
2
+
3
+ Complete reference for all environment variables supported by SecureNow.
4
+
5
+ ---
6
+
7
+ ## Quick Reference Table
8
+
9
+ | Variable | Type | Default | Description |
10
+ |----------|------|---------|-------------|
11
+ | **SECURENOW_APPID** | Required | - | Application identifier / service name |
12
+ | **SECURENOW_INSTANCE** | Required | `https://freetrial.securenow.ai:4318` | OTLP collector base URL |
13
+ | **SECURENOW_LOGGING_ENABLED** | Optional | `1` | Enable/disable logging |
14
+ | **SECURENOW_NO_UUID** | Optional | `0` | Disable UUID suffix on service name |
15
+ | **SECURENOW_STRICT** | Optional | `0` | Exit if APPID missing in cluster mode |
16
+ | **SECURENOW_CAPTURE_BODY** | Optional | `0` | Enable request body capture |
17
+ | **SECURENOW_MAX_BODY_SIZE** | Optional | `10240` | Max body size in bytes |
18
+ | **SECURENOW_SENSITIVE_FIELDS** | Optional | - | Comma-separated list of fields to redact |
19
+ | **SECURENOW_CAPTURE_MULTIPART** | Optional | `0` | Enable multipart/form-data streaming capture |
20
+ | **SECURENOW_DISABLE_INSTRUMENTATIONS** | Optional | - | Comma-separated list of packages to disable |
21
+ | **SECURENOW_TEST_SPAN** | Optional | `0` | Emit test span on startup |
22
+ | **OTEL_SERVICE_NAME** | Optional | - | Alternative to SECURENOW_APPID |
23
+ | **OTEL_EXPORTER_OTLP_ENDPOINT** | Optional | - | Alternative to SECURENOW_INSTANCE |
24
+ | **OTEL_EXPORTER_OTLP_HEADERS** | Optional | - | Headers for OTLP requests |
25
+ | **OTEL_EXPORTER_OTLP_TRACES_ENDPOINT** | Optional | - | Override traces endpoint |
26
+ | **OTEL_EXPORTER_OTLP_LOGS_ENDPOINT** | Optional | - | Override logs endpoint |
27
+ | **OTEL_LOG_LEVEL** | Optional | `none` | SDK log level |
28
+ | **NODE_ENV** | Optional | `production` | Environment name |
29
+ | **SECURENOW_API_KEY** | Optional | - | API key for firewall (auto-activates when set) |
30
+ | **SECURENOW_API_URL** | Optional | `https://api.securenow.ai` | API base URL |
31
+ | **SECURENOW_FIREWALL_ENABLED** | Optional | `1` | Firewall master kill-switch |
32
+ | **SECURENOW_FIREWALL_SYNC_INTERVAL** | Optional | `60` | Blocklist refresh interval (seconds) |
33
+ | **SECURENOW_FIREWALL_FAIL_MODE** | Optional | `open` | Behavior when API unreachable: open/closed |
34
+ | **SECURENOW_FIREWALL_STATUS_CODE** | Optional | `403` | HTTP status for blocked requests |
35
+ | **SECURENOW_FIREWALL_LOG** | Optional | `1` | Log blocked requests |
36
+ | **SECURENOW_FIREWALL_TCP** | Optional | `0` | Enable Layer 2 TCP blocking |
37
+ | **SECURENOW_FIREWALL_IPTABLES** | Optional | `0` | Enable Layer 3 iptables blocking |
38
+ | **SECURENOW_FIREWALL_CLOUD** | Optional | - | Cloud WAF provider (cloudflare/aws/gcp) |
39
+ | **SECURENOW_TRUSTED_PROXIES** | Optional | - | Trusted proxy IPs for X-Forwarded-For |
40
+
41
+ ---
42
+
43
+ ## Required Variables
44
+
45
+ ### SECURENOW_APPID
46
+
47
+ **Description:** Your application identifier. Used as the service name in traces and logs.
48
+
49
+ **Format:** String (alphanumeric, hyphens, underscores)
50
+
51
+ **Examples:**
52
+ ```bash
53
+ export SECURENOW_APPID=my-express-app
54
+ export SECURENOW_APPID=api-gateway
55
+ export SECURENOW_APPID=user-service
56
+ ```
57
+
58
+ **Notes:**
59
+ - If not set, SecureNow will use a fallback name with UUID
60
+ - In cluster mode with `SECURENOW_STRICT=1`, missing APPID will cause process exit
61
+ - Alternative: Use `OTEL_SERVICE_NAME` (OpenTelemetry standard)
62
+
63
+ **Behavior:**
64
+ - Without `SECURENOW_NO_UUID=1`: Service name becomes `{APPID}-{UUID}`
65
+ - With `SECURENOW_NO_UUID=1`: Service name is exactly `{APPID}`
66
+
67
+ ---
68
+
69
+ ### SECURENOW_INSTANCE
70
+
71
+ **Description:** Base URL of your OTLP collector endpoint.
72
+
73
+ **Format:** URL (http/https)
74
+
75
+ **Examples:**
76
+ ```bash
77
+ # Local collector
78
+ export SECURENOW_INSTANCE=http://localhost:4318
79
+
80
+ # Remote collector
81
+ export SECURENOW_INSTANCE=http://collector.example.com:4318
82
+
83
+ # HTTPS
84
+ export SECURENOW_INSTANCE=https://collector.example.com:4318
85
+ ```
86
+
87
+ **Default:** `https://freetrial.securenow.ai:4318` (if not set)
88
+
89
+ **Notes:**
90
+ - Used to construct traces and logs endpoints
91
+ - Traces sent to: `{SECURENOW_INSTANCE}/v1/traces`
92
+ - Logs sent to: `{SECURENOW_INSTANCE}/v1/logs`
93
+ - Alternative: Use `OTEL_EXPORTER_OTLP_ENDPOINT`
94
+
95
+ ---
96
+
97
+ ## Service Naming
98
+
99
+ ### OTEL_SERVICE_NAME
100
+
101
+ **Description:** Standard OpenTelemetry variable for service name. Alternative to `SECURENOW_APPID`.
102
+
103
+ **Format:** String
104
+
105
+ **Example:**
106
+ ```bash
107
+ export OTEL_SERVICE_NAME=my-app
108
+ ```
109
+
110
+ **Priority:** If both are set, `OTEL_SERVICE_NAME` takes precedence.
111
+
112
+ ---
113
+
114
+ ### SECURENOW_NO_UUID
115
+
116
+ **Description:** Disable automatic UUID suffix on service name.
117
+
118
+ **Format:** `1` (enabled) or `0` (disabled)
119
+
120
+ **Default:** `0`
121
+
122
+ **Example:**
123
+ ```bash
124
+ export SECURENOW_NO_UUID=1
125
+ ```
126
+
127
+ **Use case:**
128
+ - PM2 cluster mode - use same service name for all workers
129
+ - Docker containers with replica sets
130
+ - Kubernetes pods in a deployment
131
+
132
+ **Behavior:**
133
+ - `0`: Service name = `my-app-a1b2c3d4`
134
+ - `1`: Service name = `my-app`
135
+
136
+ ---
137
+
138
+ ### SECURENOW_STRICT
139
+
140
+ **Description:** Exit process if `SECURENOW_APPID` is not set in cluster mode.
141
+
142
+ **Format:** `1` (enabled) or `0` (disabled)
143
+
144
+ **Default:** `0`
145
+
146
+ **Example:**
147
+ ```bash
148
+ export SECURENOW_STRICT=1
149
+ ```
150
+
151
+ **Use case:**
152
+ - Production environments where service name must be explicit
153
+ - Prevent "free" or auto-generated service names
154
+ - Ensure proper configuration before starting
155
+
156
+ **Detection:**
157
+ Cluster mode is detected when any of these exist:
158
+ - `NODE_APP_INSTANCE` (PM2)
159
+ - `pm_id` (PM2)
160
+
161
+ ---
162
+
163
+ ## Connection Settings
164
+
165
+ ### OTEL_EXPORTER_OTLP_ENDPOINT
166
+
167
+ **Description:** Standard OpenTelemetry variable for OTLP endpoint. Alternative to `SECURENOW_INSTANCE`.
168
+
169
+ **Format:** URL
170
+
171
+ **Example:**
172
+ ```bash
173
+ export OTEL_EXPORTER_OTLP_ENDPOINT=http://localhost:4318
174
+ ```
175
+
176
+ **Priority:** If both are set, `OTEL_EXPORTER_OTLP_ENDPOINT` takes precedence.
177
+
178
+ ---
179
+
180
+ ### OTEL_EXPORTER_OTLP_TRACES_ENDPOINT
181
+
182
+ **Description:** Override the traces endpoint specifically.
183
+
184
+ **Format:** Full URL including `/v1/traces`
185
+
186
+ **Example:**
187
+ ```bash
188
+ export OTEL_EXPORTER_OTLP_TRACES_ENDPOINT=http://traces-collector:4318/v1/traces
189
+ ```
190
+
191
+ **Use case:**
192
+ - Separate collectors for traces and logs
193
+ - Different routing for traces
194
+
195
+ ---
196
+
197
+ ### OTEL_EXPORTER_OTLP_LOGS_ENDPOINT
198
+
199
+ **Description:** Override the logs endpoint specifically.
200
+
201
+ **Format:** Full URL including `/v1/logs`
202
+
203
+ **Example:**
204
+ ```bash
205
+ export OTEL_EXPORTER_OTLP_LOGS_ENDPOINT=http://logs-collector:4318/v1/logs
206
+ ```
207
+
208
+ **Use case:**
209
+ - Separate collectors for traces and logs
210
+ - Different routing for logs
211
+
212
+ ---
213
+
214
+ ### OTEL_EXPORTER_OTLP_HEADERS
215
+
216
+ **Description:** Headers to include in OTLP export requests.
217
+
218
+ **Format:** Comma-separated `key=value` pairs
219
+
220
+ **Examples:**
221
+ ```bash
222
+ # Single header
223
+ export OTEL_EXPORTER_OTLP_HEADERS="x-api-key=your-api-key"
224
+
225
+ # Multiple headers
226
+ export OTEL_EXPORTER_OTLP_HEADERS="x-api-key=key123,x-tenant-id=tenant456"
227
+
228
+ # Authentication
229
+ export OTEL_EXPORTER_OTLP_HEADERS="authorization=Bearer token123"
230
+ ```
231
+
232
+ **Use case:**
233
+ - API authentication
234
+ - Multi-tenancy headers
235
+ - Custom routing headers
236
+
237
+ **Notes:**
238
+ - Header names are case-insensitive
239
+ - Trailing/leading spaces are trimmed
240
+
241
+ ---
242
+
243
+ ## Logging
244
+
245
+ ### SECURENOW_LOGGING_ENABLED
246
+
247
+ **Description:** Enable or disable automatic logging to OTLP backend.
248
+
249
+ **Format:** `1` (enabled) or `0` (disabled)
250
+
251
+ **Default:** `1` (enabled by default)
252
+
253
+ **Examples:**
254
+ ```bash
255
+ # Enable logging
256
+ export SECURENOW_LOGGING_ENABLED=1
257
+
258
+ # Disable logging
259
+ export SECURENOW_LOGGING_ENABLED=0
260
+ ```
261
+
262
+ **When enabled:**
263
+ - Logs are sent to `{SECURENOW_INSTANCE}/v1/logs`
264
+ - Console instrumentation can capture logs
265
+ - Direct logger API is available
266
+
267
+ **When disabled:**
268
+ - No logs sent to backend
269
+ - `getLogger()` returns `null`
270
+ - Console instrumentation shows warning
271
+
272
+ ---
273
+
274
+ ## Request Body Capture
275
+
276
+ ### SECURENOW_CAPTURE_BODY
277
+
278
+ **Description:** Enable capture of HTTP request bodies in traces.
279
+
280
+ **Format:** `1` (enabled) or `0` (disabled)
281
+
282
+ **Default:** `0` (disabled)
283
+
284
+ **Example:**
285
+ ```bash
286
+ export SECURENOW_CAPTURE_BODY=1
287
+ ```
288
+
289
+ **Supported content types:**
290
+ - `application/json`
291
+ - `application/x-www-form-urlencoded`
292
+ - `application/graphql`
293
+
294
+ **Not captured (unless separately enabled):**
295
+ - `multipart/form-data` — requires `SECURENOW_CAPTURE_MULTIPART=1` (see below)
296
+ - Bodies larger than `SECURENOW_MAX_BODY_SIZE`
297
+
298
+ **Security:**
299
+ All captured bodies are automatically scanned for sensitive fields and redacted.
300
+
301
+ ---
302
+
303
+ ### SECURENOW_MAX_BODY_SIZE
304
+
305
+ **Description:** Maximum request body size to capture (in bytes).
306
+
307
+ **Format:** Number (bytes)
308
+
309
+ **Default:** `10240` (10 KB)
310
+
311
+ **Examples:**
312
+ ```bash
313
+ # 10 KB (default)
314
+ export SECURENOW_MAX_BODY_SIZE=10240
315
+
316
+ # 20 KB
317
+ export SECURENOW_MAX_BODY_SIZE=20480
318
+
319
+ # 5 KB
320
+ export SECURENOW_MAX_BODY_SIZE=5120
321
+ ```
322
+
323
+ **Behavior:**
324
+ - Bodies larger than this are not captured
325
+ - Span attribute shows: `[TOO LARGE: {size} bytes]`
326
+
327
+ ---
328
+
329
+ ### SECURENOW_SENSITIVE_FIELDS
330
+
331
+ **Description:** Additional field names to redact from request bodies (comma-separated).
332
+
333
+ **Format:** Comma-separated list of field names
334
+
335
+ **Default:** (see below for auto-redacted fields)
336
+
337
+ **Examples:**
338
+ ```bash
339
+ # Additional custom fields
340
+ export SECURENOW_SENSITIVE_FIELDS="internal_token,session_key"
341
+
342
+ # Multiple fields
343
+ export SECURENOW_SENSITIVE_FIELDS="custom_secret,private_data,internal_id"
344
+ ```
345
+
346
+ **Auto-redacted fields (built-in):**
347
+ - `password`, `passwd`, `pwd`
348
+ - `secret`, `token`, `api_key`, `apikey`, `access_token`
349
+ - `auth`, `credentials`, `mysql_pwd`
350
+ - `stripeToken`, `card`, `cardnumber`
351
+ - `ccv`, `cvc`, `cvv`
352
+ - `ssn`, `pin`
353
+
354
+ **Matching:**
355
+ - Case-insensitive
356
+ - Substring match (e.g., `password` matches `user_password`, `PASSWORD`, `passwordField`)
357
+ - Works recursively in nested objects
358
+
359
+ ---
360
+
361
+ ### SECURENOW_CAPTURE_MULTIPART
362
+
363
+ **Description:** Enable capture of `multipart/form-data` request bodies (file upload metadata and text fields). Uses a streaming parser that processes boundary markers on the fly — file binary content is never buffered or stored.
364
+
365
+ **Format:** `1` (enabled) or `0` (disabled)
366
+
367
+ **Default:** `0` (disabled)
368
+
369
+ **Example:**
370
+ ```bash
371
+ export SECURENOW_CAPTURE_MULTIPART=1
372
+ ```
373
+
374
+ **What gets captured:**
375
+ - **Text fields** field name and value (up to 1000 characters), with sensitive fields auto-redacted
376
+ - **File fields** metadata only: field name, filename, content-type, and size in bytes (no binary content)
377
+
378
+ **Example span attribute (`http.request.body`):**
379
+ ```json
380
+ {
381
+ "fields": { "description": "My upload", "token": "[REDACTED]" },
382
+ "files": [
383
+ { "field": "avatar", "filename": "photo.jpg", "contentType": "image/jpeg", "size": 524288 },
384
+ { "field": "document", "filename": "report.pdf", "contentType": "application/pdf", "size": 1048576 }
385
+ ]
386
+ }
387
+ ```
388
+
389
+ **Additional span attributes set:**
390
+ - `http.request.body.type` = `"multipart"`
391
+ - `http.request.body.size` — total raw request body size in bytes
392
+ - `http.request.body.fields_count` number of text fields
393
+ - `http.request.body.files_count` — number of file fields
394
+
395
+ **Memory:** Bounded at ~few KB regardless of upload size (streaming parser discards file content as it passes through).
396
+
397
+ **Parts limit:** 100 parts maximum per request (safety guard).
398
+
399
+ **Requires:** `SECURENOW_CAPTURE_BODY=1` must also be set (multipart capture is gated behind general body capture).
400
+
401
+ **Since:** v5.8.0
402
+
403
+ ---
404
+
405
+ ## Instrumentation Control
406
+
407
+ ### SECURENOW_DISABLE_INSTRUMENTATIONS
408
+
409
+ **Description:** Disable specific OpenTelemetry instrumentations.
410
+
411
+ **Format:** Comma-separated list of package names
412
+
413
+ **Example:**
414
+ ```bash
415
+ # Disable file system and DNS instrumentations
416
+ export SECURENOW_DISABLE_INSTRUMENTATIONS=fs,dns
417
+
418
+ # Disable multiple
419
+ export SECURENOW_DISABLE_INSTRUMENTATIONS=fs,dns,net,http2
420
+ ```
421
+
422
+ **Common packages you might disable:**
423
+ - `fs` - File system operations
424
+ - `dns` - DNS lookups
425
+ - `net` - Network operations
426
+ - `http2` - HTTP/2 client/server
427
+ - `grpc` - gRPC client/server
428
+
429
+ **Use case:**
430
+ - Reduce overhead by disabling unused instrumentations
431
+ - Avoid noisy traces from certain operations
432
+ - Debug issues with specific instrumentations
433
+
434
+ ---
435
+
436
+ ## Debugging
437
+
438
+ ### OTEL_LOG_LEVEL
439
+
440
+ **Description:** OpenTelemetry SDK internal log level.
441
+
442
+ **Format:** `none`, `error`, `warn`, `info`, `debug`
443
+
444
+ **Default:** `none`
445
+
446
+ **Examples:**
447
+ ```bash
448
+ # See all debug information
449
+ export OTEL_LOG_LEVEL=debug
450
+
451
+ # Only errors
452
+ export OTEL_LOG_LEVEL=error
453
+
454
+ # No SDK logs
455
+ export OTEL_LOG_LEVEL=none
456
+ ```
457
+
458
+ **Use case:**
459
+ - Troubleshooting setup issues
460
+ - Understanding trace/log export behavior
461
+ - Debugging connection problems
462
+
463
+ **Output:**
464
+ - Goes to console (stderr)
465
+ - Prefixed with `[securenow]`
466
+
467
+ ---
468
+
469
+ ### SECURENOW_TEST_SPAN
470
+
471
+ **Description:** Emit a test span on startup to verify tracing is working.
472
+
473
+ **Format:** `1` (enabled) or `0` (disabled)
474
+
475
+ **Default:** `0`
476
+
477
+ **Example:**
478
+ ```bash
479
+ export SECURENOW_TEST_SPAN=1
480
+ ```
481
+
482
+ **Behavior:**
483
+ - Creates a span named `securenow.startup.smoke`
484
+ - Span is immediately ended
485
+ - Useful for testing collector connectivity
486
+
487
+ ---
488
+
489
+ ## Environment
490
+
491
+ ### NODE_ENV
492
+
493
+ **Description:** Standard Node.js environment variable. Sent as `deployment.environment` attribute.
494
+
495
+ **Format:** String (typically: `development`, `production`, `test`, `staging`)
496
+
497
+ **Default:** `production`
498
+
499
+ **Examples:**
500
+ ```bash
501
+ export NODE_ENV=development
502
+ export NODE_ENV=production
503
+ export NODE_ENV=staging
504
+ export NODE_ENV=test
505
+ ```
506
+
507
+ **Use case:**
508
+ - Filter traces/logs by environment
509
+ - Different configurations per environment
510
+ - Standard Node.js convention
511
+
512
+ ---
513
+
514
+ ## Firewall (IP Blocking)
515
+
516
+ ### SECURENOW_API_KEY
517
+
518
+ **Description:** API key for the SecureNow firewall. When set, the firewall auto-activates and syncs your blocklist. Must have the `firewall:read` scope.
519
+
520
+ **Format:** String (`snk_live_` prefix + 64 hex characters)
521
+
522
+ **Example:**
523
+ ```bash
524
+ export SECURENOW_API_KEY=snk_live_a1b2c3d4e5f6...
525
+ ```
526
+
527
+ ---
528
+
529
+ ### SECURENOW_API_URL
530
+
531
+ **Description:** Base URL for the SecureNow API.
532
+
533
+ **Format:** URL
534
+
535
+ **Default:** `https://api.securenow.ai`
536
+
537
+ **Example:**
538
+ ```bash
539
+ export SECURENOW_API_URL=https://api.securenow.ai
540
+ ```
541
+
542
+ ---
543
+
544
+ ### SECURENOW_FIREWALL_ENABLED
545
+
546
+ **Description:** Master kill-switch for the firewall. Set to `0` to disable even when `SECURENOW_API_KEY` is set.
547
+
548
+ **Format:** `1` (enabled) or `0` (disabled)
549
+
550
+ **Default:** `1`
551
+
552
+ ---
553
+
554
+ ### SECURENOW_FIREWALL_SYNC_INTERVAL
555
+
556
+ **Description:** How often (in seconds) to refresh the blocklist from the API.
557
+
558
+ **Format:** Number (seconds)
559
+
560
+ **Default:** `60`
561
+
562
+ **Example:**
563
+ ```bash
564
+ export SECURENOW_FIREWALL_SYNC_INTERVAL=30
565
+ ```
566
+
567
+ ---
568
+
569
+ ### SECURENOW_FIREWALL_FAIL_MODE
570
+
571
+ **Description:** Behavior when the blocklist cannot be fetched from the API.
572
+
573
+ **Format:** `open` or `closed`
574
+
575
+ **Default:** `open`
576
+
577
+ - `open` — Allow all traffic when list is unavailable (recommended for most apps)
578
+ - `closed` — Block all traffic when list is unavailable (high-security environments)
579
+
580
+ ---
581
+
582
+ ### SECURENOW_FIREWALL_STATUS_CODE
583
+
584
+ **Description:** HTTP status code returned to blocked requests (Layer 1 only).
585
+
586
+ **Format:** Number
587
+
588
+ **Default:** `403`
589
+
590
+ **Example:**
591
+ ```bash
592
+ export SECURENOW_FIREWALL_STATUS_CODE=429
593
+ ```
594
+
595
+ ---
596
+
597
+ ### SECURENOW_FIREWALL_LOG
598
+
599
+ **Description:** Log blocked requests to the console.
600
+
601
+ **Format:** `1` (enabled) or `0` (disabled)
602
+
603
+ **Default:** `1`
604
+
605
+ ---
606
+
607
+ ### SECURENOW_FIREWALL_TCP
608
+
609
+ **Description:** Enable Layer 2 TCP-level blocking. Destroys sockets from blocked IPs before HTTP parsing starts.
610
+
611
+ **Format:** `1` (enabled) or `0` (disabled)
612
+
613
+ **Default:** `0`
614
+
615
+ **Notes:**
616
+ - Only sees direct connection IP (no proxy headers)
617
+ - Connections from trusted proxies are passed to Layer 1
618
+ - Most effective for direct-to-server deployments
619
+
620
+ ---
621
+
622
+ ### SECURENOW_FIREWALL_IPTABLES
623
+
624
+ **Description:** Enable Layer 3 OS firewall blocking via iptables/nftables. Kernel-level DROP — packets never reach Node.js.
625
+
626
+ **Format:** `1` (enabled) or `0` (disabled)
627
+
628
+ **Default:** `0`
629
+
630
+ **Notes:**
631
+ - Linux only (skips gracefully on macOS/Windows)
632
+ - Requires root or CAP_NET_ADMIN
633
+ - Auto-detects nftables vs iptables
634
+ - Dedicated chain: `SECURENOW_BLOCK`
635
+
636
+ ---
637
+
638
+ ### SECURENOW_FIREWALL_CLOUD
639
+
640
+ **Description:** Enable Layer 4 cloud/edge WAF blocking. Pushes the blocklist to your cloud provider's WAF.
641
+
642
+ **Format:** `cloudflare`, `aws`, or `gcp`
643
+
644
+ **Default:** *(none — disabled)*
645
+
646
+ **Provider-specific variables:**
647
+
648
+ | Provider | Required Variables |
649
+ |----------|-------------------|
650
+ | `cloudflare` | `CLOUDFLARE_API_TOKEN`, `CLOUDFLARE_ACCOUNT_ID` |
651
+ | `aws` | `AWS_WAF_IP_SET_ID`, standard AWS credentials |
652
+ | `gcp` | `GCP_PROJECT_ID`, `GCP_SECURITY_POLICY` |
653
+
654
+ ---
655
+
656
+ ### SECURENOW_FIREWALL_CLOUD_DRY_RUN
657
+
658
+ **Description:** Log cloud WAF pushes without actually applying them. Useful for testing.
659
+
660
+ **Format:** `1` (enabled) or `0` (disabled)
661
+
662
+ **Default:** `0`
663
+
664
+ ---
665
+
666
+ ### SECURENOW_TRUSTED_PROXIES
667
+
668
+ **Description:** Comma-separated list of additional trusted proxy IPs. The firewall only reads `X-Forwarded-For` from trusted proxies. Private/loopback IPs are always trusted.
669
+
670
+ **Format:** Comma-separated IPs
671
+
672
+ **Example:**
673
+ ```bash
674
+ export SECURENOW_TRUSTED_PROXIES=34.120.0.1,34.120.0.2
675
+ ```
676
+
677
+ ---
678
+
679
+ ## Configuration Examples
680
+
681
+ ### Development Environment
682
+
683
+ ```bash
684
+ # .env.development
685
+ SECURENOW_APPID=my-app-dev
686
+ SECURENOW_INSTANCE=http://localhost:4318
687
+ SECURENOW_LOGGING_ENABLED=1
688
+ SECURENOW_CAPTURE_BODY=1
689
+ SECURENOW_MAX_BODY_SIZE=20480
690
+ OTEL_LOG_LEVEL=debug
691
+ SECURENOW_TEST_SPAN=1
692
+ NODE_ENV=development
693
+ ```
694
+
695
+ ### Production Environment
696
+
697
+ ```bash
698
+ # .env.production
699
+ SECURENOW_APPID=my-app-prod
700
+ SECURENOW_INSTANCE=https://collector.prod.example.com:4318
701
+ OTEL_EXPORTER_OTLP_HEADERS=x-api-key=prod-key-12345
702
+ SECURENOW_LOGGING_ENABLED=1
703
+ SECURENOW_CAPTURE_BODY=0
704
+ SECURENOW_NO_UUID=1
705
+ SECURENOW_STRICT=1
706
+ SECURENOW_SENSITIVE_FIELDS=internal_id,session_token
707
+ OTEL_LOG_LEVEL=error
708
+ NODE_ENV=production
709
+
710
+ # Firewall (optional — auto-activates when API key is set)
711
+ SECURENOW_API_KEY=snk_live_abc123...
712
+ SECURENOW_FIREWALL_TCP=1
713
+ SECURENOW_FIREWALL_SYNC_INTERVAL=30
714
+ ```
715
+
716
+ ### PM2 Cluster
717
+
718
+ ```bash
719
+ # ecosystem.config.js environment
720
+ SECURENOW_APPID=my-app
721
+ SECURENOW_INSTANCE=http://localhost:4318
722
+ SECURENOW_LOGGING_ENABLED=1
723
+ SECURENOW_NO_UUID=1
724
+ SECURENOW_STRICT=1
725
+ SECURENOW_CAPTURE_BODY=1
726
+ NODE_ENV=production
727
+ ```
728
+
729
+ ### Docker / Kubernetes
730
+
731
+ ```bash
732
+ # Docker environment or K8s ConfigMap
733
+ SECURENOW_APPID=my-service
734
+ SECURENOW_INSTANCE=http://otel-collector:4318
735
+ SECURENOW_LOGGING_ENABLED=1
736
+ SECURENOW_NO_UUID=1
737
+ SECURENOW_CAPTURE_BODY=0
738
+ NODE_ENV=production
739
+ ```
740
+
741
+ ### Separate Collectors for Traces and Logs
742
+
743
+ ```bash
744
+ # Different backends for traces and logs
745
+ SECURENOW_APPID=my-app
746
+ OTEL_EXPORTER_OTLP_TRACES_ENDPOINT=http://traces-collector:4318/v1/traces
747
+ OTEL_EXPORTER_OTLP_LOGS_ENDPOINT=http://logs-collector:4318/v1/logs
748
+ SECURENOW_LOGGING_ENABLED=1
749
+ ```
750
+
751
+ ---
752
+
753
+ ## Priority and Overrides
754
+
755
+ When multiple variables are set, this is the priority order:
756
+
757
+ ### Service Name
758
+
759
+ 1. `OTEL_SERVICE_NAME` (highest priority)
760
+ 2. `SECURENOW_APPID`
761
+ 3. Auto-generated fallback (lowest priority)
762
+
763
+ ### OTLP Endpoint
764
+
765
+ 1. `OTEL_EXPORTER_OTLP_TRACES_ENDPOINT` (for traces)
766
+ 2. `OTEL_EXPORTER_OTLP_LOGS_ENDPOINT` (for logs)
767
+ 3. `OTEL_EXPORTER_OTLP_ENDPOINT`
768
+ 4. `SECURENOW_INSTANCE`
769
+ 5. Default: `https://freetrial.securenow.ai:4318` (lowest priority)
770
+
771
+ ---
772
+
773
+ ## Validation
774
+
775
+ SecureNow validates environment variables on startup. Check console output:
776
+
777
+ ```bash
778
+ [securenow] pid=12345 SECURENOW_APPID="my-app" OTEL_SERVICE_NAME=null → service.name=my-app-uuid123
779
+ [securenow] OTel SDK started → http://localhost:4318/v1/traces
780
+ [securenow] 📋 Logging: ENABLED → http://localhost:4318/v1/logs
781
+ [securenow] 📝 Request body capture: ENABLED (max: 10240 bytes)
782
+ ```
783
+
784
+ ---
785
+
786
+ ## Best Practices
787
+
788
+ ### 1. Use .env Files
789
+
790
+ Don't hardcode in your application:
791
+
792
+ ```bash
793
+ # .env
794
+ SECURENOW_APPID=my-app
795
+ SECURENOW_INSTANCE=http://localhost:4318
796
+ ```
797
+
798
+ ### 2. Different Configs per Environment
799
+
800
+ ```bash
801
+ # .env.development
802
+ SECURENOW_CAPTURE_BODY=1
803
+ OTEL_LOG_LEVEL=debug
804
+
805
+ # .env.production
806
+ SECURENOW_CAPTURE_BODY=0
807
+ OTEL_LOG_LEVEL=error
808
+ ```
809
+
810
+ ### 3. Use SECURENOW_NO_UUID in Clusters
811
+
812
+ ```bash
813
+ # PM2 cluster with 4 workers
814
+ SECURENOW_NO_UUID=1
815
+ ```
816
+
817
+ ### 4. Enable SECURENOW_STRICT in Production
818
+
819
+ ```bash
820
+ # Fail fast if misconfigured
821
+ SECURENOW_STRICT=1
822
+ ```
823
+
824
+ ### 5. Disable Body Capture in Production
825
+
826
+ ```bash
827
+ # Development
828
+ SECURENOW_CAPTURE_BODY=1
829
+
830
+ # Production
831
+ SECURENOW_CAPTURE_BODY=0
832
+ ```
833
+
834
+ ---
835
+
836
+ ## Troubleshooting
837
+
838
+ ### Check Current Values
839
+
840
+ ```bash
841
+ # Print all SECURENOW variables
842
+ env | grep SECURENOW
843
+
844
+ # Print all OTEL variables
845
+ env | grep OTEL
846
+
847
+ # Check specific variable
848
+ echo $SECURENOW_APPID
849
+ ```
850
+
851
+ ### Verify in Application
852
+
853
+ SecureNow logs current configuration on startup. Look for lines like:
854
+
855
+ ```
856
+ [securenow] pid=12345 SECURENOW_APPID="my-app" → service.name=my-app
857
+ [securenow] OTel SDK started → http://localhost:4318/v1/traces
858
+ ```
859
+
860
+ ### Enable Debug Mode
861
+
862
+ ```bash
863
+ export OTEL_LOG_LEVEL=debug
864
+ node app.js
865
+ ```
866
+
867
+ ---
868
+
869
+ ## Related Documentation
870
+
871
+ - [Firewall Guide](./FIREWALL-GUIDE.md)
872
+ - [API Keys Guide](./API-KEYS-GUIDE.md)
873
+ - [Express Setup Guide](./EXPRESS-SETUP-GUIDE.md)
874
+ - [Next.js Setup Guide](./NEXTJS-SETUP-COMPLETE.md)
875
+ - [Logging Guide](./LOGGING-GUIDE.md)
876
+ - [NPM README](../NPM_README.md)
877
+
878
+ ---
879
+
880
+ **Complete reference for all SecureNow environment variables.** 🎯