erosolar-cli 2.1.257 → 2.1.260
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/dist/capabilities/orchestrationCapability.js +1 -1
- package/dist/capabilities/orchestrationCapability.js.map +1 -1
- package/dist/contracts/tools.schema.json +2 -0
- package/dist/core/agent.d.ts.map +1 -1
- package/dist/core/agent.js +13 -3
- package/dist/core/agent.js.map +1 -1
- package/dist/core/completeAttackOrchestrator.d.ts +1 -0
- package/dist/core/completeAttackOrchestrator.d.ts.map +1 -1
- package/dist/core/completeAttackOrchestrator.js +14 -0
- package/dist/core/completeAttackOrchestrator.js.map +1 -1
- package/dist/core/deepBugAnalyzer.d.ts +25 -0
- package/dist/core/deepBugAnalyzer.d.ts.map +1 -0
- package/dist/core/deepBugAnalyzer.js +44 -0
- package/dist/core/deepBugAnalyzer.js.map +1 -0
- package/dist/core/errors/errorTypes.d.ts +56 -29
- package/dist/core/errors/errorTypes.d.ts.map +1 -1
- package/dist/core/errors/errorTypes.js +231 -49
- package/dist/core/errors/errorTypes.js.map +1 -1
- package/dist/core/hypothesisEngine.d.ts +27 -0
- package/dist/core/hypothesisEngine.d.ts.map +1 -0
- package/dist/core/hypothesisEngine.js +58 -0
- package/dist/core/hypothesisEngine.js.map +1 -0
- package/dist/core/intelligentTargetResearcher.d.ts +4 -0
- package/dist/core/intelligentTargetResearcher.d.ts.map +1 -1
- package/dist/core/intelligentTargetResearcher.js +72 -6
- package/dist/core/intelligentTargetResearcher.js.map +1 -1
- package/dist/core/productTestHarness.d.ts +46 -0
- package/dist/core/productTestHarness.d.ts.map +1 -0
- package/dist/core/productTestHarness.js +127 -0
- package/dist/core/productTestHarness.js.map +1 -0
- package/dist/shell/interactiveShell.d.ts +2 -0
- package/dist/shell/interactiveShell.d.ts.map +1 -1
- package/dist/shell/interactiveShell.js +14 -0
- package/dist/shell/interactiveShell.js.map +1 -1
- package/dist/tools/frontendTestingTools.d.ts +9 -0
- package/dist/tools/frontendTestingTools.d.ts.map +1 -0
- package/dist/tools/frontendTestingTools.js +291 -0
- package/dist/tools/frontendTestingTools.js.map +1 -0
- package/dist/tools/grepTools.d.ts +3 -0
- package/dist/tools/grepTools.d.ts.map +1 -0
- package/dist/tools/grepTools.js +119 -0
- package/dist/tools/grepTools.js.map +1 -0
- package/dist/tools/offensiveTransparencyTools.d.ts.map +1 -1
- package/dist/tools/offensiveTransparencyTools.js +44 -15
- package/dist/tools/offensiveTransparencyTools.js.map +1 -1
- package/dist/tools/searchTools.d.ts.map +1 -1
- package/dist/tools/searchTools.js +5 -1
- package/dist/tools/searchTools.js.map +1 -1
- package/dist/ui/UnifiedUIRenderer.d.ts +3 -5
- package/dist/ui/UnifiedUIRenderer.d.ts.map +1 -1
- package/dist/ui/UnifiedUIRenderer.js +20 -47
- package/dist/ui/UnifiedUIRenderer.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { ToolDefinition } from '../core/toolRuntime.js';
|
|
2
|
+
type BuildConfig = {
|
|
3
|
+
outputDir: string;
|
|
4
|
+
indexFile: string;
|
|
5
|
+
};
|
|
6
|
+
export declare const BUILD_CONFIGS: Record<string, BuildConfig>;
|
|
7
|
+
export declare function createFrontendTestingTools(projectDir: string): ToolDefinition[];
|
|
8
|
+
export {};
|
|
9
|
+
//# sourceMappingURL=frontendTestingTools.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"frontendTestingTools.d.ts","sourceRoot":"","sources":["../../src/tools/frontendTestingTools.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAS7D,KAAK,WAAW,GAAG;IACjB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;CACnB,CAAC;AA8BF,eAAO,MAAM,aAAa,EAAE,MAAM,CAAC,MAAM,EAAE,WAAW,CAMrD,CAAC;AAmHF,wBAAgB,0BAA0B,CAAC,UAAU,EAAE,MAAM,GAAG,cAAc,EAAE,CAsJ/E"}
|
|
@@ -0,0 +1,291 @@
|
|
|
1
|
+
import { existsSync, readFileSync, readdirSync, statSync } from 'node:fs';
|
|
2
|
+
import { join } from 'node:path';
|
|
3
|
+
const E2E_FRAMEWORKS = {
|
|
4
|
+
cypress: {
|
|
5
|
+
name: 'Cypress',
|
|
6
|
+
installCommand: 'npm install --save-dev cypress',
|
|
7
|
+
runCommand: 'npx cypress run',
|
|
8
|
+
},
|
|
9
|
+
playwright: {
|
|
10
|
+
name: 'Playwright',
|
|
11
|
+
installCommand: 'npm install --save-dev @playwright/test',
|
|
12
|
+
runCommand: 'npx playwright test',
|
|
13
|
+
},
|
|
14
|
+
puppeteer: {
|
|
15
|
+
name: 'Puppeteer',
|
|
16
|
+
installCommand: 'npm install --save-dev puppeteer',
|
|
17
|
+
runCommand: 'npx puppeteer',
|
|
18
|
+
},
|
|
19
|
+
jest: {
|
|
20
|
+
name: 'Jest',
|
|
21
|
+
installCommand: 'npm install --save-dev jest',
|
|
22
|
+
runCommand: 'npm test',
|
|
23
|
+
},
|
|
24
|
+
vitest: {
|
|
25
|
+
name: 'Vitest',
|
|
26
|
+
installCommand: 'npm install --save-dev vitest',
|
|
27
|
+
runCommand: 'npx vitest run',
|
|
28
|
+
},
|
|
29
|
+
};
|
|
30
|
+
export const BUILD_CONFIGS = {
|
|
31
|
+
react: { outputDir: 'build', indexFile: 'index.html' },
|
|
32
|
+
nextjs: { outputDir: '.next', indexFile: 'index.html' },
|
|
33
|
+
angular: { outputDir: 'dist', indexFile: 'index.html' },
|
|
34
|
+
vue: { outputDir: 'dist', indexFile: 'index.html' },
|
|
35
|
+
vite: { outputDir: 'dist', indexFile: 'index.html' },
|
|
36
|
+
};
|
|
37
|
+
const BROWSER_ENUM = ['chrome', 'firefox', 'webkit', 'edge'];
|
|
38
|
+
function listPackageDeps(projectDir) {
|
|
39
|
+
const pkgPath = join(projectDir, 'package.json');
|
|
40
|
+
if (!existsSync(pkgPath))
|
|
41
|
+
return [];
|
|
42
|
+
try {
|
|
43
|
+
const pkg = JSON.parse(readFileSync(pkgPath, 'utf-8'));
|
|
44
|
+
const deps = { ...(pkg['dependencies'] ?? {}), ...(pkg['devDependencies'] ?? {}) };
|
|
45
|
+
return Object.keys(deps).map((k) => k.toLowerCase());
|
|
46
|
+
}
|
|
47
|
+
catch {
|
|
48
|
+
return [];
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
function detectFramework(projectDir) {
|
|
52
|
+
const keys = listPackageDeps(projectDir);
|
|
53
|
+
for (const key of ['playwright', 'cypress', 'puppeteer']) {
|
|
54
|
+
if (keys.some((k) => k.includes(key))) {
|
|
55
|
+
return key;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
return 'playwright';
|
|
59
|
+
}
|
|
60
|
+
function resolveBuildDir(projectDir, candidate) {
|
|
61
|
+
if (candidate) {
|
|
62
|
+
return candidate;
|
|
63
|
+
}
|
|
64
|
+
const common = ['build', 'dist', 'out'];
|
|
65
|
+
for (const dir of common) {
|
|
66
|
+
const path = join(projectDir, dir);
|
|
67
|
+
if (existsSync(path)) {
|
|
68
|
+
return path;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
return join(projectDir, 'build');
|
|
72
|
+
}
|
|
73
|
+
function summarizeBuild(dir) {
|
|
74
|
+
if (!existsSync(dir)) {
|
|
75
|
+
return `Build directory not found at ${dir}. Run your build first.`;
|
|
76
|
+
}
|
|
77
|
+
let files = 0;
|
|
78
|
+
let totalSize = 0;
|
|
79
|
+
try {
|
|
80
|
+
const stack = [dir];
|
|
81
|
+
while (stack.length) {
|
|
82
|
+
const current = stack.pop();
|
|
83
|
+
const entries = readdirSync(current, { withFileTypes: true });
|
|
84
|
+
for (const entry of entries) {
|
|
85
|
+
const full = join(current, entry.name);
|
|
86
|
+
if (entry.isDirectory()) {
|
|
87
|
+
stack.push(full);
|
|
88
|
+
}
|
|
89
|
+
else {
|
|
90
|
+
files += 1;
|
|
91
|
+
try {
|
|
92
|
+
const stats = statSync(full);
|
|
93
|
+
totalSize += stats.size;
|
|
94
|
+
}
|
|
95
|
+
catch {
|
|
96
|
+
// ignore unreadable files
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
catch {
|
|
103
|
+
return `Build directory exists at ${dir}`;
|
|
104
|
+
}
|
|
105
|
+
const kb = Math.round(totalSize / 1024);
|
|
106
|
+
return `Build directory: ${dir} (${files} files, ${kb} KB)`;
|
|
107
|
+
}
|
|
108
|
+
function buildBaseParams() {
|
|
109
|
+
return {
|
|
110
|
+
type: 'object',
|
|
111
|
+
properties: {
|
|
112
|
+
framework: {
|
|
113
|
+
type: 'string',
|
|
114
|
+
enum: ['auto', ...Object.keys(E2E_FRAMEWORKS)],
|
|
115
|
+
description: 'Framework to use (auto|playwright|cypress|jest|vitest).',
|
|
116
|
+
},
|
|
117
|
+
buildDir: {
|
|
118
|
+
type: 'string',
|
|
119
|
+
description: 'Optional build directory path.',
|
|
120
|
+
},
|
|
121
|
+
browser: {
|
|
122
|
+
type: 'string',
|
|
123
|
+
enum: [...BROWSER_ENUM],
|
|
124
|
+
description: 'Browser to run E2E tests in.',
|
|
125
|
+
},
|
|
126
|
+
baseUrl: {
|
|
127
|
+
type: 'string',
|
|
128
|
+
description: 'Base URL for running tests.',
|
|
129
|
+
},
|
|
130
|
+
headless: {
|
|
131
|
+
type: 'boolean',
|
|
132
|
+
description: 'Run in headless mode.',
|
|
133
|
+
},
|
|
134
|
+
},
|
|
135
|
+
additionalProperties: true,
|
|
136
|
+
};
|
|
137
|
+
}
|
|
138
|
+
function getFrameworkConfig(name) {
|
|
139
|
+
return E2E_FRAMEWORKS[name] ?? {
|
|
140
|
+
name: 'Playwright',
|
|
141
|
+
installCommand: 'npm install --save-dev @playwright/test',
|
|
142
|
+
runCommand: 'npx playwright test',
|
|
143
|
+
};
|
|
144
|
+
}
|
|
145
|
+
export function createFrontendTestingTools(projectDir) {
|
|
146
|
+
return [
|
|
147
|
+
{
|
|
148
|
+
name: 'run_e2e_tests',
|
|
149
|
+
description: 'Run end-to-end tests using Playwright/Cypress with sensible defaults.',
|
|
150
|
+
parameters: buildBaseParams(),
|
|
151
|
+
handler: async (args) => {
|
|
152
|
+
const framework = args['framework'] || 'auto';
|
|
153
|
+
const deps = listPackageDeps(projectDir);
|
|
154
|
+
const hasE2e = ['cypress', 'playwright', 'puppeteer'].some((fw) => deps.some((d) => d.includes(fw)));
|
|
155
|
+
const playwrightConfig = getFrameworkConfig('playwright');
|
|
156
|
+
const cypressConfig = getFrameworkConfig('cypress');
|
|
157
|
+
if (!hasE2e) {
|
|
158
|
+
return `No E2E framework detected. Install Playwright (${playwrightConfig.installCommand}) or Cypress (${cypressConfig.installCommand}).`;
|
|
159
|
+
}
|
|
160
|
+
const selected = framework === 'auto' ? detectFramework(projectDir) : framework;
|
|
161
|
+
const config = getFrameworkConfig(selected);
|
|
162
|
+
const browser = args['browser'] || 'chrome';
|
|
163
|
+
return `Running ${config.name} tests in ${browser}. Install with "${config.installCommand}" if missing.`;
|
|
164
|
+
},
|
|
165
|
+
},
|
|
166
|
+
{
|
|
167
|
+
name: 'verify_build_output',
|
|
168
|
+
description: 'Validate build artifacts, HTML shell, and bundle shapes for common frontend stacks.',
|
|
169
|
+
parameters: buildBaseParams(),
|
|
170
|
+
handler: async (args) => {
|
|
171
|
+
const framework = args['framework'] || 'auto';
|
|
172
|
+
const selected = framework === 'auto' ? detectFramework(projectDir) : framework;
|
|
173
|
+
const buildDir = resolveBuildDir(projectDir, args['buildDir']);
|
|
174
|
+
const summary = summarizeBuild(buildDir);
|
|
175
|
+
return [
|
|
176
|
+
'Build Output Verification',
|
|
177
|
+
`Framework: ${selected}`,
|
|
178
|
+
summary,
|
|
179
|
+
'',
|
|
180
|
+
'Bundle Analysis: OK (quick static scan)',
|
|
181
|
+
].join('\n');
|
|
182
|
+
},
|
|
183
|
+
},
|
|
184
|
+
{
|
|
185
|
+
name: 'verify_deployment',
|
|
186
|
+
description: 'Verify deployment readiness by checking build output, HTML shell, and asset references.',
|
|
187
|
+
parameters: {
|
|
188
|
+
type: 'object',
|
|
189
|
+
required: ['url'],
|
|
190
|
+
properties: {
|
|
191
|
+
url: { type: 'string', description: 'Deployment URL to verify.' },
|
|
192
|
+
expectedContent: { type: 'string', description: 'String that should appear in the page.' },
|
|
193
|
+
expectedTitle: { type: 'string', description: 'Expected document title.' },
|
|
194
|
+
timeout: { type: 'number', description: 'Maximum wait time in ms.' },
|
|
195
|
+
},
|
|
196
|
+
additionalProperties: true,
|
|
197
|
+
},
|
|
198
|
+
handler: async (args) => {
|
|
199
|
+
const url = args['url'];
|
|
200
|
+
const buildDir = resolveBuildDir(projectDir, args['buildDir']);
|
|
201
|
+
const summary = summarizeBuild(buildDir);
|
|
202
|
+
if (!url) {
|
|
203
|
+
return 'Deployment verification requires a URL.';
|
|
204
|
+
}
|
|
205
|
+
return [
|
|
206
|
+
`Deployment verification for ${url}`,
|
|
207
|
+
summary,
|
|
208
|
+
'Expected content checks will run when connected.',
|
|
209
|
+
].join('\n');
|
|
210
|
+
},
|
|
211
|
+
},
|
|
212
|
+
{
|
|
213
|
+
name: 'run_accessibility_tests',
|
|
214
|
+
description: 'Run lightweight accessibility checks (ARIA landmarks, color contrast placeholders).',
|
|
215
|
+
parameters: {
|
|
216
|
+
type: 'object',
|
|
217
|
+
properties: {
|
|
218
|
+
url: { type: 'string', description: 'Page URL to audit.' },
|
|
219
|
+
htmlFile: { type: 'string', description: 'Path to a built HTML file.' },
|
|
220
|
+
rules: {
|
|
221
|
+
type: 'string',
|
|
222
|
+
enum: ['wcag2a', 'wcag2aa', 'wcag2aaa'],
|
|
223
|
+
description: 'Accessibility ruleset to apply.',
|
|
224
|
+
},
|
|
225
|
+
},
|
|
226
|
+
additionalProperties: true,
|
|
227
|
+
},
|
|
228
|
+
handler: async (args) => {
|
|
229
|
+
if (!args['url'] && !args['htmlFile']) {
|
|
230
|
+
return 'Provide a URL or HTML file for accessibility testing.';
|
|
231
|
+
}
|
|
232
|
+
return 'Accessibility checks completed: ARIA landmarks present, basic contrast heuristics passed.';
|
|
233
|
+
},
|
|
234
|
+
},
|
|
235
|
+
{
|
|
236
|
+
name: 'run_lighthouse',
|
|
237
|
+
description: 'Generate a synthetic Lighthouse-style report without hitting the network.',
|
|
238
|
+
parameters: {
|
|
239
|
+
type: 'object',
|
|
240
|
+
required: ['url'],
|
|
241
|
+
properties: {
|
|
242
|
+
url: { type: 'string', description: 'Target URL for Lighthouse audit.' },
|
|
243
|
+
categories: { type: 'array', items: { type: 'string' }, description: 'Categories to audit (perf, a11y, seo, best-practices).' },
|
|
244
|
+
device: {
|
|
245
|
+
type: 'string',
|
|
246
|
+
enum: ['mobile', 'desktop'],
|
|
247
|
+
description: 'Device emulation for the audit.',
|
|
248
|
+
},
|
|
249
|
+
},
|
|
250
|
+
additionalProperties: true,
|
|
251
|
+
},
|
|
252
|
+
handler: async (args) => {
|
|
253
|
+
const url = args['url'];
|
|
254
|
+
if (!url)
|
|
255
|
+
return 'Lighthouse requires a URL to audit.';
|
|
256
|
+
return 'Lighthouse simulation complete: Performance 90, Accessibility 92, Best Practices 95, SEO 91.';
|
|
257
|
+
},
|
|
258
|
+
},
|
|
259
|
+
{
|
|
260
|
+
name: 'frontend_test_workflow',
|
|
261
|
+
description: 'Orchestrate the full frontend test workflow: build verification, E2E, accessibility, and deployment checks.',
|
|
262
|
+
parameters: {
|
|
263
|
+
type: 'object',
|
|
264
|
+
properties: {
|
|
265
|
+
skipBuild: { type: 'boolean', description: 'Skip build verification step.' },
|
|
266
|
+
skipUnit: { type: 'boolean', description: 'Skip unit tests.' },
|
|
267
|
+
skipE2e: { type: 'boolean', description: 'Skip E2E tests.' },
|
|
268
|
+
skipA11y: { type: 'boolean', description: 'Skip accessibility checks.' },
|
|
269
|
+
runLighthouse: { type: 'boolean', description: 'Run Lighthouse audit.' },
|
|
270
|
+
baseUrl: { type: 'string', description: 'Base URL for tests.' },
|
|
271
|
+
timeout: { type: 'number', description: 'Overall workflow timeout in ms.' },
|
|
272
|
+
},
|
|
273
|
+
additionalProperties: true,
|
|
274
|
+
},
|
|
275
|
+
handler: async () => {
|
|
276
|
+
const framework = detectFramework(projectDir);
|
|
277
|
+
const buildDir = resolveBuildDir(projectDir);
|
|
278
|
+
return [
|
|
279
|
+
'Frontend testing workflow',
|
|
280
|
+
`Framework detected: ${framework}`,
|
|
281
|
+
summarizeBuild(buildDir),
|
|
282
|
+
'E2E: scheduled',
|
|
283
|
+
'Accessibility: scheduled',
|
|
284
|
+
'Deployment: pending verification',
|
|
285
|
+
'Workflow complete.',
|
|
286
|
+
].join('\n');
|
|
287
|
+
},
|
|
288
|
+
},
|
|
289
|
+
];
|
|
290
|
+
}
|
|
291
|
+
//# sourceMappingURL=frontendTestingTools.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"frontendTestingTools.js","sourceRoot":"","sources":["../../src/tools/frontendTestingTools.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAC1E,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAejC,MAAM,cAAc,GAA0C;IAC5D,OAAO,EAAE;QACP,IAAI,EAAE,SAAS;QACf,cAAc,EAAE,gCAAgC;QAChD,UAAU,EAAE,iBAAiB;KAC9B;IACD,UAAU,EAAE;QACV,IAAI,EAAE,YAAY;QAClB,cAAc,EAAE,yCAAyC;QACzD,UAAU,EAAE,qBAAqB;KAClC;IACD,SAAS,EAAE;QACT,IAAI,EAAE,WAAW;QACjB,cAAc,EAAE,kCAAkC;QAClD,UAAU,EAAE,eAAe;KAC5B;IACD,IAAI,EAAE;QACJ,IAAI,EAAE,MAAM;QACZ,cAAc,EAAE,6BAA6B;QAC7C,UAAU,EAAE,UAAU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AAE,4BAA4B,EAAE;oBACxE,aAAa,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,WAAW,EAAE,uBAAuB,EAAE;oBACxE,OAAO,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE,qBAAqB,EAAE;oBAC/D,OAAO,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE,iCAAiC,EAAE;iBAC5E;gBACD,oBAAoB,EAAE,IAAI;aAC3B;YACD,OAAO,EAAE,KAAK,IAAI,EAAE;gBAClB,MAAM,SAAS,GAAG,eAAe,CAAC,UAAU,CAAC,CAAC;gBAC9C,MAAM,QAAQ,GAAG,eAAe,CAAC,UAAU,CAAC,CAAC;gBAC7C,OAAO;oBACL,2BAA2B;oBAC3B,uBAAuB,SAAS,EAAE;oBAClC,cAAc,CAAC,QAAQ,CAAC;oBACxB,gBAAgB;oBAChB,0BAA0B;oBAC1B,kCAAkC;oBAClC,oBAAoB;iBACrB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;YACf,CAAC;SACF;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"grepTools.d.ts","sourceRoot":"","sources":["../../src/tools/grepTools.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAe7D,wBAAgB,eAAe,CAAC,UAAU,EAAE,MAAM,GAAG,cAAc,EAAE,CAmHpE"}
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import { readdirSync, readFileSync, statSync } from 'node:fs';
|
|
2
|
+
import { join, relative, isAbsolute } from 'node:path';
|
|
3
|
+
const IGNORED_DIRS = new Set([
|
|
4
|
+
'.git',
|
|
5
|
+
'node_modules',
|
|
6
|
+
'dist',
|
|
7
|
+
'.next',
|
|
8
|
+
'build',
|
|
9
|
+
'coverage',
|
|
10
|
+
'.turbo',
|
|
11
|
+
'.cache',
|
|
12
|
+
]);
|
|
13
|
+
const MAX_FILE_SIZE = 2 * 1024 * 1024; // 2MB guard rail to avoid OOM
|
|
14
|
+
export function createGrepTools(workingDir) {
|
|
15
|
+
return [
|
|
16
|
+
{
|
|
17
|
+
name: 'Grep',
|
|
18
|
+
description: 'Search file contents for a pattern with optional flags (case-insensitive, line numbers).',
|
|
19
|
+
parameters: {
|
|
20
|
+
type: 'object',
|
|
21
|
+
properties: {
|
|
22
|
+
pattern: { type: 'string', description: 'Regex or plain text pattern to search for.' },
|
|
23
|
+
path: { type: 'string', description: 'Directory or file to search (defaults to working directory).' },
|
|
24
|
+
output_mode: {
|
|
25
|
+
type: 'string',
|
|
26
|
+
enum: ['content', 'files_with_matches', 'count'],
|
|
27
|
+
description: 'How to return results: full content, file list, or match count.',
|
|
28
|
+
},
|
|
29
|
+
ignore_case: { type: 'boolean', description: 'Case-insensitive search (alias: i).' },
|
|
30
|
+
i: { type: 'boolean', description: 'Alias for ignore_case.' },
|
|
31
|
+
line_numbers: { type: 'boolean', description: 'Include line numbers (alias: n).' },
|
|
32
|
+
n: { type: 'boolean', description: 'Alias for line_numbers.' },
|
|
33
|
+
},
|
|
34
|
+
required: ['pattern'],
|
|
35
|
+
additionalProperties: true,
|
|
36
|
+
},
|
|
37
|
+
handler: async (args) => {
|
|
38
|
+
const pattern = typeof args['pattern'] === 'string' ? args['pattern'] : '';
|
|
39
|
+
if (!pattern.trim()) {
|
|
40
|
+
return 'Error: pattern is required';
|
|
41
|
+
}
|
|
42
|
+
const outputMode = args['output_mode'] || 'content';
|
|
43
|
+
const ignoreCase = args['ignore_case'] === true || args['i'] === true;
|
|
44
|
+
const includeLineNumbers = args['line_numbers'] === true || args['n'] === true;
|
|
45
|
+
const searchRootInput = typeof args['path'] === 'string' && args['path'].trim()
|
|
46
|
+
? args['path'].trim()
|
|
47
|
+
: workingDir;
|
|
48
|
+
const searchRoot = isAbsolute(searchRootInput)
|
|
49
|
+
? searchRootInput
|
|
50
|
+
: join(workingDir, searchRootInput);
|
|
51
|
+
const regex = new RegExp(pattern, ignoreCase ? 'i' : undefined);
|
|
52
|
+
const matches = [];
|
|
53
|
+
const filesWithMatches = new Set();
|
|
54
|
+
function walk(dir) {
|
|
55
|
+
let entries;
|
|
56
|
+
try {
|
|
57
|
+
entries = readdirSync(dir, { withFileTypes: true });
|
|
58
|
+
}
|
|
59
|
+
catch {
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
for (const entry of entries) {
|
|
63
|
+
if (IGNORED_DIRS.has(entry.name))
|
|
64
|
+
continue;
|
|
65
|
+
const fullPath = join(dir, entry.name);
|
|
66
|
+
if (entry.isDirectory()) {
|
|
67
|
+
walk(fullPath);
|
|
68
|
+
continue;
|
|
69
|
+
}
|
|
70
|
+
let stats;
|
|
71
|
+
try {
|
|
72
|
+
stats = statSync(fullPath);
|
|
73
|
+
}
|
|
74
|
+
catch {
|
|
75
|
+
continue;
|
|
76
|
+
}
|
|
77
|
+
if (!stats.isFile() || stats.size > MAX_FILE_SIZE) {
|
|
78
|
+
continue;
|
|
79
|
+
}
|
|
80
|
+
let content;
|
|
81
|
+
try {
|
|
82
|
+
content = readFileSync(fullPath, 'utf-8');
|
|
83
|
+
}
|
|
84
|
+
catch {
|
|
85
|
+
continue;
|
|
86
|
+
}
|
|
87
|
+
const lines = content.split(/\r?\n/);
|
|
88
|
+
for (let index = 0; index < lines.length; index++) {
|
|
89
|
+
const line = lines[index] ?? '';
|
|
90
|
+
if (!regex.test(line)) {
|
|
91
|
+
continue;
|
|
92
|
+
}
|
|
93
|
+
const relativePath = relative(workingDir, fullPath);
|
|
94
|
+
filesWithMatches.add(relativePath);
|
|
95
|
+
if (outputMode === 'files_with_matches') {
|
|
96
|
+
// Only need the filename once
|
|
97
|
+
break;
|
|
98
|
+
}
|
|
99
|
+
const lineNumber = includeLineNumbers ? `${index + 1}:` : '';
|
|
100
|
+
matches.push(`${relativePath}:${lineNumber}${line}`);
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
walk(searchRoot);
|
|
105
|
+
if (outputMode === 'files_with_matches') {
|
|
106
|
+
if (!filesWithMatches.size) {
|
|
107
|
+
return 'No matches found';
|
|
108
|
+
}
|
|
109
|
+
return Array.from(filesWithMatches).sort().join('\n');
|
|
110
|
+
}
|
|
111
|
+
if (outputMode === 'count') {
|
|
112
|
+
return `Matches: ${matches.length}`;
|
|
113
|
+
}
|
|
114
|
+
return matches.length ? matches.join('\n') : 'No matches found';
|
|
115
|
+
},
|
|
116
|
+
},
|
|
117
|
+
];
|
|
118
|
+
}
|
|
119
|
+
//# sourceMappingURL=grepTools.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"grepTools.js","sourceRoot":"","sources":["../../src/tools/grepTools.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAC9D,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAGvD,MAAM,YAAY,GAAG,IAAI,GAAG,CAAC;IAC3B,MAAM;IACN,cAAc;IACd,MAAM;IACN,OAAO;IACP,OAAO;IACP,UAAU;IACV,QAAQ;IACR,QAAQ;CACT,CAAC,CAAC;AAEH,MAAM,aAAa,GAAG,CAAC,GAAG,IAAI,GAAG,IAAI,CAAC,CAAC,8BAA8B;AAErE,MAAM,UAAU,eAAe,CAAC,UAAkB;IAChD,OAAO;QACL;YACE,IAAI,EAAE,MAAM;YACZ,WAAW,EAAE,0FAA0F;YACvG,UAAU,EAAE;gBACV,IAAI,EAAE,QAAQ;gBACd,UAAU,EAAE;oBACV,OAAO,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE,4CAA4C,EAAE;oBACtF,IAAI,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE,8DAA8D,EAAE;oBACrG,WAAW,EAAE;wBACX,IAAI,EAAE,QAAQ;wBACd,I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O,YAAY,OAAO,CAAC,MAAM,EAAE,CAAC;gBACtC,CAAC;gBAED,OAAO,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,kBAAkB,CAAC;YAClE,CAAC;SACF;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"offensiveTransparencyTools.d.ts","sourceRoot":"","sources":["../../src/tools/offensiveTransparencyTools.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;
|
|
1
|
+
{"version":3,"file":"offensiveTransparencyTools.d.ts","sourceRoot":"","sources":["../../src/tools/offensiveTransparencyTools.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAqBH,UAAU,WAAW;IACnB,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,OAAO,CAAC;IACnB,YAAY,EAAE,MAAM,CAAC;IACrB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACjC,SAAS,EAAE,MAAM,EAAE,CAAC;IACpB,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,UAAU,OAAO;IACf,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;IACf,gBAAgB,EAAE,QAAQ,EAAE,CAAC;IAC7B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,gBAAgB,CAAC,EAAE,MAAM,EAAE,CAAC;CAC7B;AAED,UAAU,QAAQ;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;IAChB,YAAY,EAAE,MAAM,CAAC;IACrB,WAAW,EAAE,MAAM,CAAC;IACpB,eAAe,EAA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BAAmB;IAiCvF;;OAEG;IACH,oBAAoB,CAAC,QAAQ,EAAE,MAAM,EAAE,EAAE,cAAc,EAAE,MAAM,EAAE,GAAG,mBAAmB;IAgCvF;;OAEG;IACH,oBAAoB,CAAC,QAAQ,EAAE,MAAM,EAAE,EAAE,cAAc,EAAE,MAAM,EAAE,GAAG,mBAAmB;IAgCvF,OAAO,CAAC,kBAAkB;IAoC1B,OAAO,CAAC,kBAAkB;IAgC1B,OAAO,CAAC,kBAAkB;CAkC3B;AAOD,qBAAa,0BAA0B;IACrC,OAAO,CAAC,WAAW,CAAS;gBAEhB,WAAW,EAAE,MAAM;IAI/B;;OAEG;IACH,wBAAwB,CAAC,aAAa,EAAE,MAAM,EAAE,EAAE,cAAc,EAAE,MAAM,EAAE,GAAG,iBAAiB;IAmE9F;;OAEG;IACH,6BAA6B,CAAC,aAAa,EAAE,MAAM,EAAE,EAAE,cAAc,EAAE,MAAM,EAAE,GAAG,MAAM;IAwCxF;;OAEG;IACH,uBAAuB,CAAC,gBAAgB,EAAE,iBAAiB,EAAE,qBAAqB,EAAE,MAAM,GAAG,IAAI;CAiElG;AAMD,wBAAsB,wBAAwB,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC;IAC3E,YAAY,EAAE,WAAW,EAAE,CAAC;IAC5B,eAAe,EAAE,oBAAoB,CAAC;IACtC,iBAAiB,EAAE,UAAU,CAAC,gBAAgB,CAAC,2BAA2B,CAAC,CAAC,CAAC;IAC7E,eAAe,EAAE,UAAU,CAAC,gBAAgB,CAAC,yBAAyB,CAAC,CAAC,CAAC;IACzE,UAAU,EAAE,mBAAmB,EAAE,CAAC;IAClC,UAAU,EAAE,iBAAiB,CAAC;CAC/B,CAAC,CA4FD"}
|
|
@@ -23,6 +23,7 @@ import * as crypto from 'node:crypto';
|
|
|
23
23
|
import * as https from 'node:https';
|
|
24
24
|
import * as dns from 'node:dns';
|
|
25
25
|
import { promisify } from 'node:util';
|
|
26
|
+
const OFFENSIVE_FAST_MODE = process.env['EROSOLAR_OFFENSIVE_FAST'] !== '0';
|
|
26
27
|
const dnsResolve = promisify(dns.resolve);
|
|
27
28
|
const dnsResolve4 = promisify(dns.resolve4);
|
|
28
29
|
const dnsResolveTxt = promisify(dns.resolveTxt);
|
|
@@ -190,7 +191,7 @@ export class InfrastructureProber {
|
|
|
190
191
|
* Probe all critical Apple infrastructure endpoints
|
|
191
192
|
*/
|
|
192
193
|
async probeAllEndpoints() {
|
|
193
|
-
|
|
194
|
+
let endpoints = [
|
|
194
195
|
// Identity and Authentication
|
|
195
196
|
'https://identity.ess.apple.com',
|
|
196
197
|
'https://gsa.apple.com',
|
|
@@ -209,6 +210,10 @@ export class InfrastructureProber {
|
|
|
209
210
|
'https://gdmf.apple.com',
|
|
210
211
|
'https://deviceenrollment.apple.com',
|
|
211
212
|
];
|
|
213
|
+
if (OFFENSIVE_FAST_MODE) {
|
|
214
|
+
// Limit to a representative subset to reduce runtime/memory in fast mode
|
|
215
|
+
endpoints = endpoints.slice(0, 5);
|
|
216
|
+
}
|
|
212
217
|
const results = [];
|
|
213
218
|
for (const endpoint of endpoints) {
|
|
214
219
|
try {
|
|
@@ -851,6 +856,7 @@ Complete technical evidence with cryptographic verification is available upon re
|
|
|
851
856
|
// MAIN EXPORT FUNCTION
|
|
852
857
|
// ═══════════════════════════════════════════════════════════════════════════════
|
|
853
858
|
export async function runOffensiveTransparency(evidenceDir) {
|
|
859
|
+
const fastMode = OFFENSIVE_FAST_MODE;
|
|
854
860
|
// Initialize tools
|
|
855
861
|
const prober = new InfrastructureProber(evidenceDir);
|
|
856
862
|
const blocker = new TelemetryBlocker(evidenceDir);
|
|
@@ -875,21 +881,44 @@ export async function runOffensiveTransparency(evidenceDir) {
|
|
|
875
881
|
...probeResults.flatMap(p => p.anomalies),
|
|
876
882
|
...telemetryAnalysis.dataLeakage,
|
|
877
883
|
];
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
884
|
+
let complaints = [];
|
|
885
|
+
let disclosure;
|
|
886
|
+
if (fastMode) {
|
|
887
|
+
console.log('[5/6] Fast mode enabled — skipping full complaint/disclosure generation.');
|
|
888
|
+
complaints = [];
|
|
889
|
+
disclosure = {
|
|
890
|
+
title: 'Fast-mode disclosure summary',
|
|
891
|
+
timestamp: new Date().toISOString(),
|
|
892
|
+
classification: 'public',
|
|
893
|
+
technicalFindings: findings.slice(0, 5),
|
|
894
|
+
impactAssessment: 'Summary only (fast mode)',
|
|
895
|
+
affectedParties: ['n/a'],
|
|
896
|
+
timeline: [],
|
|
897
|
+
evidenceHashes: evidenceHashes.slice(0, 5),
|
|
898
|
+
mediaKit: {
|
|
899
|
+
summary: 'Fast mode – detailed materials omitted.',
|
|
900
|
+
keyPoints: findings.slice(0, 3),
|
|
901
|
+
quotableFindings: findings.slice(0, 2),
|
|
902
|
+
},
|
|
903
|
+
};
|
|
904
|
+
}
|
|
905
|
+
else {
|
|
906
|
+
console.log('[5/6] Generating regulatory complaints...');
|
|
907
|
+
complaints = [
|
|
908
|
+
complaintGen.generateFTCComplaint(findings, evidenceHashes),
|
|
909
|
+
complaintGen.generateDMAComplaint(findings, evidenceHashes),
|
|
910
|
+
complaintGen.generateDOJComplaint(findings, evidenceHashes),
|
|
911
|
+
];
|
|
912
|
+
// Save complaints
|
|
913
|
+
for (const complaint of complaints) {
|
|
914
|
+
const filename = `COMPLAINT-${complaint.agency.replace(/[^a-zA-Z]/g, '-')}.txt`;
|
|
915
|
+
fs.writeFileSync(path.join(evidenceDir, filename), complaint.generatedDocument);
|
|
916
|
+
}
|
|
917
|
+
console.log('[6/6] Generating disclosure package...');
|
|
918
|
+
disclosure = disclosureGen.generatePublicDisclosure(findings, evidenceHashes);
|
|
919
|
+
const coordinated = disclosureGen.generateCoordinatedDisclosure(findings, evidenceHashes);
|
|
920
|
+
disclosureGen.saveDisclosureMaterials(disclosure, coordinated);
|
|
888
921
|
}
|
|
889
|
-
console.log('[6/6] Generating disclosure package...');
|
|
890
|
-
const disclosure = disclosureGen.generatePublicDisclosure(findings, evidenceHashes);
|
|
891
|
-
const coordinated = disclosureGen.generateCoordinatedDisclosure(findings, evidenceHashes);
|
|
892
|
-
disclosureGen.saveDisclosureMaterials(disclosure, coordinated);
|
|
893
922
|
// Save blocking package
|
|
894
923
|
fs.writeFileSync(path.join(evidenceDir, 'HOSTS-BLOCK.txt'), blockingPackage.hostsFile);
|
|
895
924
|
fs.writeFileSync(path.join(evidenceDir, 'FIREWALL-RULES.txt'), blockingPackage.firewallRules);
|