@elisra-devops/docgen-data-provider 1.139.0 → 1.141.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/.github/workflows/ci.yml +2 -0
- package/bin/helpers/tfs.js +21 -14
- package/bin/helpers/tfs.js.map +1 -1
- package/bin/modules/JfrogDataProvider.js +1 -1
- package/bin/modules/JfrogDataProvider.js.map +1 -1
- package/bin/modules/PipelinesDataProvider.js +1 -1
- package/bin/modules/PipelinesDataProvider.js.map +1 -1
- package/bin/modules/ResultDataProvider.js +21 -15
- package/bin/modules/ResultDataProvider.js.map +1 -1
- package/bin/modules/TicketsDataProvider.d.ts +3 -3
- package/bin/modules/TicketsDataProvider.js +80 -54
- package/bin/modules/TicketsDataProvider.js.map +1 -1
- package/bin/tests/modules/JfrogDataProvider.test.js +3 -1
- package/bin/tests/modules/JfrogDataProvider.test.js.map +1 -1
- package/bin/tests/modules/ResultDataProvider.test.js +6 -2
- package/bin/tests/modules/ResultDataProvider.test.js.map +1 -1
- package/bin/tests/modules/ticketsDataProvider.historical.test.js +111 -42
- package/bin/tests/modules/ticketsDataProvider.historical.test.js.map +1 -1
- package/bin/tests/utils/logger.test.d.ts +1 -0
- package/bin/tests/utils/logger.test.js +238 -0
- package/bin/tests/utils/logger.test.js.map +1 -0
- package/bin/tests/utils/runContext.test.d.ts +1 -0
- package/bin/tests/utils/runContext.test.js +51 -0
- package/bin/tests/utils/runContext.test.js.map +1 -0
- package/bin/utils/logSink.d.ts +25 -0
- package/bin/utils/logSink.js +16 -0
- package/bin/utils/logSink.js.map +1 -0
- package/bin/utils/logger.d.ts +6 -0
- package/bin/utils/logger.js +219 -27
- package/bin/utils/logger.js.map +1 -1
- package/bin/utils/runContext.d.ts +8 -0
- package/bin/utils/runContext.js +12 -0
- package/bin/utils/runContext.js.map +1 -0
- package/eslint.config.mjs +40 -0
- package/package.json +8 -3
- package/src/helpers/tfs.ts +19 -15
- package/src/modules/JfrogDataProvider.ts +1 -1
- package/src/modules/PipelinesDataProvider.ts +1 -1
- package/src/modules/ResultDataProvider.ts +20 -15
- package/src/modules/TicketsDataProvider.ts +93 -74
- package/src/tests/modules/JfrogDataProvider.test.ts +3 -1
- package/src/tests/modules/ResultDataProvider.test.ts +6 -2
- package/src/tests/modules/ticketsDataProvider.historical.test.ts +128 -43
- package/src/tests/utils/logger.test.ts +270 -0
- package/src/tests/utils/runContext.test.ts +48 -0
- package/src/utils/logSink.ts +44 -0
- package/src/utils/logger.ts +229 -29
- package/src/utils/runContext.ts +25 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logger.test.js","sourceRoot":"","sources":["../../../src/tests/utils/logger.test.ts"],"names":[],"mappings":";;AAAA,mCAAmC;AACnC,+CAAgD;AAChD,+CAAkE;AAClE,iDAA+E;AAC/E,uDAAyD;AAEzD,MAAM,WAAW,GAAG,CAAC,IAA6B,EAAE,EAAE,CAAE,IAAA,eAAM,GAAU,CAAC,SAAS,mBAAM,IAAI,EAAG,CAAC;AAEhG,QAAQ,CAAC,sBAAsB,EAAE,GAAG,EAAE;IACpC,IAAI,CAAC,mEAAmE,EAAE,GAAG,EAAE;QAC7E,MAAM,GAAG,GAAG,WAAW,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,GAAG,EAAE,KAAK,EAAE,KAAK,EAAE,QAAQ,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,CAAC,CAAC;QACnG,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;QACrC,MAAM,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;QACxC,MAAM,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;IACxC,CAAC,CAAC,CAAC;IAEH,IAAI,CAAC,oGAAoG,EAAE,GAAG,EAAE;QAC9G,mFAAmF;QAC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qB,EAAE,CAAC;QAC3C,4BAAe,CAAC,GAAG,CAAC,EAAE,KAAK,EAAE,aAAa,EAAE,WAAW,EAAE,SAAS,EAAE,EAAE,GAAG,EAAE;YACzE,MAAM,CAAC,KAAK,CAAC,eAAe,CAAC,CAAC;QAChC,CAAC,CAAC,CAAC;QACH,4BAAe,CAAC,GAAG,CAAC,EAAE,KAAK,EAAE,YAAY,EAAE,EAAE,GAAG,EAAE;YAChD,MAAM,CAAC,KAAK,CAAC,cAAc,CAAC,CAAC;QAC/B,CAAC,CAAC,CAAC;QACH,MAAM,CAAC,MAAM,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC;QAC/B,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC;IAClD,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const winston = require("winston");
|
|
4
|
+
const Transport = require("winston-transport");
|
|
5
|
+
const logger_1 = require("../../utils/logger");
|
|
6
|
+
const runContext_1 = require("../../utils/runContext");
|
|
7
|
+
class CaptureTransport extends Transport {
|
|
8
|
+
constructor() {
|
|
9
|
+
super(...arguments);
|
|
10
|
+
this.lines = [];
|
|
11
|
+
}
|
|
12
|
+
log(info, callback) {
|
|
13
|
+
var _a;
|
|
14
|
+
this.lines.push(JSON.parse((_a = info[Symbol.for('message')]) !== null && _a !== void 0 ? _a : JSON.stringify(info)));
|
|
15
|
+
callback();
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
function makeTestLogger() {
|
|
19
|
+
const capture = new CaptureTransport();
|
|
20
|
+
const logger = winston.createLogger({
|
|
21
|
+
level: 'silly',
|
|
22
|
+
format: winston.format.combine((0, logger_1.withRunContext)(), winston.format.json()),
|
|
23
|
+
transports: [capture],
|
|
24
|
+
});
|
|
25
|
+
return { logger, capture };
|
|
26
|
+
}
|
|
27
|
+
describe('withRunContext', () => {
|
|
28
|
+
test('is a no-op when the store was never populated', () => {
|
|
29
|
+
const { logger, capture } = makeTestLogger();
|
|
30
|
+
logger.info('outside any run');
|
|
31
|
+
expect(capture.lines[0].runId).toBeUndefined();
|
|
32
|
+
});
|
|
33
|
+
test('stamps runId onto every log emitted inside store.run(...)', () => {
|
|
34
|
+
const { logger, capture } = makeTestLogger();
|
|
35
|
+
runContext_1.runContextStore.run({ runId: 'run-123' }, () => {
|
|
36
|
+
logger.info('inside the run');
|
|
37
|
+
});
|
|
38
|
+
logger.info('outside again');
|
|
39
|
+
expect(capture.lines[0].runId).toBe('run-123');
|
|
40
|
+
expect(capture.lines[1].runId).toBeUndefined();
|
|
41
|
+
});
|
|
42
|
+
test('async work started inside the run keeps the runId across the await boundary', async () => {
|
|
43
|
+
const { logger, capture } = makeTestLogger();
|
|
44
|
+
await runContext_1.runContextStore.run({ runId: 'run-async' }, async () => {
|
|
45
|
+
await new Promise((resolve) => setTimeout(resolve, 0));
|
|
46
|
+
logger.info('after await');
|
|
47
|
+
});
|
|
48
|
+
expect(capture.lines[0].runId).toBe('run-async');
|
|
49
|
+
});
|
|
50
|
+
});
|
|
51
|
+
//# sourceMappingURL=runContext.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runContext.test.js","sourceRoot":"","sources":["../../../src/tests/utils/runContext.test.ts"],"names":[],"mappings":";;AAAA,mCAAmC;AACnC,+CAAgD;AAChD,+CAAoD;AACpD,uDAAyD;AAEzD,MAAM,gBAAiB,SAAQ,SAAS;IAAxC;;QACE,UAAK,GAA8B,EAAE,CAAC;IAKxC,CAAC;IAJC,GAAG,CAAC,IAA6B,EAAE,QAAoB;;QACrD,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,MAAC,IAAY,CA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K,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;QAC/C,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,aAAa,EAAE,CAAC;IACjD,CAAC,CAAC,CAAC;IAEH,IAAI,CAAC,6EAA6E,EAAE,KAAK,IAAI,EAAE;QAC7F,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,GAAG,cAAc,EAAE,CAAC;QAC7C,MAAM,4BAAe,CAAC,GAAG,CAAC,EAAE,KAAK,EAAE,WAAW,EAAE,EAAE,KAAK,IAAI,EAAE;YAC3D,MAAM,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,UAAU,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,CAAC;YACvD,MAAM,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;QAC7B,CAAC,CAAC,CAAC;QACH,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;IACnD,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export interface DiagnosticEvent {
|
|
2
|
+
ts: string;
|
|
3
|
+
level: string;
|
|
4
|
+
service: string;
|
|
5
|
+
version: string;
|
|
6
|
+
runId?: string;
|
|
7
|
+
docType?: string;
|
|
8
|
+
step?: string;
|
|
9
|
+
contentControlType?: string;
|
|
10
|
+
contentControlTitle?: string;
|
|
11
|
+
project?: string;
|
|
12
|
+
userId?: string;
|
|
13
|
+
message: string;
|
|
14
|
+
err?: {
|
|
15
|
+
message: string;
|
|
16
|
+
code?: string;
|
|
17
|
+
stack?: string;
|
|
18
|
+
};
|
|
19
|
+
retainPending?: boolean;
|
|
20
|
+
}
|
|
21
|
+
export interface LogSink {
|
|
22
|
+
push(event: DiagnosticEvent): void;
|
|
23
|
+
}
|
|
24
|
+
export declare function getLogSink(): LogSink | undefined;
|
|
25
|
+
export declare function installLogSink(sink: LogSink): void;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getLogSink = getLogSink;
|
|
4
|
+
exports.installLogSink = installLogSink;
|
|
5
|
+
// Symbol.for so this package's copy converges on the same installed sink as
|
|
6
|
+
// docgen-content-control's (the host process this package runs inside) and
|
|
7
|
+
// docgen-dg-skins-package's, the same reasoning as runContext.ts's AsyncLocalStorage. A
|
|
8
|
+
// never-populated sink is a harmless no-op — this package only reads it, never installs one.
|
|
9
|
+
const KEY = Symbol.for('elisradevops.docgen.logSink');
|
|
10
|
+
function getLogSink() {
|
|
11
|
+
return globalThis[KEY];
|
|
12
|
+
}
|
|
13
|
+
function installLogSink(sink) {
|
|
14
|
+
globalThis[KEY] = sink;
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=logSink.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logSink.js","sourceRoot":"","sources":["../../src/utils/logSink.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAqCb,gCAEC;AAED,wCAEC;AAZD,4EAA4E;AAC5E,2EAA2E;AAC3E,wFAAwF;AACxF,6FAA6F;AAC7F,MAAM,GAAG,GAAG,MAAM,CAAC,GAAG,CAAC,6BAA6B,CAAC,CAAC;AAEtD,SAAgB,UAAU;IACxB,OAAQ,UAAsC,CAAC,GAAG,CAAwB,CAAC;AAC7E,CAAC;AAED,SAAgB,cAAc,CAAC,IAAa;IACzC,UAAsC,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC;AACtD,CAAC"}
|
package/bin/utils/logger.d.ts
CHANGED
|
@@ -1,3 +1,9 @@
|
|
|
1
1
|
import * as winston from 'winston';
|
|
2
|
+
import * as Transport from 'winston-transport';
|
|
2
3
|
declare let logger: winston.Logger;
|
|
4
|
+
export declare const withRunContext: winston.Logform.FormatWrap;
|
|
5
|
+
export declare const redact: winston.Logform.FormatWrap;
|
|
6
|
+
export declare class DiagnosticsTransport extends Transport {
|
|
7
|
+
log(info: Record<string, unknown>, callback: () => void): void;
|
|
8
|
+
}
|
|
3
9
|
export default logger;
|
package/bin/utils/logger.js
CHANGED
|
@@ -1,35 +1,227 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DiagnosticsTransport = exports.redact = exports.withRunContext = void 0;
|
|
3
4
|
const winston = require("winston");
|
|
5
|
+
const fs = require("fs");
|
|
6
|
+
const path = require("path");
|
|
7
|
+
const Transport = require("winston-transport");
|
|
8
|
+
const runContext_1 = require("./runContext");
|
|
9
|
+
const logSink_1 = require("./logSink");
|
|
4
10
|
let logger;
|
|
5
|
-
|
|
6
|
-
//
|
|
7
|
-
//
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
//
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
//
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
//
|
|
21
|
-
//
|
|
22
|
-
//
|
|
23
|
-
//
|
|
24
|
-
//
|
|
11
|
+
// Merges the ambient runId (set by content-control's request middleware, once Phase 3 lands
|
|
12
|
+
// there) into every log record. A never-populated store is a harmless no-op — this package
|
|
13
|
+
// only reads it, never sets it.
|
|
14
|
+
exports.withRunContext = winston.format((info) => {
|
|
15
|
+
const store = runContext_1.runContextStore.getStore();
|
|
16
|
+
if (store === null || store === void 0 ? void 0 : store.runId)
|
|
17
|
+
info.runId = store.runId;
|
|
18
|
+
// Phase 7b — same ambient, per-run treatment as runId.
|
|
19
|
+
if (store === null || store === void 0 ? void 0 : store.docType)
|
|
20
|
+
info.docType = store.docType;
|
|
21
|
+
// Phase 7c — same read-only treatment; populated by content-control's attachRunContext.
|
|
22
|
+
if (store === null || store === void 0 ? void 0 : store.project)
|
|
23
|
+
info.project = store.project;
|
|
24
|
+
return info;
|
|
25
|
+
});
|
|
26
|
+
// Defense-in-depth: scrubs known-sensitive keys out of any object attached to a log call
|
|
27
|
+
// (meta, splat, an Error's own enumerable props — e.g. AxiosError.toJSON()'s
|
|
28
|
+
// config.auth.password / config.headers.Authorization, which is exactly how a PAT was
|
|
29
|
+
// leaking via `logger.error(JSON.stringify(error))` on ADO REST failures). Does not
|
|
30
|
+
// redact secrets interpolated into a message string — that's the corresponding call-site
|
|
31
|
+
// fixes' job; this is a backstop for structured fields.
|
|
32
|
+
// "accesskey" (not just "minioaccesskey") so this also catches an *AccessKeyId-style field —
|
|
33
|
+
// a real gap found in api-gate's copy during the Phase 5 manifest work: only the *SecretKey
|
|
34
|
+
// sibling was covered before, via "secret". Applied here too to keep the four copies in sync.
|
|
35
|
+
const SENSITIVE_KEY = /token|pat|password|secret|authorization|accesskey|minioaccesskey|miniosecretkey/i;
|
|
36
|
+
// A per-key try/catch on the *read*, not just around the whole loop: a getter that throws
|
|
37
|
+
// (e.g. `{ get boom() { throw ... } }`) would otherwise abort redaction for every remaining
|
|
38
|
+
// key in the same object, or — worse — survive redaction untouched and re-throw later, inside
|
|
39
|
+
// winston's json() formatter, which is not wrapped in anything. redactValue always returns a
|
|
40
|
+
// freshly built plain object/array, never the original reference, so once a value has passed
|
|
41
|
+
// through here nothing downstream can re-trigger a throwing accessor on it.
|
|
42
|
+
function safeRead(obj, key) {
|
|
43
|
+
try {
|
|
44
|
+
return { ok: true, value: obj[key] };
|
|
45
|
+
}
|
|
46
|
+
catch (_a) {
|
|
47
|
+
return { ok: false };
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
function redactValue(value, depth = 0, seen = new WeakSet()) {
|
|
51
|
+
if (depth > 6 || value === null || typeof value !== 'object')
|
|
52
|
+
return value;
|
|
53
|
+
if (seen.has(value))
|
|
54
|
+
return '[Circular]';
|
|
55
|
+
seen.add(value);
|
|
56
|
+
if (Array.isArray(value))
|
|
57
|
+
return value.map((v) => redactValue(v, depth + 1, seen));
|
|
58
|
+
const out = {};
|
|
59
|
+
for (const key of Object.keys(value)) {
|
|
60
|
+
const read = safeRead(value, key);
|
|
61
|
+
if (!read.ok) {
|
|
62
|
+
out[key] = '[Unreadable property]';
|
|
63
|
+
continue;
|
|
64
|
+
}
|
|
65
|
+
out[key] = SENSITIVE_KEY.test(key) ? '[REDACTED]' : redactValue(read.value, depth + 1, seen);
|
|
66
|
+
}
|
|
67
|
+
return out;
|
|
68
|
+
}
|
|
69
|
+
exports.redact = winston.format((info) => {
|
|
70
|
+
const target = info;
|
|
71
|
+
for (const key of Object.keys(target)) {
|
|
72
|
+
// level/timestamp are always plain strings winston sets itself — never touched. message is
|
|
73
|
+
// NOT exempt: when logger.error(x) is called with a single non-string/non-Error argument,
|
|
74
|
+
// winston nests the whole thing under info.message (this is exactly the shape hit by a raw
|
|
75
|
+
// object argument), so message can carry a throwing getter or a sensitive key just as much
|
|
76
|
+
// as any other field — redactValue already no-ops on a plain string, so including it here
|
|
77
|
+
// costs nothing for the common case and closes that gap for the uncommon one.
|
|
78
|
+
if (key === 'level' || key === 'timestamp')
|
|
79
|
+
continue;
|
|
80
|
+
const read = safeRead(target, key);
|
|
81
|
+
const value = !read.ok
|
|
82
|
+
? '[Unreadable property]'
|
|
83
|
+
: // A top-level primitive (e.g. token: "abc") has no children for redactValue to walk into —
|
|
84
|
+
// the key itself has to be checked here too, not just inside the recursive object walk.
|
|
85
|
+
SENSITIVE_KEY.test(key)
|
|
86
|
+
? '[REDACTED]'
|
|
87
|
+
: redactValue(read.value);
|
|
88
|
+
try {
|
|
89
|
+
target[key] = value;
|
|
90
|
+
}
|
|
91
|
+
catch (_a) {
|
|
92
|
+
// The original property could be a getter-only accessor with no setter, which throws on
|
|
93
|
+
// plain assignment in strict mode — redefine it outright rather than skip it.
|
|
94
|
+
Object.defineProperty(target, key, { value, writable: true, enumerable: true, configurable: true });
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
return info;
|
|
98
|
+
});
|
|
99
|
+
// Resolves the package's own version for defaultMeta. Node-only (this package is currently
|
|
100
|
+
// only ever consumed by docgen-content-control at runtime — the browser transport below is
|
|
101
|
+
// unused/commented out), so fs/path are safe here.
|
|
102
|
+
function readOwnVersion() {
|
|
103
|
+
const candidates = [
|
|
104
|
+
path.resolve(__dirname, '../package.json'),
|
|
105
|
+
path.resolve(__dirname, '../../package.json'),
|
|
106
|
+
path.resolve(process.cwd(), 'package.json'),
|
|
107
|
+
];
|
|
108
|
+
for (const candidate of candidates) {
|
|
109
|
+
try {
|
|
110
|
+
if (!fs.existsSync(candidate))
|
|
111
|
+
continue;
|
|
112
|
+
return JSON.parse(fs.readFileSync(candidate, 'utf8')).version || 'unknown';
|
|
113
|
+
}
|
|
114
|
+
catch (_a) {
|
|
115
|
+
// try next candidate
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
return 'unknown';
|
|
119
|
+
}
|
|
120
|
+
// A template literal's implicit ToString throws on a Symbol value (unlike String(), which
|
|
121
|
+
// calls Symbol.prototype.toString() explicitly) — logger.error(Symbol('x')) would otherwise
|
|
122
|
+
// crash inside this formatter itself, the one place in the pipeline with no try/catch around
|
|
123
|
+
// it. Symbol.toString() itself never throws, so this needs no further guarding.
|
|
124
|
+
const safeMessageString = (value) => typeof value === 'symbol' ? value.toString() : String(value);
|
|
125
|
+
const textFormat = winston.format.printf((info) => `${info.timestamp} - ${info.level}: ${safeMessageString(info.message)}`);
|
|
126
|
+
// Bounded so one oversized message/stack can't produce an unbounded LogEvent document.
|
|
127
|
+
const MAX_MESSAGE_LEN = 2000;
|
|
128
|
+
const MAX_STACK_LEN = 4000;
|
|
129
|
+
function clamp(value, max) {
|
|
130
|
+
if (typeof value !== 'string')
|
|
131
|
+
return undefined;
|
|
132
|
+
return value.length > max ? value.slice(0, max) : value;
|
|
133
|
+
}
|
|
134
|
+
// Ships warn/error records to whatever LogSink the host process (docgen-content-control's
|
|
135
|
+
// index.ts) has installed — this package never installs one itself, only reads it. This is
|
|
136
|
+
// the dominant source of real ADO error records (tfs.ts's executeWithRetry is the single
|
|
137
|
+
// static axios instance handling all Azure DevOps traffic), so without this transport most
|
|
138
|
+
// real generation failures either never reach the store or get misattributed to
|
|
139
|
+
// dg-content-control. Reads info *after* the rest of the format chain has already run —
|
|
140
|
+
// redact() has already scrubbed it by the time this transport sees it. Never throws, never
|
|
141
|
+
// blocks the call path, and never logs through `logger` itself (that would recurse back
|
|
142
|
+
// into this same transport) — failures go to console.error only.
|
|
143
|
+
const DIAGNOSTICS_CAPTURE_ENABLED = (process.env.DIAGNOSTICS_CAPTURE_ENABLED || 'true').toLowerCase() !== 'false';
|
|
144
|
+
// Exported for tests, the same treatment as redact()/withRunContext() — so a test pipeline
|
|
145
|
+
// can exercise this transport without going through the real singleton logger's env-gated
|
|
146
|
+
// json()/textFormat branch.
|
|
147
|
+
class DiagnosticsTransport extends Transport {
|
|
148
|
+
log(info, callback) {
|
|
149
|
+
var _a, _b, _c, _d, _e;
|
|
150
|
+
setImmediate(() => this.emit('logged', info));
|
|
151
|
+
try {
|
|
152
|
+
const level = info.level;
|
|
153
|
+
const isWarnOrError = level === 'warn' || level === 'error';
|
|
154
|
+
// Phase 6b — the logger's own level gate is now 'debug' (see createLogger below), so a
|
|
155
|
+
// debug/info call reaches this transport regardless of mode; this is the one place that
|
|
156
|
+
// decides whether it's actually persisted, keyed off the per-run capture mode rather
|
|
157
|
+
// than a process-wide setting — concurrent runs in 'normal' mode are unaffected by a
|
|
158
|
+
// sibling run's 'verbose'/'retain-on-failure' opt-in.
|
|
159
|
+
const captureMode = (_a = runContext_1.runContextStore.getStore()) === null || _a === void 0 ? void 0 : _a.captureMode;
|
|
160
|
+
const isCapturedDebugOrInfo = (level === 'debug' || level === 'info') && (captureMode === 'verbose' || captureMode === 'retain-on-failure');
|
|
161
|
+
if (DIAGNOSTICS_CAPTURE_ENABLED && (isWarnOrError || isCapturedDebugOrInfo)) {
|
|
162
|
+
// winston.errors({stack:true}) merges an Error's own enumerable properties (stack,
|
|
163
|
+
// and anything else the call site set, e.g. `err.code`) directly onto `info` — there
|
|
164
|
+
// is no separate nested info.err. `info.stack`'s presence is the only reliable signal
|
|
165
|
+
// that this record came from `logger.error('...', err)`/`logger.error(err)` rather
|
|
166
|
+
// than a plain string message. When present, info.message is already the
|
|
167
|
+
// stable-message-plus-error-message string winston produced, so err.message reuses it.
|
|
168
|
+
const hasErr = typeof info.stack === 'string';
|
|
169
|
+
const message = (_b = clamp(info.message, MAX_MESSAGE_LEN)) !== null && _b !== void 0 ? _b : '';
|
|
170
|
+
const event = {
|
|
171
|
+
ts: typeof info.timestamp === 'string' ? info.timestamp : new Date().toISOString(),
|
|
172
|
+
level: String(info.level),
|
|
173
|
+
service: String((_c = info.service) !== null && _c !== void 0 ? _c : '@elisra-devops/docgen-data-provider'),
|
|
174
|
+
version: String((_d = info.version) !== null && _d !== void 0 ? _d : 'unknown'),
|
|
175
|
+
runId: typeof info.runId === 'string' ? info.runId : undefined,
|
|
176
|
+
docType: typeof info.docType === 'string' ? info.docType : undefined,
|
|
177
|
+
step: typeof info.step === 'string' ? info.step : undefined,
|
|
178
|
+
contentControlType: typeof info.contentControlType === 'string' ? info.contentControlType : undefined,
|
|
179
|
+
contentControlTitle: typeof info.contentControlTitle === 'string' ? info.contentControlTitle : undefined,
|
|
180
|
+
project: typeof info.project === 'string' ? info.project : undefined,
|
|
181
|
+
userId: typeof info.userId === 'string' ? info.userId : undefined,
|
|
182
|
+
message,
|
|
183
|
+
err: hasErr
|
|
184
|
+
? {
|
|
185
|
+
message,
|
|
186
|
+
code: typeof info.code === 'string' ? info.code : undefined,
|
|
187
|
+
stack: clamp(info.stack, MAX_STACK_LEN),
|
|
188
|
+
}
|
|
189
|
+
: undefined,
|
|
190
|
+
retainPending: !isWarnOrError && captureMode === 'retain-on-failure' ? true : undefined,
|
|
191
|
+
};
|
|
192
|
+
(_e = (0, logSink_1.getLogSink)()) === null || _e === void 0 ? void 0 : _e.push(event);
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
catch (e) {
|
|
196
|
+
// eslint-disable-next-line no-console
|
|
197
|
+
console.error('DiagnosticsTransport failed to push event', e);
|
|
198
|
+
}
|
|
199
|
+
callback();
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
exports.DiagnosticsTransport = DiagnosticsTransport;
|
|
203
|
+
// LOG_FORMAT=json is the eventual default (structured stdout a collector can parse), but
|
|
204
|
+
// stays opt-in for one release so switching is a config change, not an image rebuild, if
|
|
205
|
+
// anyone reading raw console output needs to roll back.
|
|
206
|
+
const useJson = (process.env.LOG_FORMAT || 'text').toLowerCase() === 'json';
|
|
207
|
+
// Phase 6b — the Logger's own level gate must be 'debug' (winston's most permissive) so a
|
|
208
|
+
// debug/info call always reaches every transport's log(); a static per-logger level can't
|
|
209
|
+
// depend on the ALS store's per-run capture mode, so DiagnosticsTransport has to be the one
|
|
210
|
+
// deciding what's actually persisted. The Console transport below gets its own explicit
|
|
211
|
+
// level so stdout's default behavior (info/warn/error unless LOG_LEVEL=debug) is unchanged —
|
|
212
|
+
// this only spends the format-chain cost on debug() calls that previously short-circuited
|
|
213
|
+
// for free; info/warn/error volume (Phase 4's focus) is unaffected either way.
|
|
214
|
+
const CONSOLE_LOG_LEVEL = process.env.LOG_LEVEL || 'info';
|
|
25
215
|
logger = winston.createLogger({
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
216
|
+
level: 'debug',
|
|
217
|
+
defaultMeta: { service: '@elisra-devops/docgen-data-provider', version: readOwnVersion() },
|
|
218
|
+
format: useJson
|
|
219
|
+
? winston.format.combine(winston.format.errors({ stack: true }), winston.format.timestamp(), (0, exports.withRunContext)(), (0, exports.redact)(), winston.format.splat(), winston.format.json())
|
|
220
|
+
: winston.format.combine(winston.format.errors({ stack: true }), winston.format.timestamp(), (0, exports.withRunContext)(), (0, exports.redact)(), winston.format.splat(), textFormat),
|
|
221
|
+
// Stdout only — no File transports, consistent with the other DocGen services (no mounted
|
|
222
|
+
// log volume anywhere in this deployment, so a File transport is invisible to `kubectl logs`
|
|
223
|
+
// and can throw at import time under a read-only root filesystem).
|
|
224
|
+
transports: [new winston.transports.Console({ level: CONSOLE_LOG_LEVEL }), new DiagnosticsTransport()],
|
|
32
225
|
});
|
|
33
|
-
// }
|
|
34
226
|
exports.default = logger;
|
|
35
227
|
//# sourceMappingURL=logger.js.map
|
package/bin/utils/logger.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"logger.js","sourceRoot":"","sources":["../../src/utils/logger.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC
|
|
1
|
+
{"version":3,"file":"logger.js","sourceRoot":"","sources":["../../src/utils/logger.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;;;AACb,mCAAmC;AACnC,yBAAyB;AACzB,6BAA6B;AAC7B,+CAA+C;AAC/C,6CAA+C;AAC/C,uCAAwD;AACxD,IAAI,MAAsB,CAAC;AAE3B,4FAA4F;AAC5F,2FAA2F;AAC3F,gCAAgC;AACnB,QAAA,cAAc,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE;IACpD,MAAM,KAAK,GAAG,4BAAe,CAAC,QAAQ,EAAE,CAAC;IACzC,IAAI,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,KAAK;QAAG,IAAgC,CAAC,KAAK,GAAG,KAAK,CAAC,KAAK,CAAC;IACxE,uDAAuD;IACvD,IAAI,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,OAAO;QAAG,IAAgC,CAAC,OAAO,GAAG,KAAK,CAAC,OAAO,CAAC;IAC9E,wFAAwF;IACxF,IAAI,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,OAAO;QAAG,IAAgC,CAAC,OAAO,GAAG,KAAK,CAAC,OAAO,CAAC;IAC9E,OAAO,IAAI,CAAC;AACd,CAAC,CAAC,CAAC;AAEH,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C/E,MAAM,iBAAiB,GAAG,OAAO,CAAC,GAAG,CAAC,SAAS,IAAI,MAAM,CAAC;AAE1D,MAAM,GAAG,OAAO,CAAC,YAAY,CAAC;IAC5B,KAAK,EAAE,OAAO;IACd,WAAW,EAAE,EAAE,OAAO,EAAE,qCAAqC,EAAE,OAAO,EAAE,cAAc,EAAE,EAAE;IAC1F,MAAM,EAAE,OAAO;QACb,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC,OAAO,CACpB,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,EACtC,OAAO,CAAC,MAAM,CAAC,SAAS,EAAE,EAC1B,IAAA,sBAAc,GAAE,EAChB,IAAA,cAAM,GAAE,EACR,OAAO,CAAC,MAAM,CAAC,KAAK,EAAE,EACtB,OAAO,CAAC,MAAM,CAAC,IAAI,EAAE,CACtB;QACH,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC,OAAO,CACpB,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,EACtC,OAAO,CAAC,MAAM,CAAC,SAAS,EAAE,EAC1B,IAAA,sBAAc,GAAE,EAChB,IAAA,cAAM,GAAE,EACR,OAAO,CAAC,MAAM,CAAC,KAAK,EAAE,EACtB,UAAU,CACX;IACL,0FAA0F;IAC1F,6FAA6F;IAC7F,mEAAmE;IACnE,UAAU,EAAE,CAAC,IAAI,OAAO,CAAC,UAAU,CAAC,OAAO,CAAC,EAAE,KAAK,EAAE,iBAAiB,EAAE,CAAC,EAAE,IAAI,oBAAoB,EAAE,CAAC;CACvG,CAAC,CAAC;AAEH,kBAAe,MAAM,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
var _a;
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.runContextStore = void 0;
|
|
5
|
+
const async_hooks_1 = require("async_hooks");
|
|
6
|
+
// Symbol.for uses the global symbol registry, so every duplicated copy of this file across
|
|
7
|
+
// the DocGen packages — hoisted or nested at any depth by npm — converges on the same
|
|
8
|
+
// AsyncLocalStorage instance. Keying by module identity instead would silently split into
|
|
9
|
+
// two stores and runId would go missing with no visible error.
|
|
10
|
+
const KEY = Symbol.for('elisradevops.docgen.runContext');
|
|
11
|
+
exports.runContextStore = (_a = globalThis[KEY]) !== null && _a !== void 0 ? _a : (globalThis[KEY] = new async_hooks_1.AsyncLocalStorage());
|
|
12
|
+
//# sourceMappingURL=runContext.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runContext.js","sourceRoot":"","sources":["../../src/utils/runContext.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;;;;AACb,6CAAgD;AAehD,2FAA2F;AAC3F,sFAAsF;AACtF,0FAA0F;AAC1F,+DAA+D;AAC/D,MAAM,GAAG,GAAG,MAAM,CAAC,GAAG,CAAC,gCAAgC,CAAC,CAAC;AAE5C,QAAA,eAAe,GAC1B,MAAE,UAAsC,CAAC,GAAG,CAA+C,mCAC3F,CAAE,UAAsC,CAAC,GAAG,CAAC,GAAG,IAAI,+BAAiB,EAAc,CAAC,CAAC"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import tseslint from 'typescript-eslint';
|
|
2
|
+
import globals from 'globals';
|
|
3
|
+
|
|
4
|
+
// Phase 4 regression guard: bans the two log-record-corrupting patterns the observability plan
|
|
5
|
+
// found and fixed by hand across all four backend repos. Deliberately does NOT extend
|
|
6
|
+
// js.configs.recommended/tseslint's recommended rule sets — this repo has never had a linter,
|
|
7
|
+
// and pulling in a general rule set now would surface a large, unrelated pre-existing backlog
|
|
8
|
+
// (unused vars, etc.) as new lint failures. Scope is exactly the one regression this guards
|
|
9
|
+
// against. Keep this file identical in shape across docgen-api-gate / docgen-content-control /
|
|
10
|
+
// docgen-data-provider-package / docgen-dg-skins-package — see each repo's CLAUDE.md "keep
|
|
11
|
+
// these files in sync" note.
|
|
12
|
+
export default tseslint.config(
|
|
13
|
+
{
|
|
14
|
+
ignores: ['bin/**', 'coverage/**', '**/test/**', '**/tests/**'],
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
files: ['src/**/*.ts'],
|
|
18
|
+
extends: [tseslint.configs.base],
|
|
19
|
+
languageOptions: {
|
|
20
|
+
globals: globals.node,
|
|
21
|
+
},
|
|
22
|
+
rules: {
|
|
23
|
+
'no-restricted-syntax': [
|
|
24
|
+
'error',
|
|
25
|
+
{
|
|
26
|
+
selector:
|
|
27
|
+
"CallExpression[callee.object.name='logger'] > :matches(TemplateLiteral, BinaryExpression[operator='+']).arguments:first-child MemberExpression[property.name='stack']",
|
|
28
|
+
message:
|
|
29
|
+
'Do not embed .stack in the log message string — errors({stack:true}) attaches it automatically when the Error is passed as an argument. Pass the Error itself as a positional/meta argument instead.',
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
selector:
|
|
33
|
+
"CallExpression[callee.object.name='logger'] CallExpression[callee.object.name='JSON'][callee.property.name='stringify'] > Identifier.arguments:first-child[name=/^(e|err|error|ex)$/]",
|
|
34
|
+
message:
|
|
35
|
+
"Don't JSON.stringify an Error — message/stack are non-enumerable and it serializes to {}. Pass the Error object directly as a log argument.",
|
|
36
|
+
},
|
|
37
|
+
],
|
|
38
|
+
},
|
|
39
|
+
}
|
|
40
|
+
);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@elisra-devops/docgen-data-provider",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.141.0",
|
|
4
4
|
"description": "A document generator data provider, aimed to retrive data from azure devops",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -11,9 +11,11 @@
|
|
|
11
11
|
"types": "./bin/index.d.ts",
|
|
12
12
|
"scripts": {
|
|
13
13
|
"test": "jest --coverage --runInBand --forceExit",
|
|
14
|
-
"build": "tsc"
|
|
14
|
+
"build": "tsc",
|
|
15
|
+
"lint": "eslint ."
|
|
15
16
|
},
|
|
16
17
|
"devDependencies": {
|
|
18
|
+
"@eslint/js": "^9.39.5",
|
|
17
19
|
"@types/babel__generator": "^7.6.8",
|
|
18
20
|
"@types/babel__template": "^7.4.4",
|
|
19
21
|
"@types/caseless": "^0.12.5",
|
|
@@ -24,11 +26,14 @@
|
|
|
24
26
|
"@types/yargs-parser": "^21.0.3",
|
|
25
27
|
"baseline-browser-mapping": "^2.9.0",
|
|
26
28
|
"dotenv": "^16.4.5",
|
|
29
|
+
"eslint": "^9.39.5",
|
|
30
|
+
"globals": "^15.15.0",
|
|
27
31
|
"jest": "^29.7.0",
|
|
28
32
|
"jest-junit": "^16.0.0",
|
|
29
33
|
"npm": "^10.8.2",
|
|
30
34
|
"ts-jest": "^29.2.3",
|
|
31
|
-
"typescript": "^5.5.4"
|
|
35
|
+
"typescript": "^5.5.4",
|
|
36
|
+
"typescript-eslint": "^8.71.0"
|
|
32
37
|
},
|
|
33
38
|
"dependencies": {
|
|
34
39
|
"@types/xml2js": "^0.4.5",
|
package/src/helpers/tfs.ts
CHANGED
|
@@ -248,7 +248,7 @@ export class TFSServices {
|
|
|
248
248
|
|
|
249
249
|
// Log error if needed
|
|
250
250
|
if (printError) {
|
|
251
|
-
this.logDetailedError(e, url);
|
|
251
|
+
this.logDetailedError(e, url, attempts);
|
|
252
252
|
}
|
|
253
253
|
|
|
254
254
|
throw e;
|
|
@@ -286,23 +286,27 @@ export class TFSServices {
|
|
|
286
286
|
/**
|
|
287
287
|
* Log detailed error information
|
|
288
288
|
*/
|
|
289
|
-
private static logDetailedError(error: any, url: string): void {
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
}
|
|
298
|
-
|
|
299
|
-
error.response.data.message || JSON.stringify(error.response.data).substring(0, 200);
|
|
300
|
-
logger.error(`Response: ${dataMessage}`);
|
|
289
|
+
private static logDetailedError(error: any, url: string, attempt?: number): void {
|
|
290
|
+
let responseExcerpt: string | undefined;
|
|
291
|
+
if (error.response?.data) {
|
|
292
|
+
if (typeof error.response.data === 'string') {
|
|
293
|
+
responseExcerpt = error.response.data.substring(0, 200);
|
|
294
|
+
} else {
|
|
295
|
+
try {
|
|
296
|
+
responseExcerpt = error.response.data.message || JSON.stringify(error.response.data).substring(0, 200);
|
|
297
|
+
} catch {
|
|
298
|
+
responseExcerpt = '[unserializable response data]';
|
|
301
299
|
}
|
|
302
300
|
}
|
|
303
|
-
} else {
|
|
304
|
-
logger.error(`Error for ${url} - ${error.message}`);
|
|
305
301
|
}
|
|
302
|
+
logger.error('ADO request failed', {
|
|
303
|
+
message: error.message,
|
|
304
|
+
stack: error.stack,
|
|
305
|
+
url,
|
|
306
|
+
status: error.response?.status,
|
|
307
|
+
responseExcerpt,
|
|
308
|
+
attempt,
|
|
309
|
+
});
|
|
306
310
|
}
|
|
307
311
|
|
|
308
312
|
private static getErrorMessage(error: any): string {
|
|
@@ -19,7 +19,7 @@ export default class JfrogDataProvider {
|
|
|
19
19
|
if (!serviceConnectionResponse?.url) {
|
|
20
20
|
throw new Error(`Service connection ${connectionId} returned no URL — identity may lack service-endpoint read permission`);
|
|
21
21
|
}
|
|
22
|
-
logger.debug(`service connection url ${
|
|
22
|
+
logger.debug(`service connection url ${serviceConnectionResponse.url}`);
|
|
23
23
|
return serviceConnectionResponse.url;
|
|
24
24
|
}
|
|
25
25
|
|
|
@@ -1252,7 +1252,7 @@ export default class PipelinesDataProvider {
|
|
|
1252
1252
|
},
|
|
1253
1253
|
parameters: parameter, //'{"Test":"123"}'
|
|
1254
1254
|
};
|
|
1255
|
-
logger.info(
|
|
1255
|
+
logger.info('Triggering build', data);
|
|
1256
1256
|
let url = `${this.orgUrl}${projectName}/_apis/build/builds?api-version=5.0`;
|
|
1257
1257
|
let res = await TFSServices.postRequest(url, this.token, 'post', data, null);
|
|
1258
1258
|
return res;
|