@sonisoft/now-sdk-ext-core 5.3.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 +21 -21
- package/README.md +40 -3
- package/dist/comm/http/ServiceNowProcessorRequest.d.ts +1 -0
- package/dist/comm/http/ServiceNowProcessorRequest.js +8 -1
- package/dist/comm/http/ServiceNowProcessorRequest.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/sn/amb/AMBClient.js +24 -11
- package/dist/sn/amb/AMBClient.js.map +1 -1
- package/dist/sn/amb/SubscriptionCommandSender.js +19 -2
- package/dist/sn/amb/SubscriptionCommandSender.js.map +1 -1
- package/dist/sn/amb/XMLHttpRequest.d.ts +1 -0
- package/dist/sn/amb/XMLHttpRequest.js +5 -1
- package/dist/sn/amb/XMLHttpRequest.js.map +1 -1
- package/dist/sn/scripttracer/ScriptTracer.js +6 -2
- package/dist/sn/scripttracer/ScriptTracer.js.map +1 -1
- package/dist/util/LogConfig.d.ts +83 -0
- package/dist/util/LogConfig.js +387 -0
- package/dist/util/LogConfig.js.map +1 -0
- package/dist/util/Logger.d.ts +40 -18
- package/dist/util/Logger.js +78 -84
- package/dist/util/Logger.js.map +1 -1
- package/dist/util/redact.d.ts +12 -0
- package/dist/util/redact.js +76 -0
- package/dist/util/redact.js.map +1 -1
- package/package.json +1 -1
package/dist/util/Logger.js
CHANGED
|
@@ -1,115 +1,109 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import { getRootLogger, logEpoch } from "./LogConfig.js";
|
|
2
|
+
/**
|
|
3
|
+
* A named handle onto the process-wide logger.
|
|
4
|
+
*
|
|
5
|
+
* This used to build its own winston logger with four File transports per instance. It
|
|
6
|
+
* no longer builds anything: there are ~43 of these across the codebase, and
|
|
7
|
+
* `ServiceNowRequest` is constructed per HTTP call, so each request was opening four
|
|
8
|
+
* more never-closed append streams. That is where the 120 MB of logs came from, and it
|
|
9
|
+
* also made rotation impossible — File transports track size independently, so several
|
|
10
|
+
* on one path interleave renames and lose lines.
|
|
11
|
+
*
|
|
12
|
+
* Destination, level, and rotation now live in LogConfig and are set once by the
|
|
13
|
+
* application. See `configureLogging`.
|
|
14
|
+
*/
|
|
5
15
|
export class Logger {
|
|
16
|
+
_labelName;
|
|
17
|
+
/** Set only by `setLogger`. Overrides the shared root for this instance. */
|
|
18
|
+
_override;
|
|
19
|
+
_cached;
|
|
20
|
+
_epochSeen = -1;
|
|
6
21
|
/**
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
* ~40 logging calls across src/, several of which pass whole request configs and
|
|
11
|
-
* session objects, and the set grows. Auditing call sites catches today's leaks
|
|
12
|
-
* and none of tomorrow's; a format in the pipeline catches both.
|
|
13
|
-
*
|
|
14
|
-
* The specific leak that motivated it: RequestHandler built `{auth: this._session}`
|
|
15
|
-
* and logged it at debug on every single request, writing live cookies and tokens
|
|
16
|
-
* to logs/app-debug.log.
|
|
22
|
+
* @param labelName Appears as `label` on every record from this instance.
|
|
23
|
+
* @param level Ignored. Kept so existing call sites still compile.
|
|
24
|
+
* @deprecated Pass the level to `configureLogging` instead — it applies process-wide.
|
|
17
25
|
*/
|
|
18
|
-
|
|
19
|
-
for (const key of Object.keys(info)) {
|
|
20
|
-
if (key === "level" || key === "message" || key === "timestamp" || key === "label") {
|
|
21
|
-
continue;
|
|
22
|
-
}
|
|
23
|
-
if (isSecretKey(key)) {
|
|
24
|
-
info[key] = REDACTED;
|
|
25
|
-
continue;
|
|
26
|
-
}
|
|
27
|
-
info[key] = redactValue(info[key]);
|
|
28
|
-
}
|
|
29
|
-
return info;
|
|
30
|
-
});
|
|
31
|
-
static errorFilter = winston.format((info) => {
|
|
32
|
-
return info.level === "error" ? info : false;
|
|
33
|
-
});
|
|
34
|
-
static infoFilter = winston.format((info) => {
|
|
35
|
-
return info.level === "info" ? info : false;
|
|
36
|
-
});
|
|
37
|
-
static debugFilter = winston.format((info) => {
|
|
38
|
-
return info.level === "debug" ? info : false;
|
|
39
|
-
});
|
|
40
|
-
_labelName;
|
|
41
|
-
_localLogger;
|
|
42
|
-
_logLevel;
|
|
43
|
-
constructor(labelName, level = "info") {
|
|
26
|
+
constructor(labelName, level) {
|
|
44
27
|
this._labelName = labelName;
|
|
45
|
-
|
|
46
|
-
this.initLogger();
|
|
28
|
+
void level;
|
|
47
29
|
}
|
|
30
|
+
/** Replaces the underlying winston logger for this instance only. Test seam. */
|
|
48
31
|
setLogger(logger) {
|
|
49
|
-
this.
|
|
32
|
+
this._override = logger;
|
|
50
33
|
}
|
|
51
34
|
getLabel() {
|
|
52
35
|
return this._labelName;
|
|
53
36
|
}
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
// First in the chain: redact before anything reshapes, nests, or
|
|
59
|
-
// serializes the entry, so no later format can capture a raw value.
|
|
60
|
-
Logger.redactSecrets(), label({ label: this._labelName }), timestamp({ format: "YYYY-MM-DD HH:mm:ss" }),
|
|
61
|
-
// Format the metadata object
|
|
62
|
-
metadata({ fillExcept: ["message", "level", "timestamp", "label"] })),
|
|
63
|
-
transports: [
|
|
64
|
-
new transports.File({
|
|
65
|
-
filename: "logs/combined.log",
|
|
66
|
-
format: format.combine(timestamp(), format.json())
|
|
67
|
-
}),
|
|
68
|
-
new transports.File({
|
|
69
|
-
filename: "logs/app-error.log",
|
|
70
|
-
level: "error",
|
|
71
|
-
format: combine(Logger.errorFilter(), timestamp(), json()),
|
|
72
|
-
}),
|
|
73
|
-
new transports.File({
|
|
74
|
-
filename: "logs/app-info.log",
|
|
75
|
-
level: "info",
|
|
76
|
-
format: combine(Logger.infoFilter(), timestamp(), json()),
|
|
77
|
-
}),
|
|
78
|
-
new transports.File({
|
|
79
|
-
filename: "logs/app-debug.log",
|
|
80
|
-
level: "debug",
|
|
81
|
-
format: combine(Logger.debugFilter(), timestamp(), json()),
|
|
82
|
-
}),
|
|
83
|
-
],
|
|
84
|
-
exitOnError: false
|
|
85
|
-
});
|
|
86
|
-
}
|
|
37
|
+
/**
|
|
38
|
+
* @deprecated The `level` argument the constructor accepts is ignored; use
|
|
39
|
+
* `configureLogging({level})`.
|
|
40
|
+
*/
|
|
87
41
|
static createLogger(labelName) {
|
|
88
42
|
return new Logger(labelName);
|
|
89
43
|
}
|
|
44
|
+
/** Resolves the shared root, rebuilding the cached reference if config changed. */
|
|
45
|
+
root() {
|
|
46
|
+
if (this._override) {
|
|
47
|
+
return this._override;
|
|
48
|
+
}
|
|
49
|
+
if (this._epochSeen !== logEpoch()) {
|
|
50
|
+
this._cached = getRootLogger();
|
|
51
|
+
this._epochSeen = logEpoch();
|
|
52
|
+
}
|
|
53
|
+
return this._cached;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Attaches this instance's label to the record.
|
|
57
|
+
*
|
|
58
|
+
* The label used to be a winston format bound to a per-instance logger. With one
|
|
59
|
+
* shared root it has to travel with the call. Callers pass all sorts of things as
|
|
60
|
+
* `metadata`, so a non-object is nested rather than spread — spreading a string
|
|
61
|
+
* would scatter it across numeric keys.
|
|
62
|
+
*/
|
|
63
|
+
meta(metadata) {
|
|
64
|
+
if (metadata === undefined || metadata === null) {
|
|
65
|
+
return { label: this._labelName };
|
|
66
|
+
}
|
|
67
|
+
if (typeof metadata === "object" && !Array.isArray(metadata)) {
|
|
68
|
+
// Label last, deliberately. Metadata objects here are assembled ad hoc and
|
|
69
|
+
// grow over time; a caller key named `label` would otherwise misattribute
|
|
70
|
+
// the record to a component that never emitted it.
|
|
71
|
+
return { ...metadata, label: this._labelName };
|
|
72
|
+
}
|
|
73
|
+
return { label: this._labelName, meta: metadata };
|
|
74
|
+
}
|
|
90
75
|
debug(message, metadata) {
|
|
91
|
-
this.
|
|
76
|
+
this.root().debug(message, this.meta(metadata));
|
|
92
77
|
}
|
|
93
78
|
info(message, metadata) {
|
|
94
|
-
this.
|
|
79
|
+
this.root().info(message, this.meta(metadata));
|
|
95
80
|
}
|
|
96
81
|
error(message, metadata) {
|
|
97
|
-
this.
|
|
82
|
+
this.root().error(message, this.meta(metadata));
|
|
98
83
|
}
|
|
99
84
|
warn(message, metadata) {
|
|
100
|
-
this.
|
|
85
|
+
this.root().warn(message, this.meta(metadata));
|
|
86
|
+
}
|
|
87
|
+
verbose(message, metadata) {
|
|
88
|
+
this.root().verbose(message, this.meta(metadata));
|
|
89
|
+
}
|
|
90
|
+
http(message, metadata) {
|
|
91
|
+
this.root().http(message, this.meta(metadata));
|
|
92
|
+
}
|
|
93
|
+
silly(message, metadata) {
|
|
94
|
+
this.root().silly(message, this.meta(metadata));
|
|
101
95
|
}
|
|
102
96
|
addInfoMessage(message, metadata) {
|
|
103
|
-
this.
|
|
97
|
+
this.info(message, metadata);
|
|
104
98
|
}
|
|
105
99
|
addErrorMessage(message, metadata) {
|
|
106
|
-
this.
|
|
100
|
+
this.error(message, metadata);
|
|
107
101
|
}
|
|
108
102
|
addWarnMessage(message, metadata) {
|
|
109
|
-
this.
|
|
103
|
+
this.warn(message, metadata);
|
|
110
104
|
}
|
|
111
105
|
successful(message, metadata) {
|
|
112
|
-
this.
|
|
106
|
+
this.info(message, metadata);
|
|
113
107
|
}
|
|
114
108
|
}
|
|
115
109
|
//# sourceMappingURL=Logger.js.map
|
package/dist/util/Logger.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Logger.js","sourceRoot":"","sources":["../../src/util/Logger.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Logger.js","sourceRoot":"","sources":["../../src/util/Logger.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAEtD;;;;;;;;;;;;GAYG;AACH,MAAM,OAAO,MAAM;IACf,UAAU,CAAS;IAEnB,4EAA4E;IACpE,SAAS,CAAkB;IAE3B,OAAO,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AI,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;IACjC,CAAC;IAEM,eAAe,CAAC,OAAe,EAAE,QAAkB;QACtD,IAAI,CAAC,KAAK,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;IAClC,CAAC;IAEM,cAAc,CAAC,OAAe,EAAE,QAAkB;QACrD,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;IACjC,CAAC;IAEM,UAAU,CAAC,OAAe,EAAE,QAAkB;QACjD,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;IACjC,CAAC;CACJ"}
|
package/dist/util/redact.d.ts
CHANGED
|
@@ -14,6 +14,18 @@
|
|
|
14
14
|
* `access_token`, …) because they come from the SDK's own session objects.
|
|
15
15
|
*/
|
|
16
16
|
export declare const REDACTED = "[redacted]";
|
|
17
|
+
/**
|
|
18
|
+
* Removes credential material from a log message string.
|
|
19
|
+
*
|
|
20
|
+
* The leak this exists for: `ScriptTracer` logged `Session ID from debugger/start:
|
|
21
|
+
* ${token}` at INFO level, so a live session token landed in `app-info.log` on every
|
|
22
|
+
* trace. `AMBClient` did the same with session cookies, truncated to 80 characters —
|
|
23
|
+
* truncation is not redaction, and a partial cookie is still a cookie.
|
|
24
|
+
*
|
|
25
|
+
* Deliberately biased toward over-redaction. Losing `30s` from `token refresh: 30s`
|
|
26
|
+
* costs a diagnostic; leaking a session token costs an instance.
|
|
27
|
+
*/
|
|
28
|
+
export declare function redactMessage(message: string): string;
|
|
17
29
|
export declare function isSecretKey(key: string): boolean;
|
|
18
30
|
/**
|
|
19
31
|
* Returns a copy of `value` with every secret-shaped key replaced by `[redacted]`.
|
package/dist/util/redact.js
CHANGED
|
@@ -41,6 +41,21 @@ const SECRET_KEYS = [
|
|
|
41
41
|
"sysparm_ck",
|
|
42
42
|
"apikey",
|
|
43
43
|
"api_key",
|
|
44
|
+
// Bayeux/CometD. `clientId` is not an identifier in the harmless sense — it is the
|
|
45
|
+
// credential that authorises every subsequent message on an AMB connection, and
|
|
46
|
+
// SubscriptionCommandSender logs whole handshake responses as metadata.
|
|
47
|
+
"clientid",
|
|
48
|
+
"client_id",
|
|
49
|
+
// ServiceNow session cookies, by name. `redactMessage` already catches these in
|
|
50
|
+
// message text; without them here the same value was redacted in a string and left
|
|
51
|
+
// intact as a key. Listed explicitly rather than adding a `session` FRAGMENT, which
|
|
52
|
+
// would also destroy the deliberate non-secret diagnostics in AMBClient
|
|
53
|
+
// (`sessionKeys`, `sessionType`) that log key names and shapes but never values.
|
|
54
|
+
"jsessionid",
|
|
55
|
+
"glide_session_store",
|
|
56
|
+
"glide_user_route",
|
|
57
|
+
"glide_user_activity",
|
|
58
|
+
"glide_sso_id",
|
|
44
59
|
];
|
|
45
60
|
/** Substrings that make a key secret regardless of what surrounds them. */
|
|
46
61
|
const SECRET_FRAGMENTS = [
|
|
@@ -52,6 +67,67 @@ const SECRET_FRAGMENTS = [
|
|
|
52
67
|
];
|
|
53
68
|
/** Depth cap. Session and response graphs are deep; nothing useful lives past this. */
|
|
54
69
|
const MAX_DEPTH = 8;
|
|
70
|
+
/**
|
|
71
|
+
* Named patterns for secrets interpolated into a log MESSAGE.
|
|
72
|
+
*
|
|
73
|
+
* Key-based redaction cannot reach these: by the time a template literal has been
|
|
74
|
+
* evaluated there is no key left, only text. So this matches on the secret's NAME as it
|
|
75
|
+
* appears in the text — the same rule, applied to a different carrier.
|
|
76
|
+
*
|
|
77
|
+
* Every pattern is anchored on a name and bounded in what it will consume. An unbounded
|
|
78
|
+
* `.*` here would be a denial-of-service on the logging path, and a value-shaped pattern
|
|
79
|
+
* (entropy, length) would redact half of every ServiceNow sys_id.
|
|
80
|
+
*/
|
|
81
|
+
const MESSAGE_PATTERNS = [
|
|
82
|
+
// A Cookie/Set-Cookie header carries several pairs; take the whole line, or the
|
|
83
|
+
// second pair survives while the first is redacted.
|
|
84
|
+
{ re: /\b(set-cookie|cookie)(\s*:\s*).+/gi, with: "$1$2" + REDACTED },
|
|
85
|
+
// `Bearer <token>` — the one case with no delimiter to key off.
|
|
86
|
+
{ re: /\b(bearer\s+)[A-Za-z0-9._~+/-]{8,}=*/gi, with: "$1" + REDACTED },
|
|
87
|
+
// Session/servlet cookies by name, wherever they appear in the text.
|
|
88
|
+
{
|
|
89
|
+
re: /\b(JSESSIONID|glide_session_store|glide_user_route|glide_user_activity|glide_sso_id|sysparm_ck)(\s*=\s*)[^\s;,"']+/gi,
|
|
90
|
+
with: "$1$2" + REDACTED,
|
|
91
|
+
},
|
|
92
|
+
// `<secret-ish label> … : value` / `= value`. The middle is capped at 32 chars and
|
|
93
|
+
// may not itself contain a delimiter, which is what keeps this from running away —
|
|
94
|
+
// it is how `Session ID from debugger/start: <token>` is caught without also
|
|
95
|
+
// eating `Error during request. Status: 401`.
|
|
96
|
+
{
|
|
97
|
+
re: /\b(pass(?:word|wd)?|secret|tokens?|api[_-]?keys?|credentials?|cookies?|session[ _-]?id|authorization|x-usertoken)([^:=\n]{0,32}?[:=]\s*)[^\s,;)\]}]+/gi,
|
|
98
|
+
with: "$1$2" + REDACTED,
|
|
99
|
+
},
|
|
100
|
+
];
|
|
101
|
+
/** Cheap pre-filter. Most messages carry no delimiter and can skip the scan entirely. */
|
|
102
|
+
function mayContainSecret(message) {
|
|
103
|
+
return message.includes("=") || message.includes(":") || /bearer/i.test(message);
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* Removes credential material from a log message string.
|
|
107
|
+
*
|
|
108
|
+
* The leak this exists for: `ScriptTracer` logged `Session ID from debugger/start:
|
|
109
|
+
* ${token}` at INFO level, so a live session token landed in `app-info.log` on every
|
|
110
|
+
* trace. `AMBClient` did the same with session cookies, truncated to 80 characters —
|
|
111
|
+
* truncation is not redaction, and a partial cookie is still a cookie.
|
|
112
|
+
*
|
|
113
|
+
* Deliberately biased toward over-redaction. Losing `30s` from `token refresh: 30s`
|
|
114
|
+
* costs a diagnostic; leaking a session token costs an instance.
|
|
115
|
+
*/
|
|
116
|
+
export function redactMessage(message) {
|
|
117
|
+
if (typeof message !== "string" || message.length === 0) {
|
|
118
|
+
return message;
|
|
119
|
+
}
|
|
120
|
+
if (!mayContainSecret(message)) {
|
|
121
|
+
return message;
|
|
122
|
+
}
|
|
123
|
+
let out = message;
|
|
124
|
+
for (const pattern of MESSAGE_PATTERNS) {
|
|
125
|
+
// Shared module-level regexes carry lastIndex between calls with /g.
|
|
126
|
+
pattern.re.lastIndex = 0;
|
|
127
|
+
out = out.replace(pattern.re, pattern.with);
|
|
128
|
+
}
|
|
129
|
+
return out;
|
|
130
|
+
}
|
|
55
131
|
export function isSecretKey(key) {
|
|
56
132
|
if (!key) {
|
|
57
133
|
return false;
|
package/dist/util/redact.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"redact.js","sourceRoot":"","sources":["../../src/util/redact.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,MAAM,CAAC,MAAM,QAAQ,GAAG,YAAY,CAAC;AAErC;;;GAGG;AACH,MAAM,WAAW,GAAsB;IACnC,MAAM;IACN,eAAe;IACf,SAAS;IACT,YAAY;IACZ,aAAa;IACb,UAAU;IACV,QAAQ;IACR,QAAQ;IACR,eAAe;IACf,cAAc;IACd,OAAO;IACP,cAAc;IACd,eAAe;IACf,UAAU;IACV,WAAW;IACX,QAAQ;IACR,SAAS;IACT,YAAY;IACZ,WAAW;IACX,YAAY;IACZ,QAAQ;IACR,SAAS;
|
|
1
|
+
{"version":3,"file":"redact.js","sourceRoot":"","sources":["../../src/util/redact.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,MAAM,CAAC,MAAM,QAAQ,GAAG,YAAY,CAAC;AAErC;;;GAGG;AACH,MAAM,WAAW,GAAsB;IACnC,MAAM;IACN,eAAe;IACf,SAAS;IACT,YAAY;IACZ,aAAa;IACb,UAAU;IACV,QAAQ;IACR,QAAQ;IACR,eAAe;IACf,cAAc;IACd,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"name": "@sonisoft/now-sdk-ext-core",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "6.0.0",
|
|
4
4
|
"description": "Comprehensive TypeScript library extending ServiceNow SDK with application management, ATF testing, real-time log monitoring, AMB event subscriptions, and automation tools",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"servicenow",
|