@indigoai-us/hq-cli 5.345.168 → 5.345.170
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/CHANGELOG.md +23 -0
- package/dist/command-catalog.generated.d.ts +49 -4
- package/dist/command-catalog.generated.js +60 -4
- package/dist/commands/access.js +7 -2
- package/dist/commands/bot.js +4 -0
- package/dist/commands/cloud.d.ts +20 -0
- package/dist/commands/cloud.js +55 -4
- package/dist/commands/core-checkpoint-native.js +30 -10
- package/dist/commands/feedback-triage.d.ts +43 -1
- package/dist/commands/feedback-triage.js +123 -23
- package/dist/commands/feedback.d.ts +40 -1
- package/dist/commands/feedback.js +195 -7
- package/dist/commands/files.d.ts +42 -0
- package/dist/commands/files.js +223 -30
- package/dist/commands/mesh.js +6 -0
- package/dist/commands/sync-manifest.d.ts +16 -0
- package/dist/commands/sync-manifest.js +17 -1
- package/dist/lib/bot/decisions.d.ts +62 -0
- package/dist/lib/bot/decisions.js +228 -0
- package/dist/lib/bot/index.d.ts +1 -0
- package/dist/lib/bot/index.js +1 -0
- package/dist/lib/bot/run.d.ts +7 -0
- package/dist/lib/bot/run.js +104 -1
- package/dist/lib/daemon/catalog.d.ts +4 -0
- package/dist/lib/daemon/catalog.js +60 -29
- package/dist/lib/daemon/config.d.ts +7 -0
- package/dist/lib/daemon/config.js +32 -0
- package/dist/lib/daemon/run.d.ts +3 -2
- package/dist/lib/daemon/run.js +23 -3
- package/dist/lib/daemon/supervisor.d.ts +1 -0
- package/dist/lib/daemon/supervisor.js +4 -0
- package/dist/lib/daemon/sync-core-canary.d.ts +9 -0
- package/dist/lib/daemon/sync-core-canary.js +56 -0
- package/dist/lib/doctor/checks/sync-health.d.ts +39 -1
- package/dist/lib/doctor/checks/sync-health.js +121 -3
- package/dist/lib/doctor/fix/apply.d.ts +66 -8
- package/dist/lib/doctor/fix/apply.js +278 -80
- package/dist/lib/doctor/fix/process-identity.d.ts +13 -0
- package/dist/lib/doctor/fix/process-identity.js +34 -0
- package/dist/lib/doctor/fix/refresh-sync-handoff.d.ts +201 -0
- package/dist/lib/doctor/fix/refresh-sync-handoff.js +752 -0
- package/dist/lib/doctor/fix/refresh-sync-outcome.d.ts +1 -1
- package/dist/lib/doctor/fix/refresh-sync-outcome.js +13 -0
- package/dist/lib/doctor/types.d.ts +1 -1
- package/dist/lib/doctor/types.js +3 -0
- package/dist/lib/mesh/live/daemon/work-subscribe.js +31 -0
- package/dist/lib/work-context/organize.d.ts +7 -0
- package/dist/lib/work-context/organize.js +21 -1
- package/dist/sentry-before-send.js +14 -0
- package/dist/utils/breadcrumb-buffer.js +15 -4
- package/dist/utils/feedback-diagnostics.js +5 -2
- package/dist/utils/feedback-logs.d.ts +7 -0
- package/dist/utils/feedback-logs.js +37 -3
- package/dist/utils/scrub-diagnostics.d.ts +4 -0
- package/dist/utils/scrub-diagnostics.js +95 -0
- package/package.json +7 -7
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/** Privacy-safe outcomes for a targeted refresh-sync attempt. */
|
|
2
|
-
export declare const REFRESH_SYNC_OUTCOMES: readonly ["pull-succeeded", "pull-timeout", "pull-failed:4xx", "pull-failed:5xx", "pull-failed:network", "pull-failed:other"];
|
|
2
|
+
export declare const REFRESH_SYNC_OUTCOMES: readonly ["pull-succeeded", "pull-timeout", "pull-handed-off", "pull-preempted", "pull-timeout-capped", "pull-failed:lock-busy", "pull-failed:4xx", "pull-failed:5xx", "pull-failed:network", "pull-failed:other"];
|
|
3
3
|
export type RefreshSyncOutcome = (typeof REFRESH_SYNC_OUTCOMES)[number];
|
|
4
4
|
/** Outcomes that say nothing about the journal itself: offline, timed out, or the service failed. */
|
|
5
5
|
export declare const TRANSIENT_REFRESH_SYNC_OUTCOMES: ReadonlySet<RefreshSyncOutcome>;
|
|
@@ -2,6 +2,10 @@
|
|
|
2
2
|
export const REFRESH_SYNC_OUTCOMES = [
|
|
3
3
|
"pull-succeeded",
|
|
4
4
|
"pull-timeout",
|
|
5
|
+
"pull-handed-off",
|
|
6
|
+
"pull-preempted",
|
|
7
|
+
"pull-timeout-capped",
|
|
8
|
+
"pull-failed:lock-busy",
|
|
5
9
|
"pull-failed:4xx",
|
|
6
10
|
"pull-failed:5xx",
|
|
7
11
|
"pull-failed:network",
|
|
@@ -10,6 +14,10 @@ export const REFRESH_SYNC_OUTCOMES = [
|
|
|
10
14
|
/** Outcomes that say nothing about the journal itself: offline, timed out, or the service failed. */
|
|
11
15
|
export const TRANSIENT_REFRESH_SYNC_OUTCOMES = new Set([
|
|
12
16
|
"pull-timeout",
|
|
17
|
+
"pull-handed-off",
|
|
18
|
+
"pull-preempted",
|
|
19
|
+
"pull-timeout-capped",
|
|
20
|
+
"pull-failed:lock-busy",
|
|
13
21
|
"pull-failed:network",
|
|
14
22
|
"pull-failed:5xx",
|
|
15
23
|
]);
|
|
@@ -26,6 +34,11 @@ export function classifyRefreshSyncOutcome(observation) {
|
|
|
26
34
|
if (!errorCode && observation.status === 0) {
|
|
27
35
|
return "pull-succeeded";
|
|
28
36
|
}
|
|
37
|
+
// Another HQ operation (usually the sync runner's pass) held the per-root
|
|
38
|
+
// lock past --lock-timeout. Nothing is wrong with the journal itself.
|
|
39
|
+
if (/another HQ operation is already\s+running/.test(details)) {
|
|
40
|
+
return "pull-failed:lock-busy";
|
|
41
|
+
}
|
|
29
42
|
const httpStatus = /(?:HTTP(?:\/\d(?:\.\d)?)?\s+|status(?:\s+code)?\s*[=: ]\s*)([45]\d\d)\b/i.exec(details)?.[1] ?? "";
|
|
30
43
|
if (httpStatus.startsWith("4"))
|
|
31
44
|
return "pull-failed:4xx";
|
|
@@ -19,7 +19,7 @@ export declare const DOCTOR_STATUSES: readonly ["PASS", "FAIL", "WARN", "UNTESTE
|
|
|
19
19
|
*/
|
|
20
20
|
export type DoctorStatus = (typeof DOCTOR_STATUSES)[number];
|
|
21
21
|
/** Stable, privacy-safe diagnostics emitted by the sync health family. */
|
|
22
|
-
export declare const SYNC_REASON_CODES: readonly ["core-version-unavailable", "core-update-available", "no-local-tree", "company-not-resolved", "legacy-personal-journal", "never-synced", "invalid-last-sync", "stale-threshold", "manifest-unavailable", "manifest-state-unavailable", "no-manifest-scopes", "never-uploaded", "invalid-upload-time", "unresolved-company-uid", "realtime-lag-stuck", "receiver-permission-denied", "pull-access-denied", "runner-restart-loop", "device-limit-backoff", "repeated-conflicts"];
|
|
22
|
+
export declare const SYNC_REASON_CODES: readonly ["core-version-unavailable", "core-update-available", "no-local-tree", "company-not-resolved", "legacy-personal-journal", "never-synced", "invalid-last-sync", "stale-threshold", "refresh-in-progress", "refresh-lock-held", "manifest-unavailable", "manifest-state-unavailable", "no-manifest-scopes", "never-uploaded", "invalid-upload-time", "manifest-upload-rejected", "unresolved-company-uid", "realtime-lag-stuck", "receiver-permission-denied", "pull-access-denied", "runner-restart-loop", "device-limit-backoff", "repeated-conflicts"];
|
|
23
23
|
export type SyncReasonCode = (typeof SYNC_REASON_CODES)[number];
|
|
24
24
|
/** Runtime type guard: true only for a member of the fixed vocabulary. */
|
|
25
25
|
export declare function isDoctorStatus(value: unknown): value is DoctorStatus;
|
package/dist/lib/doctor/types.js
CHANGED
|
@@ -31,11 +31,14 @@ export const SYNC_REASON_CODES = [
|
|
|
31
31
|
"never-synced",
|
|
32
32
|
"invalid-last-sync",
|
|
33
33
|
"stale-threshold",
|
|
34
|
+
"refresh-in-progress",
|
|
35
|
+
"refresh-lock-held",
|
|
34
36
|
"manifest-unavailable",
|
|
35
37
|
"manifest-state-unavailable",
|
|
36
38
|
"no-manifest-scopes",
|
|
37
39
|
"never-uploaded",
|
|
38
40
|
"invalid-upload-time",
|
|
41
|
+
"manifest-upload-rejected",
|
|
39
42
|
"unresolved-company-uid",
|
|
40
43
|
"realtime-lag-stuck",
|
|
41
44
|
"receiver-permission-denied",
|
|
@@ -12,6 +12,33 @@ import { backoffDelayMs, RECONNECT_MIN_DELAY_MS } from "./presence.js";
|
|
|
12
12
|
import { AGENT_INBOX_PUSH_STATE_BASENAME, SYNC_WAKE_STATE_BASENAME } from "../paths.js";
|
|
13
13
|
export { AGENT_INBOX_PUSH_STATE_BASENAME, SYNC_WAKE_STATE_BASENAME } from "../paths.js";
|
|
14
14
|
const INBOX_PUSH_HEARTBEAT_MS = 5_000;
|
|
15
|
+
const SYNC_WAKE_KEYS = new Set(["v", "type", "vault", "head", "rootId"]);
|
|
16
|
+
const SYNC_WAKE_VAULT = /^(?:prs|cmp|agt)_[0-9A-Za-z]+$/;
|
|
17
|
+
const SYNC_WAKE_ROOT = /^[0-9a-f]{64}$/i;
|
|
18
|
+
function isSyncWakeEnvelope(payload) {
|
|
19
|
+
let parsed;
|
|
20
|
+
try {
|
|
21
|
+
parsed = JSON.parse(Buffer.isBuffer(payload) ? payload.toString("utf8") : payload);
|
|
22
|
+
}
|
|
23
|
+
catch {
|
|
24
|
+
return false;
|
|
25
|
+
}
|
|
26
|
+
if (!parsed || typeof parsed !== "object" || Array.isArray(parsed))
|
|
27
|
+
return false;
|
|
28
|
+
const message = parsed;
|
|
29
|
+
const keys = Object.keys(message);
|
|
30
|
+
if (keys.length !== SYNC_WAKE_KEYS.size || keys.some((key) => !SYNC_WAKE_KEYS.has(key))) {
|
|
31
|
+
return false;
|
|
32
|
+
}
|
|
33
|
+
return message.v === 1 &&
|
|
34
|
+
message.type === "vault.head" &&
|
|
35
|
+
typeof message.vault === "string" &&
|
|
36
|
+
SYNC_WAKE_VAULT.test(message.vault) &&
|
|
37
|
+
Number.isSafeInteger(message.head) &&
|
|
38
|
+
Number(message.head) > 0 &&
|
|
39
|
+
(message.rootId === null ||
|
|
40
|
+
(typeof message.rootId === "string" && SYNC_WAKE_ROOT.test(message.rootId)));
|
|
41
|
+
}
|
|
15
42
|
function readWakeSequence(meshRoot, basename, label, onInfo) {
|
|
16
43
|
const target = path.join(meshRoot, basename);
|
|
17
44
|
try {
|
|
@@ -260,6 +287,10 @@ export async function startWorkCacheSubscriber(opts) {
|
|
|
260
287
|
return;
|
|
261
288
|
}
|
|
262
289
|
if (syncTopic && _topic === syncTopic && syncSubscribed) {
|
|
290
|
+
if (!isSyncWakeEnvelope(payload)) {
|
|
291
|
+
opts.onInfo?.("sync wake ignored (invalid envelope)");
|
|
292
|
+
return;
|
|
293
|
+
}
|
|
263
294
|
syncWakeSequence += 1;
|
|
264
295
|
persistSyncState(true);
|
|
265
296
|
return;
|
|
@@ -91,6 +91,13 @@ export declare function prepareOrganizeDecision(input: {
|
|
|
91
91
|
fetchCandidates?: FetchCandidatesFn;
|
|
92
92
|
/** Skip network; leave unresolved without candidates. */
|
|
93
93
|
offline?: boolean;
|
|
94
|
+
/**
|
|
95
|
+
* Membership-validated slug -> companyUid. Reconcile can persist a session
|
|
96
|
+
* with only `companySlug` (for example a local-only project bound while the
|
|
97
|
+
* membership lookup was offline or failed). Online organize uses this to
|
|
98
|
+
* recover the uid instead of reporting `candidates_unavailable`.
|
|
99
|
+
*/
|
|
100
|
+
resolveCompanyUid?: (companySlug: string) => Promise<string | null | undefined>;
|
|
94
101
|
}): Promise<OrganizeListResult>;
|
|
95
102
|
/** True when a local decision's server window has passed (or is unparsable). */
|
|
96
103
|
export declare function isLocalDecisionExpired(expiresAt: string | undefined, now?: Date): boolean;
|
|
@@ -76,7 +76,7 @@ export function decisionFromCandidates(sessionId, response) {
|
|
|
76
76
|
*/
|
|
77
77
|
export async function prepareOrganizeDecision(input) {
|
|
78
78
|
const nowFn = input.now ?? (() => new Date());
|
|
79
|
-
|
|
79
|
+
let state = readSessionState(input.sessionId, input.root);
|
|
80
80
|
if (!state) {
|
|
81
81
|
return {
|
|
82
82
|
sessionId: input.sessionId,
|
|
@@ -114,6 +114,26 @@ export async function prepareOrganizeDecision(input) {
|
|
|
114
114
|
reason: state.contextStatus,
|
|
115
115
|
};
|
|
116
116
|
}
|
|
117
|
+
// Recover the uid after the status gates, before refreshExpired and the
|
|
118
|
+
// candidates_unavailable gate both read it.
|
|
119
|
+
if (!state.companyUid &&
|
|
120
|
+
state.companySlug &&
|
|
121
|
+
!input.offline &&
|
|
122
|
+
input.fetchCandidates &&
|
|
123
|
+
input.resolveCompanyUid) {
|
|
124
|
+
let recovered;
|
|
125
|
+
try {
|
|
126
|
+
recovered = await input.resolveCompanyUid(state.companySlug);
|
|
127
|
+
}
|
|
128
|
+
catch {
|
|
129
|
+
recovered = undefined;
|
|
130
|
+
}
|
|
131
|
+
if (typeof recovered === "string" && recovered.startsWith("cmp_")) {
|
|
132
|
+
const withUid = mergeLocalSessionFields({ ...state, companyUid: recovered, updatedAt: nowFn().toISOString() }, state);
|
|
133
|
+
writeSessionState(withUid, input.root);
|
|
134
|
+
state = withUid;
|
|
135
|
+
}
|
|
136
|
+
}
|
|
117
137
|
// Ask-once: an existing decision is never replaced or re-armed — unless its
|
|
118
138
|
// server decision window has expired. The server stamps a fresh window only
|
|
119
139
|
// when candidates are listed, so returning the stale decision would make
|
|
@@ -2,6 +2,13 @@ const SENSITIVE_FIELD_NAMES = new Set([
|
|
|
2
2
|
"password", "secret", "apikey", "api_key", "token",
|
|
3
3
|
// Cognito token-response fields captured as error context.
|
|
4
4
|
"idtoken", "accesstoken", "refreshtoken",
|
|
5
|
+
// Signed-URL query params, so scrubQueryString and key walks redact them.
|
|
6
|
+
"x-amz-signature", "x-amz-credential", "x-amz-security-token",
|
|
7
|
+
"x-goog-signature", "x-goog-credential", "signature", "sig",
|
|
8
|
+
// CloudFront signed-URL params, and the access-key ids paired with
|
|
9
|
+
// signatures; same names the string pattern below already covers.
|
|
10
|
+
"policy", "key-pair-id", "awsaccesskeyid", "googleaccessid",
|
|
11
|
+
"sessiontoken", "session_token",
|
|
5
12
|
]);
|
|
6
13
|
// Stored lowercased; membership tested against `name.toLowerCase()`.
|
|
7
14
|
// MUST cover BOTH Auth.js v5 (current in hq-console, pinned to
|
|
@@ -110,6 +117,10 @@ const SENSITIVE_STRING_PATTERNS = [
|
|
|
110
117
|
/\b(password|secret|api[_-]?key|(?:id|access|refresh)[_-]?token|token)\s*[:=]\s*[^\s&"'<>]+/gi,
|
|
111
118
|
/\b(Bearer|Basic)\s+[A-Za-z0-9._~+/=-]+/gi,
|
|
112
119
|
/\beyJ[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,}\b/g,
|
|
120
|
+
// Signed-URL params (SigV4/SigV2, GCS, CloudFront, Azure SAS): plain, at the
|
|
121
|
+
// start of a bare query string, or URL-encoded. S3 presigned URLs carry the
|
|
122
|
+
// STS session token in X-Amz-Security-Token (feedback family ec9435cd).
|
|
123
|
+
/(?:^|(?<=[?&;\s"'(]|%3F|%26))(?:X-Amz-Signature|X-Amz-Credential|X-Amz-Security-Token|X-Amz-SignedHeaders|AWSAccessKeyId|Signature|X-Goog-Signature|X-Goog-Credential|GoogleAccessId|Policy|Key-Pair-Id|sig)(?:=|%3D)[^&\s"'#<>]+/gi,
|
|
113
124
|
];
|
|
114
125
|
function scrubString(s) {
|
|
115
126
|
let out = s;
|
|
@@ -197,11 +208,14 @@ export function beforeSend(event, _hint) {
|
|
|
197
208
|
"never-synced",
|
|
198
209
|
"invalid-last-sync",
|
|
199
210
|
"stale-threshold",
|
|
211
|
+
"refresh-in-progress",
|
|
212
|
+
"refresh-lock-held",
|
|
200
213
|
"manifest-unavailable",
|
|
201
214
|
"manifest-state-unavailable",
|
|
202
215
|
"no-manifest-scopes",
|
|
203
216
|
"never-uploaded",
|
|
204
217
|
"invalid-upload-time",
|
|
218
|
+
"manifest-upload-rejected",
|
|
205
219
|
"unresolved-company-uid",
|
|
206
220
|
]);
|
|
207
221
|
const platforms = new Set([
|
|
@@ -1,15 +1,26 @@
|
|
|
1
|
+
import { scrubDiagnosticsValue } from "./scrub-diagnostics.js";
|
|
1
2
|
const BUFFER_SIZE = 20;
|
|
2
3
|
const _buffer = [];
|
|
3
|
-
// Sentry beforeBreadcrumb hook: records every breadcrumb in
|
|
4
|
-
// and returns
|
|
4
|
+
// Sentry beforeBreadcrumb hook: records a scrubbed copy of every breadcrumb in
|
|
5
|
+
// a ring buffer and returns the original so Sentry still processes it (its
|
|
6
|
+
// own beforeSend scrubber runs on the way out). The buffer feeds feedback
|
|
7
|
+
// diagnostics, which beforeSend never sees, so it must never hold raw
|
|
8
|
+
// presigned URLs or tokens.
|
|
5
9
|
export function beforeBreadcrumb(breadcrumb) {
|
|
6
|
-
|
|
10
|
+
let copy;
|
|
11
|
+
try {
|
|
12
|
+
copy = scrubDiagnosticsValue(breadcrumb);
|
|
13
|
+
}
|
|
14
|
+
catch {
|
|
15
|
+
copy = { category: breadcrumb.category, message: "[breadcrumb dropped: scrub failed]" };
|
|
16
|
+
}
|
|
17
|
+
_buffer.push(copy);
|
|
7
18
|
if (_buffer.length > BUFFER_SIZE) {
|
|
8
19
|
_buffer.shift();
|
|
9
20
|
}
|
|
10
21
|
return breadcrumb;
|
|
11
22
|
}
|
|
12
23
|
export function getRecentBreadcrumbs() {
|
|
13
|
-
return [..._buffer];
|
|
24
|
+
return scrubDiagnosticsValue([..._buffer]);
|
|
14
25
|
}
|
|
15
26
|
//# sourceMappingURL=breadcrumb-buffer.js.map
|
|
@@ -4,6 +4,7 @@ import { getRecentBreadcrumbs } from "./breadcrumb-buffer.js";
|
|
|
4
4
|
import { CLI_VERSION } from "../cli-version.js";
|
|
5
5
|
import { collectVersions } from "./feedback-versions.js";
|
|
6
6
|
import { sanitizeArgv } from "./sanitize-argv.js";
|
|
7
|
+
import { scrubDiagnosticsValue } from "./scrub-diagnostics.js";
|
|
7
8
|
export { sanitizeArgv } from "./sanitize-argv.js";
|
|
8
9
|
function sanitizeRemoteUrl(url) {
|
|
9
10
|
return url.replace(/https?:\/\/[^@]+@/, "https://***@");
|
|
@@ -49,7 +50,9 @@ function collectGitContext() {
|
|
|
49
50
|
return { branch, head, dirty, remoteUrl };
|
|
50
51
|
}
|
|
51
52
|
export function collectDiagnostics() {
|
|
52
|
-
|
|
53
|
+
// Every field passes through the scrubber, not only the breadcrumbs: argv,
|
|
54
|
+
// cwd and the git remote can also carry a presigned URL or a token.
|
|
55
|
+
return scrubDiagnosticsValue({
|
|
53
56
|
cliVersion: CLI_VERSION,
|
|
54
57
|
versions: collectVersions(),
|
|
55
58
|
nodeVersion: process.version,
|
|
@@ -62,6 +65,6 @@ export function collectDiagnostics() {
|
|
|
62
65
|
cwd: process.cwd(),
|
|
63
66
|
git: collectGitContext(),
|
|
64
67
|
recentSentryBreadcrumbs: getRecentBreadcrumbs(),
|
|
65
|
-
};
|
|
68
|
+
});
|
|
66
69
|
}
|
|
67
70
|
//# sourceMappingURL=feedback-diagnostics.js.map
|
|
@@ -181,6 +181,13 @@ export interface LogCandidate {
|
|
|
181
181
|
sizeBytes: number;
|
|
182
182
|
modifiedMs: number;
|
|
183
183
|
}
|
|
184
|
+
/**
|
|
185
|
+
* Query parameters that sign or authorize a URL: AWS SigV4 (S3 presigned
|
|
186
|
+
* URLs carry the STS session token in X-Amz-Security-Token), legacy SigV2,
|
|
187
|
+
* GCS V4, CloudFront signed URLs and Azure SAS. Exported for the feedback
|
|
188
|
+
* diagnostics scrubber.
|
|
189
|
+
*/
|
|
190
|
+
export declare const SIGNED_URL_PARAM_PATTERN: RegExp;
|
|
184
191
|
/**
|
|
185
192
|
* Replace every secret-shaped span in `text`. Returns the redacted text and a
|
|
186
193
|
* count of replacements, so triage can tell "no secrets present" from
|
|
@@ -189,6 +189,13 @@ const FEEDBACK_ROOT_LOG_FILENAMES = [
|
|
|
189
189
|
"boot-sync.log",
|
|
190
190
|
"boot-capture.log",
|
|
191
191
|
];
|
|
192
|
+
/**
|
|
193
|
+
* Query parameters that sign or authorize a URL: AWS SigV4 (S3 presigned
|
|
194
|
+
* URLs carry the STS session token in X-Amz-Security-Token), legacy SigV2,
|
|
195
|
+
* GCS V4, CloudFront signed URLs and Azure SAS. Exported for the feedback
|
|
196
|
+
* diagnostics scrubber.
|
|
197
|
+
*/
|
|
198
|
+
export const SIGNED_URL_PARAM_PATTERN = /((?:^|[?&;\s"'(]|%3F|%26)(?:X-Amz-Signature|X-Amz-Credential|X-Amz-Security-Token|X-Amz-SignedHeaders|AWSAccessKeyId|Signature|X-Goog-Signature|X-Goog-Credential|GoogleAccessId|Policy|Key-Pair-Id|sig|token|access_token|id_token|refresh_token|session_token)(?:=|%3D))[^&\s"'#<>]+/gi;
|
|
192
199
|
/**
|
|
193
200
|
* Redaction patterns, applied in order. Structured secrets (whole PEM blocks)
|
|
194
201
|
* come first so a later, narrower pattern cannot chop one into fragments that
|
|
@@ -220,20 +227,47 @@ const REDACTION_PATTERNS = [
|
|
|
220
227
|
pattern: /\bxox[abposr]-[A-Za-z0-9-]{10,}\b/g,
|
|
221
228
|
replace: () => "[redacted slack token]",
|
|
222
229
|
},
|
|
230
|
+
// HQ API keys.
|
|
231
|
+
{
|
|
232
|
+
pattern: /\bhqk_[A-Za-z0-9_-]{8,}/g,
|
|
233
|
+
replace: () => "[redacted hq key]",
|
|
234
|
+
},
|
|
223
235
|
// SigV4 presigned-URL material. Keeps the URL readable, drops what signs it.
|
|
224
236
|
{
|
|
225
|
-
|
|
237
|
+
// Matches the param at a `?`/`&`/`;` boundary, at the start of a bare
|
|
238
|
+
// query string (Sentry's `http.query` breadcrumb field), or URL-encoded
|
|
239
|
+
// (`%3F`/`%26` boundary, `%3D` separator) inside another URL.
|
|
240
|
+
pattern: SIGNED_URL_PARAM_PATTERN,
|
|
226
241
|
replace: (_m, prefix) => `${prefix}[redacted]`,
|
|
227
242
|
},
|
|
228
243
|
// `Authorization: Bearer <token>` in any casing.
|
|
244
|
+
// Signed-URL params written as header lines or quoted JSON keys
|
|
245
|
+
// (`X-Amz-Signature: v`, `"X-Amz-Credential":"v"`).
|
|
246
|
+
{
|
|
247
|
+
pattern: /("?\b(?:X-Amz-Signature|X-Amz-Credential|X-Amz-Security-Token|X-Goog-Signature|X-Goog-Credential)"?\s*:\s*"?)([^\s",;&}]+)/gi,
|
|
248
|
+
replace: (_m, prefix) => `${prefix}[redacted]`,
|
|
249
|
+
},
|
|
250
|
+
// `Authorization:` / `Proxy-Authorization:` with ANY scheme (Basic, Bearer,
|
|
251
|
+
// custom): the whole value to the end of the line or closing quote goes,
|
|
252
|
+
// however short.
|
|
253
|
+
{
|
|
254
|
+
pattern: /(\b(?:Proxy-)?Authorization"?\s*[:=]\s*"?)([^"\r\n]+)/gi,
|
|
255
|
+
replace: (_m, prefix) => `${prefix}[redacted]`,
|
|
256
|
+
},
|
|
257
|
+
// Bare scheme credentials outside a header. Basic requires a digit or a
|
|
258
|
+
// base64 symbol so prose like "Basic functionality" stays readable.
|
|
259
|
+
{
|
|
260
|
+
pattern: /\b([Bb]earer\s+)[A-Za-z0-9._~+/=-]{8,}/g,
|
|
261
|
+
replace: (_m, prefix) => `${prefix}[redacted]`,
|
|
262
|
+
},
|
|
229
263
|
{
|
|
230
|
-
pattern: /\b([Bb]
|
|
264
|
+
pattern: /\b([Bb]asic\s+)(?=[A-Za-z0-9+/=]*[0-9+/=])[A-Za-z0-9+/=]{4,}/g,
|
|
231
265
|
replace: (_m, prefix) => `${prefix}[redacted]`,
|
|
232
266
|
},
|
|
233
267
|
// Generic `key: value` / `key=value` for names that denote a secret. Runs
|
|
234
268
|
// last so the specific patterns above produce the more informative label.
|
|
235
269
|
{
|
|
236
|
-
pattern: /("?\b(?:token|secret|password|passwd|api[_-]?key|access[_-]?key|secret[_-]?key|auth[_-]?token|authorization|credential|session[_-]?token)"?\s*[:=]\s*"?)([^\s",;&}]{6,})/gi,
|
|
270
|
+
pattern: /("?\b(?:(?:access|id|refresh)[_-]?token|token|secret|password|passwd|api[_-]?key|access[_-]?key|secret[_-]?key|auth[_-]?token|authorization|credential|session[_-]?token)"?\s*[:=]\s*"?)([^\s",;&}]{6,})/gi,
|
|
237
271
|
replace: (_m, prefix) => `${prefix}[redacted]`,
|
|
238
272
|
},
|
|
239
273
|
];
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export declare function isSensitiveDiagnosticsKey(key: string): boolean;
|
|
2
|
+
export declare function scrubDiagnosticsString(value: string): string;
|
|
3
|
+
export declare function scrubDiagnosticsValue<T>(value: T, seen?: WeakMap<object, unknown>): T;
|
|
4
|
+
//# sourceMappingURL=scrub-diagnostics.d.ts.map
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import { redactLogText } from "./feedback-logs.js";
|
|
2
|
+
/**
|
|
3
|
+
* Redaction for the feedback diagnostics blob.
|
|
4
|
+
*
|
|
5
|
+
* Feedback diagnostics are uploaded to hq-pro and stored on the feedback row.
|
|
6
|
+
* Sentry's `beforeSend` scrubber never sees them: the breadcrumb ring buffer
|
|
7
|
+
* records breadcrumbs in `beforeBreadcrumb`, before any scrubbing, and
|
|
8
|
+
* `collectDiagnostics` copied that buffer verbatim. Breadcrumbs from the
|
|
9
|
+
* Node http integration carry full request URLs, so S3 presigned URLs (with
|
|
10
|
+
* the STS session token in X-Amz-Security-Token) landed in stored rows.
|
|
11
|
+
*
|
|
12
|
+
* `scrubDiagnosticsValue` deep-copies any JSON-like value, replaces values
|
|
13
|
+
* under credential-named keys, and runs every string through the same
|
|
14
|
+
* redaction patterns as the inline log tails.
|
|
15
|
+
*/
|
|
16
|
+
const REDACTED = "[redacted]";
|
|
17
|
+
// Compared after lowercasing and dropping every non-alphanumeric character,
|
|
18
|
+
// so `X-Amz-Security-Token`, `x_amz_security_token` and `xAmzSecurityToken`
|
|
19
|
+
// all normalize to the same entry.
|
|
20
|
+
const SENSITIVE_KEYS = new Set([
|
|
21
|
+
"authorization",
|
|
22
|
+
"proxyauthorization",
|
|
23
|
+
"cookie",
|
|
24
|
+
"setcookie",
|
|
25
|
+
"token",
|
|
26
|
+
"accesstoken",
|
|
27
|
+
"idtoken",
|
|
28
|
+
"refreshtoken",
|
|
29
|
+
"sessiontoken",
|
|
30
|
+
"authtoken",
|
|
31
|
+
"bearertoken",
|
|
32
|
+
"securitytoken",
|
|
33
|
+
"xamzsecuritytoken",
|
|
34
|
+
"xamzsignature",
|
|
35
|
+
"xamzcredential",
|
|
36
|
+
"xapikey",
|
|
37
|
+
"xauthtoken",
|
|
38
|
+
"xaccesstoken",
|
|
39
|
+
"xsessiontoken",
|
|
40
|
+
"apikey",
|
|
41
|
+
"secret",
|
|
42
|
+
"clientsecret",
|
|
43
|
+
"secretaccesskey",
|
|
44
|
+
"password",
|
|
45
|
+
"passwd",
|
|
46
|
+
"signature",
|
|
47
|
+
"credential",
|
|
48
|
+
"credentials",
|
|
49
|
+
// Signed-URL params that arrive as structured keys (GCS, CloudFront, Azure SAS).
|
|
50
|
+
"xgoogsignature",
|
|
51
|
+
"xgoogcredential",
|
|
52
|
+
"googleaccessid",
|
|
53
|
+
"awsaccesskeyid",
|
|
54
|
+
"sig",
|
|
55
|
+
"policy",
|
|
56
|
+
"keypairid",
|
|
57
|
+
]);
|
|
58
|
+
function normalizeKey(key) {
|
|
59
|
+
return key.toLowerCase().replace(/[^a-z0-9]/g, "");
|
|
60
|
+
}
|
|
61
|
+
export function isSensitiveDiagnosticsKey(key) {
|
|
62
|
+
return SENSITIVE_KEYS.has(normalizeKey(key));
|
|
63
|
+
}
|
|
64
|
+
export function scrubDiagnosticsString(value) {
|
|
65
|
+
return redactLogText(value).text;
|
|
66
|
+
}
|
|
67
|
+
export function scrubDiagnosticsValue(value, seen = new WeakMap()) {
|
|
68
|
+
if (typeof value === "string")
|
|
69
|
+
return scrubDiagnosticsString(value);
|
|
70
|
+
if (value === null || typeof value !== "object")
|
|
71
|
+
return value;
|
|
72
|
+
const obj = value;
|
|
73
|
+
if (seen.has(obj))
|
|
74
|
+
return seen.get(obj);
|
|
75
|
+
if (Array.isArray(value)) {
|
|
76
|
+
const arr = [];
|
|
77
|
+
seen.set(obj, arr);
|
|
78
|
+
for (const item of value)
|
|
79
|
+
arr.push(scrubDiagnosticsValue(item, seen));
|
|
80
|
+
return arr;
|
|
81
|
+
}
|
|
82
|
+
const out = {};
|
|
83
|
+
seen.set(obj, out);
|
|
84
|
+
for (const [key, inner] of Object.entries(value)) {
|
|
85
|
+
const safeKey = scrubDiagnosticsString(key);
|
|
86
|
+
if (isSensitiveDiagnosticsKey(key) && inner !== null && inner !== undefined && inner !== "") {
|
|
87
|
+
out[safeKey] = REDACTED;
|
|
88
|
+
}
|
|
89
|
+
else {
|
|
90
|
+
out[safeKey] = scrubDiagnosticsValue(inner, seen);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
return out;
|
|
94
|
+
}
|
|
95
|
+
//# sourceMappingURL=scrub-diagnostics.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@indigoai-us/hq-cli",
|
|
3
|
-
"version": "5.345.
|
|
3
|
+
"version": "5.345.170",
|
|
4
4
|
"description": "HQ by Indigo management CLI — modules and cloud sync",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"bin": {
|
|
@@ -114,11 +114,11 @@
|
|
|
114
114
|
"*.{ts,tsx,mts,cts,js,jsx,mjs,cjs}": "eslint --cache --no-error-on-unmatched-pattern"
|
|
115
115
|
},
|
|
116
116
|
"optionalDependencies": {
|
|
117
|
-
"@indigoai-us/hq-hook-win32-x64": "5.345.
|
|
118
|
-
"@indigoai-us/hq-hook-win32-arm64": "5.345.
|
|
119
|
-
"@indigoai-us/hq-hook-darwin-x64": "5.345.
|
|
120
|
-
"@indigoai-us/hq-hook-darwin-arm64": "5.345.
|
|
121
|
-
"@indigoai-us/hq-hook-linux-x64": "5.345.
|
|
122
|
-
"@indigoai-us/hq-hook-linux-arm64": "5.345.
|
|
117
|
+
"@indigoai-us/hq-hook-win32-x64": "5.345.170",
|
|
118
|
+
"@indigoai-us/hq-hook-win32-arm64": "5.345.170",
|
|
119
|
+
"@indigoai-us/hq-hook-darwin-x64": "5.345.170",
|
|
120
|
+
"@indigoai-us/hq-hook-darwin-arm64": "5.345.170",
|
|
121
|
+
"@indigoai-us/hq-hook-linux-x64": "5.345.170",
|
|
122
|
+
"@indigoai-us/hq-hook-linux-arm64": "5.345.170"
|
|
123
123
|
}
|
|
124
124
|
}
|