projscan 4.6.0 → 4.7.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/README.md +24 -11
- package/dist/cli/_shared.js +12 -44
- package/dist/cli/_shared.js.map +1 -1
- package/dist/cli/changedOnly.d.ts +16 -0
- package/dist/cli/changedOnly.js +28 -0
- package/dist/cli/changedOnly.js.map +1 -0
- package/dist/cli/formatOptions.d.ts +4 -0
- package/dist/cli/formatOptions.js +30 -0
- package/dist/cli/formatOptions.js.map +1 -0
- package/dist/core/agentBrief.js +6 -1
- package/dist/core/agentBrief.js.map +1 -1
- package/dist/core/astBodySignals.js +2 -3
- package/dist/core/astBodySignals.js.map +1 -1
- package/dist/core/astMembers.d.ts +1 -0
- package/dist/core/astMembers.js +38 -9
- package/dist/core/astMembers.js.map +1 -1
- package/dist/core/bugHunt.js +2 -142
- package/dist/core/bugHunt.js.map +1 -1
- package/dist/core/bugHuntHotspotFindings.d.ts +2 -0
- package/dist/core/bugHuntHotspotFindings.js +68 -0
- package/dist/core/bugHuntHotspotFindings.js.map +1 -0
- package/dist/core/bugHuntPreflightFindings.d.ts +3 -0
- package/dist/core/bugHuntPreflightFindings.js +115 -0
- package/dist/core/bugHuntPreflightFindings.js.map +1 -0
- package/dist/core/codeGraph.d.ts +1 -8
- package/dist/core/codeGraph.js +4 -30
- package/dist/core/codeGraph.js.map +1 -1
- package/dist/core/codeGraphFileSelection.d.ts +7 -0
- package/dist/core/codeGraphFileSelection.js +19 -0
- package/dist/core/codeGraphFileSelection.js.map +1 -0
- package/dist/core/codeGraphQueries.d.ts +9 -0
- package/dist/core/codeGraphQueries.js +25 -0
- package/dist/core/codeGraphQueries.js.map +1 -0
- package/dist/core/dataflow.js +3 -338
- package/dist/core/dataflow.js.map +1 -1
- package/dist/core/dataflowDatabaseSinks.d.ts +8 -0
- package/dist/core/dataflowDatabaseSinks.js +78 -0
- package/dist/core/dataflowDatabaseSinks.js.map +1 -0
- package/dist/core/dataflowRiskAssembly.d.ts +11 -0
- package/dist/core/dataflowRiskAssembly.js +117 -0
- package/dist/core/dataflowRiskAssembly.js.map +1 -0
- package/dist/core/dataflowTraversal.d.ts +25 -0
- package/dist/core/dataflowTraversal.js +200 -0
- package/dist/core/dataflowTraversal.js.map +1 -0
- package/dist/core/fileInspectionReport.d.ts +13 -0
- package/dist/core/fileInspectionReport.js +49 -0
- package/dist/core/fileInspectionReport.js.map +1 -0
- package/dist/core/fileInspector.d.ts +3 -11
- package/dist/core/fileInspector.js +2 -46
- package/dist/core/fileInspector.js.map +1 -1
- package/dist/core/fixSuggest.d.ts +1 -9
- package/dist/core/fixSuggest.js +2 -58
- package/dist/core/fixSuggest.js.map +1 -1
- package/dist/core/fixSuggestDependencyNames.d.ts +1 -0
- package/dist/core/fixSuggestDependencyNames.js +9 -0
- package/dist/core/fixSuggestDependencyNames.js.map +1 -0
- package/dist/core/fixSuggestPreview.d.ts +10 -0
- package/dist/core/fixSuggestPreview.js +87 -0
- package/dist/core/fixSuggestPreview.js.map +1 -0
- package/dist/core/frameworkHonoSources.js +7 -0
- package/dist/core/frameworkHonoSources.js.map +1 -1
- package/dist/core/frameworkNextRouteSources.d.ts +6 -1
- package/dist/core/frameworkNextRouteSources.js +31 -1
- package/dist/core/frameworkNextRouteSources.js.map +1 -1
- package/dist/core/frameworkRemixSources.d.ts +2 -0
- package/dist/core/frameworkRemixSources.js +63 -0
- package/dist/core/frameworkRemixSources.js.map +1 -0
- package/dist/core/frameworkSources.d.ts +15 -3
- package/dist/core/frameworkSources.js +41 -10
- package/dist/core/frameworkSources.js.map +1 -1
- package/dist/core/intentRouter.d.ts +4 -14
- package/dist/core/intentRouter.js +4 -29
- package/dist/core/intentRouter.js.map +1 -1
- package/dist/core/intentRouterCatalog.js +17 -0
- package/dist/core/intentRouterCatalog.js.map +1 -1
- package/dist/core/intentRouterKeywordWeights.js +13 -0
- package/dist/core/intentRouterKeywordWeights.js.map +1 -1
- package/dist/core/intentRouterReleaseSignals.js +119 -39
- package/dist/core/intentRouterReleaseSignals.js.map +1 -1
- package/dist/core/intentRouterResult.d.ts +16 -0
- package/dist/core/intentRouterResult.js +34 -0
- package/dist/core/intentRouterResult.js.map +1 -0
- package/dist/core/intentRouterWorkSignals.js +18 -0
- package/dist/core/intentRouterWorkSignals.js.map +1 -1
- package/dist/core/languages/pythonLockfiles.d.ts +4 -0
- package/dist/core/languages/pythonLockfiles.js +6 -2
- package/dist/core/languages/pythonLockfiles.js.map +1 -1
- package/dist/core/languages/pythonManifests.js +5 -5
- package/dist/core/languages/pythonManifests.js.map +1 -1
- package/dist/core/languages/pythonProjectEvidence.js +1 -1
- package/dist/core/languages/pythonProjectEvidence.js.map +1 -1
- package/dist/core/languages/pythonRequirements.js +144 -18
- package/dist/core/languages/pythonRequirements.js.map +1 -1
- package/dist/core/pluginManifestValidation.d.ts +41 -0
- package/dist/core/pluginManifestValidation.js +179 -0
- package/dist/core/pluginManifestValidation.js.map +1 -0
- package/dist/core/plugins.d.ts +3 -41
- package/dist/core/plugins.js +2 -129
- package/dist/core/plugins.js.map +1 -1
- package/dist/core/regressionPlan.d.ts +2 -1
- package/dist/core/regressionPlan.js +7 -1
- package/dist/core/regressionPlan.js.map +1 -1
- package/dist/core/releaseEvidence.js +6 -120
- package/dist/core/releaseEvidence.js.map +1 -1
- package/dist/core/releaseEvidenceArtifacts.d.ts +3 -0
- package/dist/core/releaseEvidenceArtifacts.js +65 -0
- package/dist/core/releaseEvidenceArtifacts.js.map +1 -0
- package/dist/core/releaseEvidenceVerdict.d.ts +6 -0
- package/dist/core/releaseEvidenceVerdict.js +54 -0
- package/dist/core/releaseEvidenceVerdict.js.map +1 -0
- package/dist/core/reportPathRedaction.d.ts +4 -0
- package/dist/core/reportPathRedaction.js +64 -0
- package/dist/core/reportPathRedaction.js.map +1 -0
- package/dist/core/reportScope.js +2 -163
- package/dist/core/reportScope.js.map +1 -1
- package/dist/core/reportScopeFiltering.d.ts +9 -0
- package/dist/core/reportScopeFiltering.js +102 -0
- package/dist/core/reportScopeFiltering.js.map +1 -0
- package/dist/core/searchIndex.d.ts +2 -14
- package/dist/core/searchIndex.js +4 -227
- package/dist/core/searchIndex.js.map +1 -1
- package/dist/core/searchIndexFiles.d.ts +1 -0
- package/dist/core/searchIndexFiles.js +26 -0
- package/dist/core/searchIndexFiles.js.map +1 -0
- package/dist/core/searchIndexText.d.ts +15 -0
- package/dist/core/searchIndexText.js +204 -0
- package/dist/core/searchIndexText.js.map +1 -0
- package/dist/core/start.js +5 -46
- package/dist/core/start.js.map +1 -1
- package/dist/core/startEvidence.d.ts +1 -1
- package/dist/core/startEvidence.js +16 -1
- package/dist/core/startEvidence.js.map +1 -1
- package/dist/core/startInputs.d.ts +1 -0
- package/dist/core/startInputs.js +4 -1
- package/dist/core/startInputs.js.map +1 -1
- package/dist/core/startMissionPolicy.js +10 -0
- package/dist/core/startMissionPolicy.js.map +1 -1
- package/dist/core/startReportBuilder.d.ts +1 -0
- package/dist/core/startReportBuilder.js +1 -0
- package/dist/core/startReportBuilder.js.map +1 -1
- package/dist/core/startReportContext.d.ts +23 -0
- package/dist/core/startReportContext.js +51 -0
- package/dist/core/startReportContext.js.map +1 -0
- package/dist/core/startRoadmapPreview.d.ts +2 -0
- package/dist/core/startRoadmapPreview.js +31 -0
- package/dist/core/startRoadmapPreview.js.map +1 -0
- package/dist/core/taint.d.ts +2 -67
- package/dist/core/taint.js +41 -164
- package/dist/core/taint.js.map +1 -1
- package/dist/core/taintIndex.d.ts +20 -0
- package/dist/core/taintIndex.js +81 -0
- package/dist/core/taintIndex.js.map +1 -0
- package/dist/core/taintTraversal.d.ts +8 -0
- package/dist/core/taintTraversal.js +113 -0
- package/dist/core/taintTraversal.js.map +1 -0
- package/dist/core/taintTypes.d.ts +67 -0
- package/dist/core/taintTypes.js +2 -0
- package/dist/core/taintTypes.js.map +1 -0
- package/dist/core/telemetry.js +36 -30
- package/dist/core/telemetry.js.map +1 -1
- package/dist/core/upgradePreviewPython.js +1 -1
- package/dist/core/upgradePreviewPython.js.map +1 -1
- package/dist/mcp/tools.js +11 -12
- package/dist/mcp/tools.js.map +1 -1
- package/dist/projscan-sbom.cdx.json +6 -6
- package/dist/reporters/consoleFixReporter.d.ts +3 -0
- package/dist/reporters/consoleFixReporter.js +41 -0
- package/dist/reporters/consoleFixReporter.js.map +1 -0
- package/dist/reporters/consoleReporter.d.ts +1 -3
- package/dist/reporters/consoleReporter.js +1 -42
- package/dist/reporters/consoleReporter.js.map +1 -1
- package/dist/tool-manifest.json +2 -2
- package/dist/types/start.d.ts +14 -0
- package/docs/GUIDE.md +1 -1
- package/docs/ROADMAP.md +16 -5
- package/package.json +1 -1
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export type PathRedactor = (filePath: string) => string;
|
|
2
|
+
export declare function normalizeReportPath(value: string): string | null;
|
|
3
|
+
export declare function createPathRedactor(): PathRedactor;
|
|
4
|
+
export declare function redactText(text: string, replacements: ReadonlyArray<readonly [string, string]>, redactor: PathRedactor | null): string;
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
export function normalizeReportPath(value) {
|
|
2
|
+
let normalized = value.trim().replace(/\\/g, '/');
|
|
3
|
+
normalized = normalized.replace(/\/+/g, '/');
|
|
4
|
+
normalized = normalized.replace(/^\.\//, '');
|
|
5
|
+
normalized = normalized.replace(/\/$/, '');
|
|
6
|
+
if (!normalized || normalized === '.')
|
|
7
|
+
return null;
|
|
8
|
+
return normalized;
|
|
9
|
+
}
|
|
10
|
+
export function createPathRedactor() {
|
|
11
|
+
const seen = new Map();
|
|
12
|
+
return (filePath) => {
|
|
13
|
+
const normalized = normalizeReportPath(filePath) ?? filePath;
|
|
14
|
+
const existing = seen.get(normalized);
|
|
15
|
+
if (existing)
|
|
16
|
+
return existing;
|
|
17
|
+
const next = `redacted-path-${seen.size + 1}`;
|
|
18
|
+
seen.set(normalized, next);
|
|
19
|
+
return next;
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
export function redactText(text, replacements, redactor) {
|
|
23
|
+
let out = text;
|
|
24
|
+
const ordered = [...replacements].sort((a, b) => b[0].length - a[0].length);
|
|
25
|
+
for (const [filePath, label] of ordered) {
|
|
26
|
+
out = out.replace(pathReferenceRegExp(filePath), label);
|
|
27
|
+
}
|
|
28
|
+
if (redactor)
|
|
29
|
+
out = redactUnmappedPathTokens(out, redactor);
|
|
30
|
+
return out;
|
|
31
|
+
}
|
|
32
|
+
const TEXT_PATH_TOKEN_PATTERN = /(?:[A-Za-z]:[\\/]|\/|\.{1,2}[\\/])?(?:[A-Za-z0-9._@-]+[\\/])+[A-Za-z0-9._@-]+\.(?:ts|tsx|js|jsx|mjs|cjs|mts|cts|py|go|java|rb|rs|php|cs|json|ya?ml|toml|md)(?=$|[\s'"()[\]{}<>.,;:!?#])/gi;
|
|
33
|
+
function redactUnmappedPathTokens(text, redactor) {
|
|
34
|
+
return text.replace(TEXT_PATH_TOKEN_PATTERN, (match, ...args) => {
|
|
35
|
+
const offset = args[args.length - 2];
|
|
36
|
+
if (isHttpUrlPathToken(text, offset))
|
|
37
|
+
return match;
|
|
38
|
+
return redactor(match);
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
function isHttpUrlPathToken(text, offset) {
|
|
42
|
+
const tokenStart = previousTokenStart(text, offset);
|
|
43
|
+
const prefix = text.slice(tokenStart, Math.min(text.length, offset + 2)).toLowerCase();
|
|
44
|
+
return prefix.startsWith('http://') || prefix.startsWith('https://');
|
|
45
|
+
}
|
|
46
|
+
function previousTokenStart(text, offset) {
|
|
47
|
+
let index = offset;
|
|
48
|
+
while (index > 0 && !isPathTokenBoundary(text[index - 1]))
|
|
49
|
+
index -= 1;
|
|
50
|
+
return index;
|
|
51
|
+
}
|
|
52
|
+
function isPathTokenBoundary(char) {
|
|
53
|
+
return char === undefined || /[\s'"()[\]{}<>]/.test(char);
|
|
54
|
+
}
|
|
55
|
+
function pathReferenceRegExp(filePath) {
|
|
56
|
+
const normalized = filePath.replace(/\\/g, '/');
|
|
57
|
+
const pathPattern = normalized.split('/').map(escapeRegExp).join(String.raw `[\\/]`);
|
|
58
|
+
const tokenEnd = String.raw `(?=$|[\s'"()[\]{}<>.,;:!?#])`;
|
|
59
|
+
return new RegExp(String.raw `(?:\S+[\\/])*` + pathPattern + tokenEnd, 'g');
|
|
60
|
+
}
|
|
61
|
+
function escapeRegExp(value) {
|
|
62
|
+
return value.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
63
|
+
}
|
|
64
|
+
//# sourceMappingURL=reportPathRedaction.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"reportPathRedaction.js","sourceRoot":"","sources":["../../src/core/reportPathRedaction.ts"],"names":[],"mappings":"AAEA,MAAM,UAAU,mBAAmB,CAAC,KAAa;IAC/C,IAAI,UAAU,GAAG,KAAK,CAAC,IAAI,EAAE,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;IAClD,UAAU,GAAG,UAAU,CAAC,OAAO,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAC7C,UAAU,GAAG,UAAU,CAAC,OAAO,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC;IAC7C,UAAU,GAAG,UAAU,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;IAC3C,IAAI,CAAC,UAAU,IAAI,UAAU,KAAK,GAAG;QAAE,OAAO,IAAI,CAAC;IACnD,OAAO,UAAU,CAAC;AACpB,CAAC;AAED,MAAM,UAAU,kBAAkB;IAChC,MAAM,IAAI,GAAG,IAAI,GAAG,EAAkB,CAAC;IACvC,OAAO,CAAC,QAAgB,EAAU,EAAE;QAClC,MAAM,UAAU,GAAG,mBAAmB,CAAC,QAAQ,CAAC,IAAI,QAAQ,CAAC;QAC7D,MAAM,QAAQ,GAAG,IAAI,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;QACtC,IAAI,QAAQ;YAAE,OAAO,QAAQ,CAAC;QAC9B,MAAM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,EAAE,MAAM,CAAC,CAAC;AACtD,CAAC"}
|
package/dist/core/reportScope.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { applyReportControlsToDependencies, applyReportControlsToIssuesWithRedactor, buildDirectoryTree, countDirectories, filterFilesByScope, normalizeScopes, redactFileEntry, } from './reportScopeFiltering.js';
|
|
2
|
+
import { createPathRedactor, normalizeReportPath, } from './reportPathRedaction.js';
|
|
1
3
|
export function parseReportScopes(input) {
|
|
2
4
|
if (typeof input !== 'string')
|
|
3
5
|
return [];
|
|
@@ -68,167 +70,4 @@ export function applyReportControlsToAnalysis(report, options = {}) {
|
|
|
68
70
|
issues,
|
|
69
71
|
};
|
|
70
72
|
}
|
|
71
|
-
function applyReportControlsToDependencies(dependencies, scopes, redactor) {
|
|
72
|
-
if (!dependencies?.byWorkspace)
|
|
73
|
-
return dependencies;
|
|
74
|
-
return {
|
|
75
|
-
...dependencies,
|
|
76
|
-
byWorkspace: dependencies.byWorkspace
|
|
77
|
-
.filter((workspace) => dependencyWorkspaceInScope(workspace.relativePath, scopes))
|
|
78
|
-
.map((workspace) => ({
|
|
79
|
-
...workspace,
|
|
80
|
-
relativePath: redactor && workspace.relativePath ? redactor(workspace.relativePath) : workspace.relativePath,
|
|
81
|
-
})),
|
|
82
|
-
};
|
|
83
|
-
}
|
|
84
|
-
function dependencyWorkspaceInScope(relativePath, scopes) {
|
|
85
|
-
if (scopes.length === 0)
|
|
86
|
-
return true;
|
|
87
|
-
return isInScope(relativePath, scopes);
|
|
88
|
-
}
|
|
89
|
-
function applyReportControlsToIssuesWithRedactor(issues, scopes, redactor) {
|
|
90
|
-
const out = [];
|
|
91
|
-
for (const issue of issues) {
|
|
92
|
-
const scopedLocations = filterLocationsByScope(issue.locations, scopes);
|
|
93
|
-
if (scopes.length > 0 && scopedLocations.length === 0)
|
|
94
|
-
continue;
|
|
95
|
-
out.push(redactIssue(issue, scopedLocations, redactor));
|
|
96
|
-
}
|
|
97
|
-
return out;
|
|
98
|
-
}
|
|
99
|
-
function normalizeScopes(scopes) {
|
|
100
|
-
return [...new Set((scopes ?? []).map(normalizeReportPath).filter(Boolean))];
|
|
101
|
-
}
|
|
102
|
-
function normalizeReportPath(value) {
|
|
103
|
-
let normalized = value.trim().replace(/\\/g, '/');
|
|
104
|
-
normalized = normalized.replace(/\/+/g, '/');
|
|
105
|
-
normalized = normalized.replace(/^\.\//, '');
|
|
106
|
-
normalized = normalized.replace(/\/$/, '');
|
|
107
|
-
if (!normalized || normalized === '.')
|
|
108
|
-
return null;
|
|
109
|
-
return normalized;
|
|
110
|
-
}
|
|
111
|
-
function isInScope(filePath, scopes) {
|
|
112
|
-
if (scopes.length === 0)
|
|
113
|
-
return true;
|
|
114
|
-
const normalized = normalizeReportPath(filePath);
|
|
115
|
-
if (!normalized)
|
|
116
|
-
return false;
|
|
117
|
-
return scopes.some((scope) => normalized === scope || normalized.startsWith(`${scope}/`));
|
|
118
|
-
}
|
|
119
|
-
function filterLocationsByScope(locations, scopes) {
|
|
120
|
-
if (!locations || locations.length === 0)
|
|
121
|
-
return [];
|
|
122
|
-
return locations.filter((loc) => loc.file && isInScope(loc.file, scopes));
|
|
123
|
-
}
|
|
124
|
-
function filterFilesByScope(files, scopes) {
|
|
125
|
-
if (scopes.length === 0)
|
|
126
|
-
return [...files];
|
|
127
|
-
return files.filter((file) => isInScope(file.relativePath, scopes));
|
|
128
|
-
}
|
|
129
|
-
function createPathRedactor() {
|
|
130
|
-
const seen = new Map();
|
|
131
|
-
return (filePath) => {
|
|
132
|
-
const normalized = normalizeReportPath(filePath) ?? filePath;
|
|
133
|
-
const existing = seen.get(normalized);
|
|
134
|
-
if (existing)
|
|
135
|
-
return existing;
|
|
136
|
-
const next = `redacted-path-${seen.size + 1}`;
|
|
137
|
-
seen.set(normalized, next);
|
|
138
|
-
return next;
|
|
139
|
-
};
|
|
140
|
-
}
|
|
141
|
-
function redactLocations(locations, redactor) {
|
|
142
|
-
if (!redactor)
|
|
143
|
-
return locations.map((loc) => ({ ...loc }));
|
|
144
|
-
return locations.map((loc) => ({ ...loc, file: redactor(loc.file) }));
|
|
145
|
-
}
|
|
146
|
-
function redactIssue(issue, scopedLocations, redactor) {
|
|
147
|
-
const redactedLocations = redactLocations(scopedLocations, redactor);
|
|
148
|
-
const redactedIssue = {
|
|
149
|
-
...issue,
|
|
150
|
-
...(scopedLocations.length > 0 || issue.locations ? { locations: redactedLocations } : {}),
|
|
151
|
-
};
|
|
152
|
-
if (!redactor)
|
|
153
|
-
return redactedIssue;
|
|
154
|
-
const textLocations = issue.locations ?? scopedLocations;
|
|
155
|
-
const replacements = textLocations
|
|
156
|
-
.filter((loc) => loc.file)
|
|
157
|
-
.map((loc) => [loc.file, redactor(loc.file)]);
|
|
158
|
-
redactedIssue.title = redactText(redactedIssue.title, replacements, redactor);
|
|
159
|
-
redactedIssue.description = redactText(redactedIssue.description, replacements, redactor);
|
|
160
|
-
if (redactedIssue.suggestedAction) {
|
|
161
|
-
redactedIssue.suggestedAction = {
|
|
162
|
-
...redactedIssue.suggestedAction,
|
|
163
|
-
summary: redactText(redactedIssue.suggestedAction.summary, replacements, redactor),
|
|
164
|
-
};
|
|
165
|
-
}
|
|
166
|
-
return redactedIssue;
|
|
167
|
-
}
|
|
168
|
-
function redactText(text, replacements, redactor) {
|
|
169
|
-
let out = text;
|
|
170
|
-
const ordered = [...replacements].sort((a, b) => b[0].length - a[0].length);
|
|
171
|
-
for (const [filePath, label] of ordered) {
|
|
172
|
-
out = out.replace(pathReferenceRegExp(filePath), label);
|
|
173
|
-
}
|
|
174
|
-
if (redactor)
|
|
175
|
-
out = redactUnmappedPathTokens(out, redactor);
|
|
176
|
-
return out;
|
|
177
|
-
}
|
|
178
|
-
const TEXT_PATH_TOKEN_PATTERN = /(?:[A-Za-z]:[\\/]|\/|\.{1,2}[\\/])?(?:[A-Za-z0-9._@-]+[\\/])+[A-Za-z0-9._@-]+\.(?:ts|tsx|js|jsx|mjs|cjs|mts|cts|py|go|java|rb|rs|php|cs|json|ya?ml|toml|md)(?=$|[\s'"()[\]{}<>.,;:!?#])/gi;
|
|
179
|
-
function redactUnmappedPathTokens(text, redactor) {
|
|
180
|
-
return text.replace(TEXT_PATH_TOKEN_PATTERN, (match, ...args) => {
|
|
181
|
-
const offset = args[args.length - 2];
|
|
182
|
-
if (isHttpUrlPathToken(text, offset))
|
|
183
|
-
return match;
|
|
184
|
-
return redactor(match);
|
|
185
|
-
});
|
|
186
|
-
}
|
|
187
|
-
function isHttpUrlPathToken(text, offset) {
|
|
188
|
-
const tokenStart = previousTokenStart(text, offset);
|
|
189
|
-
const prefix = text.slice(tokenStart, Math.min(text.length, offset + 2)).toLowerCase();
|
|
190
|
-
return prefix.startsWith('http://') || prefix.startsWith('https://');
|
|
191
|
-
}
|
|
192
|
-
function previousTokenStart(text, offset) {
|
|
193
|
-
let index = offset;
|
|
194
|
-
while (index > 0 && !isPathTokenBoundary(text[index - 1]))
|
|
195
|
-
index -= 1;
|
|
196
|
-
return index;
|
|
197
|
-
}
|
|
198
|
-
function isPathTokenBoundary(char) {
|
|
199
|
-
return char === undefined || /[\s'"()[\]{}<>]/.test(char);
|
|
200
|
-
}
|
|
201
|
-
function pathReferenceRegExp(filePath) {
|
|
202
|
-
const normalized = filePath.replace(/\\/g, '/');
|
|
203
|
-
const pathPattern = normalized.split('/').map(escapeRegExp).join(String.raw `[\\/]`);
|
|
204
|
-
const tokenEnd = String.raw `(?=$|[\s'"()[\]{}<>.,;:!?#])`;
|
|
205
|
-
return new RegExp(String.raw `(?:\S+[\\/])*` + pathPattern + tokenEnd, 'g');
|
|
206
|
-
}
|
|
207
|
-
function escapeRegExp(value) {
|
|
208
|
-
return value.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
209
|
-
}
|
|
210
|
-
function redactFileEntry(file, redactor) {
|
|
211
|
-
if (!redactor)
|
|
212
|
-
return { ...file };
|
|
213
|
-
const relativePath = redactor(file.relativePath);
|
|
214
|
-
return {
|
|
215
|
-
...file,
|
|
216
|
-
relativePath,
|
|
217
|
-
absolutePath: relativePath,
|
|
218
|
-
directory: '.',
|
|
219
|
-
};
|
|
220
|
-
}
|
|
221
|
-
function countDirectories(files) {
|
|
222
|
-
const dirs = new Set(files.map((file) => file.directory || '.'));
|
|
223
|
-
return dirs.size;
|
|
224
|
-
}
|
|
225
|
-
function buildDirectoryTree(name, files) {
|
|
226
|
-
return {
|
|
227
|
-
name,
|
|
228
|
-
path: '.',
|
|
229
|
-
fileCount: files.length,
|
|
230
|
-
totalFileCount: files.length,
|
|
231
|
-
children: [],
|
|
232
|
-
};
|
|
233
|
-
}
|
|
234
73
|
//# sourceMappingURL=reportScope.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reportScope.js","sourceRoot":"","sources":["../../src/core/reportScope.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"reportScope.js","sourceRoot":"","sources":["../../src/core/reportScope.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,iCAAiC,EACjC,uCAAuC,EACvC,kBAAkB,EAClB,gBAAgB,EAChB,kBAAkB,EAClB,eAAe,EACf,eAAe,GAChB,MAAM,2BAA2B,CAAC;AACnC,OAAO,EACL,kBAAkB,EAClB,mBAAmB,GACpB,MAAM,0BAA0B,CAAC;AAqBlC,MAAM,UAAU,iBAAiB,CAAC,KAAc;IAC9C,IAAI,OAAO,KAAK,KAAK,QAAQ;QAAE,OAAO,EAAE,CAAC;IACzC,OAAO,KAAK;SACT,KAAK,CAAC,GAAG,CAAC;SACV,GAAG,CAAC,mBAAmB,CAAC;SACxB,MAAM,CAAC,CAAC,KAAK,EAAmB,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC;AACxD,CAAC;AAED,MAAM,UAAU,qBAAqB,CAAC,KAAiC;IACrE,IAAI,QAAQ,GAAyB,EAAE,CAAC;IACxC,IAAI,OAAO,KAAK,CAAC,YAAY,KAAK,QAAQ,EAAE,CAAC;QAC3C,MAAM,U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gBAC3B,CAAC,CAAC,kBAAkB,CAAC,QAAQ,CAAC,CAAC,CAAC,iBAAiB,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,aAAa,CAAC,IAAI,EAAE,KAAK,CAAC;gBAC1F,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,aAAa;SAChC;QACD,YAAY;QACZ,MAAM;KACP,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { AnalysisReport, DirectoryNode, FileEntry, Issue } from '../types.js';
|
|
2
|
+
import { type PathRedactor } from './reportPathRedaction.js';
|
|
3
|
+
export declare function applyReportControlsToDependencies(dependencies: AnalysisReport['dependencies'], scopes: string[], redactor: PathRedactor | null): AnalysisReport['dependencies'];
|
|
4
|
+
export declare function applyReportControlsToIssuesWithRedactor(issues: Issue[], scopes: string[], redactor: PathRedactor | null): Issue[];
|
|
5
|
+
export declare function normalizeScopes(scopes: string[] | undefined): string[];
|
|
6
|
+
export declare function filterFilesByScope(files: FileEntry[], scopes: string[]): FileEntry[];
|
|
7
|
+
export declare function redactFileEntry(file: FileEntry, redactor: PathRedactor | null): FileEntry;
|
|
8
|
+
export declare function countDirectories(files: FileEntry[]): number;
|
|
9
|
+
export declare function buildDirectoryTree(name: string, files: FileEntry[]): DirectoryNode;
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import { normalizeReportPath, redactText } from './reportPathRedaction.js';
|
|
2
|
+
export function applyReportControlsToDependencies(dependencies, scopes, redactor) {
|
|
3
|
+
if (!dependencies?.byWorkspace)
|
|
4
|
+
return dependencies;
|
|
5
|
+
return {
|
|
6
|
+
...dependencies,
|
|
7
|
+
byWorkspace: dependencies.byWorkspace
|
|
8
|
+
.filter((workspace) => dependencyWorkspaceInScope(workspace.relativePath, scopes))
|
|
9
|
+
.map((workspace) => ({
|
|
10
|
+
...workspace,
|
|
11
|
+
relativePath: redactor && workspace.relativePath ? redactor(workspace.relativePath) : workspace.relativePath,
|
|
12
|
+
})),
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
export function applyReportControlsToIssuesWithRedactor(issues, scopes, redactor) {
|
|
16
|
+
const out = [];
|
|
17
|
+
for (const issue of issues) {
|
|
18
|
+
const scopedLocations = filterLocationsByScope(issue.locations, scopes);
|
|
19
|
+
if (scopes.length > 0 && scopedLocations.length === 0)
|
|
20
|
+
continue;
|
|
21
|
+
out.push(redactIssue(issue, scopedLocations, redactor));
|
|
22
|
+
}
|
|
23
|
+
return out;
|
|
24
|
+
}
|
|
25
|
+
export function normalizeScopes(scopes) {
|
|
26
|
+
return [...new Set((scopes ?? []).map(normalizeReportPath).filter(Boolean))];
|
|
27
|
+
}
|
|
28
|
+
export function filterFilesByScope(files, scopes) {
|
|
29
|
+
if (scopes.length === 0)
|
|
30
|
+
return [...files];
|
|
31
|
+
return files.filter((file) => isInScope(file.relativePath, scopes));
|
|
32
|
+
}
|
|
33
|
+
export function redactFileEntry(file, redactor) {
|
|
34
|
+
if (!redactor)
|
|
35
|
+
return { ...file };
|
|
36
|
+
const relativePath = redactor(file.relativePath);
|
|
37
|
+
return {
|
|
38
|
+
...file,
|
|
39
|
+
relativePath,
|
|
40
|
+
absolutePath: relativePath,
|
|
41
|
+
directory: '.',
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
export function countDirectories(files) {
|
|
45
|
+
const dirs = new Set(files.map((file) => file.directory || '.'));
|
|
46
|
+
return dirs.size;
|
|
47
|
+
}
|
|
48
|
+
export function buildDirectoryTree(name, files) {
|
|
49
|
+
return {
|
|
50
|
+
name,
|
|
51
|
+
path: '.',
|
|
52
|
+
fileCount: files.length,
|
|
53
|
+
totalFileCount: files.length,
|
|
54
|
+
children: [],
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
function dependencyWorkspaceInScope(relativePath, scopes) {
|
|
58
|
+
if (scopes.length === 0)
|
|
59
|
+
return true;
|
|
60
|
+
return isInScope(relativePath, scopes);
|
|
61
|
+
}
|
|
62
|
+
function isInScope(filePath, scopes) {
|
|
63
|
+
if (scopes.length === 0)
|
|
64
|
+
return true;
|
|
65
|
+
const normalized = normalizeReportPath(filePath);
|
|
66
|
+
if (!normalized)
|
|
67
|
+
return false;
|
|
68
|
+
return scopes.some((scope) => normalized === scope || normalized.startsWith(`${scope}/`));
|
|
69
|
+
}
|
|
70
|
+
function filterLocationsByScope(locations, scopes) {
|
|
71
|
+
if (!locations || locations.length === 0)
|
|
72
|
+
return [];
|
|
73
|
+
return locations.filter((loc) => loc.file && isInScope(loc.file, scopes));
|
|
74
|
+
}
|
|
75
|
+
function redactLocations(locations, redactor) {
|
|
76
|
+
if (!redactor)
|
|
77
|
+
return locations.map((loc) => ({ ...loc }));
|
|
78
|
+
return locations.map((loc) => ({ ...loc, file: redactor(loc.file) }));
|
|
79
|
+
}
|
|
80
|
+
function redactIssue(issue, scopedLocations, redactor) {
|
|
81
|
+
const redactedLocations = redactLocations(scopedLocations, redactor);
|
|
82
|
+
const redactedIssue = {
|
|
83
|
+
...issue,
|
|
84
|
+
...(scopedLocations.length > 0 || issue.locations ? { locations: redactedLocations } : {}),
|
|
85
|
+
};
|
|
86
|
+
if (!redactor)
|
|
87
|
+
return redactedIssue;
|
|
88
|
+
const textLocations = issue.locations ?? scopedLocations;
|
|
89
|
+
const replacements = textLocations
|
|
90
|
+
.filter((loc) => loc.file)
|
|
91
|
+
.map((loc) => [loc.file, redactor(loc.file)]);
|
|
92
|
+
redactedIssue.title = redactText(redactedIssue.title, replacements, redactor);
|
|
93
|
+
redactedIssue.description = redactText(redactedIssue.description, replacements, redactor);
|
|
94
|
+
if (redactedIssue.suggestedAction) {
|
|
95
|
+
redactedIssue.suggestedAction = {
|
|
96
|
+
...redactedIssue.suggestedAction,
|
|
97
|
+
summary: redactText(redactedIssue.suggestedAction.summary, replacements, redactor),
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
return redactedIssue;
|
|
101
|
+
}
|
|
102
|
+
//# sourceMappingURL=reportScopeFi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+
export { expandQuery, tokenize };
|
|
3
5
|
export interface IndexedFile {
|
|
4
6
|
relativePath: string;
|
|
5
7
|
content: string[];
|
|
@@ -47,17 +49,3 @@ export declare function search(index: SearchIndex, query: string, options?: Sear
|
|
|
47
49
|
* the caller only wants paths (e.g., an agent filtering before fetching).
|
|
48
50
|
*/
|
|
49
51
|
export declare function attachExcerpts(rootPath: string, hits: SearchHit[], queryTokens: string[]): Promise<SearchHit[]>;
|
|
50
|
-
/**
|
|
51
|
-
* Tokenize a string for indexing/querying:
|
|
52
|
-
* - lowercase
|
|
53
|
-
* - split on non-identifier chars
|
|
54
|
-
* - split camelCase and snake_case
|
|
55
|
-
* - drop tokens shorter than 2 chars, stopwords, TS keywords
|
|
56
|
-
* - apply basic stem (drop trailing s / ing / ed)
|
|
57
|
-
*/
|
|
58
|
-
export declare function tokenize(input: string): string[];
|
|
59
|
-
/**
|
|
60
|
-
* Expand a user query into a set of candidate tokens. Same rules as tokenize
|
|
61
|
-
* plus: if the raw query has no hits, try progressively looser tokenization.
|
|
62
|
-
*/
|
|
63
|
-
export declare function expandQuery(query: string): string[];
|