@groundtrack/hooks 0.1.10 → 0.1.11
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.
|
@@ -202,10 +202,15 @@ export function discoverSessions(options) {
|
|
|
202
202
|
const normalizedRemote = metadata.repositoryUrl
|
|
203
203
|
? normalizeRepositoryUrl(metadata.repositoryUrl)
|
|
204
204
|
: null;
|
|
205
|
+
const cwdMatchesCurrentRepository = Boolean(options.repository && metadata.cwd && isInside(metadata.cwd, options.repository.root));
|
|
206
|
+
const currentRepositoryRemote = cwdMatchesCurrentRepository
|
|
207
|
+
? soleRemote(options.repository)
|
|
208
|
+
: null;
|
|
209
|
+
const remoteMatchesCurrentRepository = Boolean(options.repository && normalizedRemote && options.repository.remotes.has(normalizedRemote));
|
|
205
210
|
const matchesCurrentRepository = options.repository
|
|
206
|
-
?
|
|
207
|
-
|
|
208
|
-
|
|
211
|
+
? remoteMatchesCurrentRepository ||
|
|
212
|
+
(!normalizedRemote && cwdMatchesCurrentRepository) ||
|
|
213
|
+
Boolean(currentRepositoryRemote && cwdMatchesCurrentRepository)
|
|
209
214
|
: false;
|
|
210
215
|
if (!options.allRepositories && !matchesCurrentRepository) {
|
|
211
216
|
skipped.push({ path, reason: "other_repository" });
|
|
@@ -218,16 +223,15 @@ export function discoverSessions(options) {
|
|
|
218
223
|
skipped.push({ path, reason: "unscoped" });
|
|
219
224
|
continue;
|
|
220
225
|
}
|
|
221
|
-
const
|
|
222
|
-
?
|
|
223
|
-
:
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
: candidate);
|
|
226
|
+
const attributedRemote = remoteMatchesCurrentRepository
|
|
227
|
+
? normalizedRemote
|
|
228
|
+
: (currentRepositoryRemote ??
|
|
229
|
+
normalizedRemote ??
|
|
230
|
+
(options.allRepositories ? soleRemote(repositoryIdentityForCwd(metadata.cwd)) : null));
|
|
231
|
+
included.push({
|
|
232
|
+
...candidate,
|
|
233
|
+
metadata: { ...metadata, repositoryUrl: attributedRemote },
|
|
234
|
+
});
|
|
231
235
|
}
|
|
232
236
|
if (!options.format.materializeCandidates)
|
|
233
237
|
return { included, skipped, failed: [] };
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { CANONICAL_IMPORT_MAX_ENTRIES, isSessionRecord, sessionString, } from "./canonical.js";
|
|
2
|
+
import { sanitizeRepositoryUrl } from "./redaction.js";
|
|
2
3
|
export class SessionNormalizationError extends Error {
|
|
3
4
|
code;
|
|
4
5
|
constructor(code, message) {
|
|
@@ -65,6 +66,9 @@ export function createSessionNormalizationAccumulator(normalizer, options = {})
|
|
|
65
66
|
return {
|
|
66
67
|
metadata: {
|
|
67
68
|
...base,
|
|
69
|
+
repositoryUrl: options.discoveryMetadata
|
|
70
|
+
? sanitizeRepositoryUrl(options.discoveryMetadata.repositoryUrl)
|
|
71
|
+
: base.repositoryUrl,
|
|
68
72
|
startedAt: earliestTimestampMs === null
|
|
69
73
|
? (options.discoveryMetadata?.startedAt?.toISOString() ?? null)
|
|
70
74
|
: new Date(earliestTimestampMs).toISOString(),
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const sensitiveKeyPattern = /(?:^|[_-])(?:api[_-]?key|token|authorization|auth|password|passwd|secret|private[_-]?key|cookie|credentials?)(?:$|[_-])/i;
|
|
1
|
+
const sensitiveKeyPattern = /(?:^|[_-])(?:api[_-]?key|access[_-]?key(?:[_-]?id)?|token|authorization|auth|password|passwd|secret|private[_-]?key|cookie|credentials?|database[_-]?url)(?:$|[_-])/i;
|
|
2
2
|
const internalInstructionMarkers = [
|
|
3
3
|
"<local-command-caveat>",
|
|
4
4
|
"<system-reminder>",
|
|
@@ -19,9 +19,11 @@ export function redactCredentialText(value) {
|
|
|
19
19
|
return value
|
|
20
20
|
.replace(/-----BEGIN [A-Z ]*PRIVATE KEY-----[\s\S]*?-----END [A-Z ]*PRIVATE KEY-----/g, "[REDACTED PRIVATE KEY]")
|
|
21
21
|
.replace(/\b(authorization\s*:\s*(?:bearer|basic)\s+)[^\s,;]+/gi, "$1[REDACTED]")
|
|
22
|
-
.replace(/\b((?:[a-z0-9_-]*(?:api[_-]?key|token|password|passwd|secret|private[_-]?key|credentials?))\s*[=:]\s*)[^\s,;]+/gi, "$1[REDACTED]")
|
|
22
|
+
.replace(/\b((?:[a-z0-9_-]*(?:api[_-]?key|access[_-]?key(?:[_-]?id)?|token|password|passwd|secret|private[_-]?key|credentials?|database[_-]?url))\s*[=:]\s*)[^\s,;]+/gi, "$1[REDACTED]")
|
|
23
23
|
.replace(/(?:^|\s)((?:--)?(?:api-key|token|password|secret)\s+)[^\s,;]+/gi, "$1$2[REDACTED]")
|
|
24
|
-
.replace(/\b(?:sk-[A-Za-z0-9_-]{16,}|ghp_[A-Za-z0-9]{
|
|
24
|
+
.replace(/\b(?:sk-[A-Za-z0-9_-]{16,}|ghp_[A-Za-z0-9]{8,}|github_pat_[A-Za-z0-9_]{8,}|glpat-[A-Za-z0-9_-]{12,}|npm_[A-Za-z0-9]{20,}|xox[baprs]-[A-Za-z0-9-]{12,}|(?:AKIA|ASIA)[A-Z0-9]{16}|AIza[A-Za-z0-9_-]{20,})\b/g, "[REDACTED]")
|
|
25
|
+
.replace(/\beyJ[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+\b/g, "[REDACTED]")
|
|
26
|
+
.replace(/\b([a-z][a-z0-9+.-]*:\/\/)[^\s/:@]+:[^\s/@]+@/gi, "$1[REDACTED]@");
|
|
25
27
|
}
|
|
26
28
|
export function sanitizeRepositoryUrl(value) {
|
|
27
29
|
if (typeof value !== "string" || value.length === 0)
|