@flowspec-qa/runner-core 0.2.4 → 0.4.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.
Files changed (52) hide show
  1. package/dist/api-client.d.ts +87 -10
  2. package/dist/api-client.d.ts.map +1 -1
  3. package/dist/api-client.js +108 -7
  4. package/dist/api-client.js.map +1 -1
  5. package/dist/auth.d.ts.map +1 -1
  6. package/dist/auth.js +4 -3
  7. package/dist/auth.js.map +1 -1
  8. package/dist/config.d.ts +1 -0
  9. package/dist/config.d.ts.map +1 -1
  10. package/dist/config.js +4 -1
  11. package/dist/config.js.map +1 -1
  12. package/dist/discovery-report.d.ts +13 -0
  13. package/dist/discovery-report.d.ts.map +1 -0
  14. package/dist/discovery-report.js +977 -0
  15. package/dist/discovery-report.js.map +1 -0
  16. package/dist/discovery.d.ts +213 -3
  17. package/dist/discovery.d.ts.map +1 -1
  18. package/dist/discovery.js +2125 -264
  19. package/dist/discovery.js.map +1 -1
  20. package/dist/evidence-corpus.d.ts +338 -0
  21. package/dist/evidence-corpus.d.ts.map +1 -0
  22. package/dist/evidence-corpus.js +927 -0
  23. package/dist/evidence-corpus.js.map +1 -0
  24. package/dist/evidence-types.d.ts +230 -0
  25. package/dist/evidence-types.d.ts.map +1 -0
  26. package/dist/evidence-types.js +24 -0
  27. package/dist/evidence-types.js.map +1 -0
  28. package/dist/executor.d.ts +1 -0
  29. package/dist/executor.d.ts.map +1 -1
  30. package/dist/executor.js +93 -195
  31. package/dist/executor.js.map +1 -1
  32. package/dist/index.d.ts +5 -1
  33. package/dist/index.d.ts.map +1 -1
  34. package/dist/index.js +3 -0
  35. package/dist/index.js.map +1 -1
  36. package/dist/suite-manager.d.ts +6 -0
  37. package/dist/suite-manager.d.ts.map +1 -1
  38. package/dist/suite-manager.js +55 -2
  39. package/dist/suite-manager.js.map +1 -1
  40. package/package.json +4 -1
  41. package/src/api-client.ts +0 -170
  42. package/src/auth.ts +0 -45
  43. package/src/backup-manager.ts +0 -63
  44. package/src/config.ts +0 -52
  45. package/src/devices.ts +0 -196
  46. package/src/discovery.ts +0 -563
  47. package/src/executor.ts +0 -681
  48. package/src/index.ts +0 -11
  49. package/src/result-sanitizer.ts +0 -60
  50. package/src/suite-manager.ts +0 -73
  51. package/src/uploader.ts +0 -74
  52. package/tsconfig.json +0 -8
@@ -1,60 +0,0 @@
1
- import { config } from './config.js';
2
- import type { TestResultItem } from './api-client.js';
3
-
4
- /**
5
- * Sanitize test results before uploading to FlowSpecQA SaaS.
6
- *
7
- * Strips:
8
- * - HTTP/HTTPS URLs (base URLs of the client's environments)
9
- * - IP addresses
10
- * - Authorization / Bearer tokens
11
- * - Password patterns (key=value)
12
- * - Anything matching custom patterns in config
13
- *
14
- * The test name, status, and duration are NEVER modified.
15
- * Only `error` messages are sanitized.
16
- */
17
- export function sanitizeResults(results: TestResultItem[]): TestResultItem[] {
18
- const patterns = config.get('sanitizerPatterns').map((p) => new RegExp(p, 'gi'));
19
-
20
- return results.map((r) => ({
21
- ...r,
22
- error: r.error ? sanitizeString(r.error, patterns) : null,
23
- }));
24
- }
25
-
26
- function sanitizeString(text: string, patterns: RegExp[]): string {
27
- let sanitized = text;
28
- for (const pattern of patterns) {
29
- sanitized = sanitized.replace(pattern, '[REDACTED]');
30
- }
31
- // Additional pass: truncate very long error messages to 1500 chars
32
- if (sanitized.length > 1500) {
33
- sanitized = sanitized.slice(0, 1500) + '... [truncated]';
34
- }
35
- return sanitized;
36
- }
37
-
38
- /**
39
- * Validate that no obvious secrets leaked through (belt-and-suspenders check).
40
- * Throws if any result still contains a pattern that looks like a secret.
41
- */
42
- export function assertNoSecrets(results: TestResultItem[]): void {
43
- const dangerPatterns = [
44
- /https?:\/\/[a-z0-9.-]+\.(internal|local|corp|dev|staging|test)[/:]?/i,
45
- /Bearer\s+[A-Za-z0-9.\-_]{20,}/,
46
- /\bpassword\b/i,
47
- ];
48
-
49
- for (const r of results) {
50
- if (!r.error) continue;
51
- for (const p of dangerPatterns) {
52
- if (p.test(r.error)) {
53
- throw new Error(
54
- `Security check failed: error message for test "${r.name}" may contain sensitive data. ` +
55
- `Run with --skip-security-check to bypass (not recommended).`
56
- );
57
- }
58
- }
59
- }
60
- }
@@ -1,73 +0,0 @@
1
- import AdmZip from 'adm-zip';
2
- import fs from 'fs';
3
- import path from 'path';
4
- import { config } from './config.js';
5
- import { FlowSpecQAApi } from './api-client.js';
6
-
7
- export interface LocalSuite {
8
- runId: string;
9
- entityId: string;
10
- framework: 'playwright' | 'cypress' | 'maestro';
11
- suiteDir: string;
12
- downloadedAt: Date;
13
- }
14
-
15
- /**
16
- * Download a suite ZIP from FlowSpecQA SaaS and unzip it to the local cache.
17
- * Returns the path to the unzipped suite directory.
18
- */
19
- export async function downloadSuite(suiteId: string, entityId: string, framework: string): Promise<LocalSuite> {
20
- const cacheDir = config.get('suiteCacheDir');
21
- const suiteDir = path.join(cacheDir, entityId, suiteId);
22
-
23
- // Avoid re-downloading if already cached
24
- if (fs.existsSync(path.join(suiteDir, 'package.json'))) {
25
- return {
26
- runId: suiteId,
27
- entityId,
28
- framework: framework as LocalSuite['framework'],
29
- suiteDir,
30
- downloadedAt: fs.statSync(suiteDir).mtime,
31
- };
32
- }
33
-
34
- const zipBuffer = await FlowSpecQAApi.downloadSuiteZip(suiteId);
35
- fs.mkdirSync(suiteDir, { recursive: true });
36
-
37
- const zip = new AdmZip(zipBuffer);
38
- zip.extractAllTo(suiteDir, /* overwrite */ true);
39
-
40
- return {
41
- runId: suiteId,
42
- entityId,
43
- framework: framework as LocalSuite['framework'],
44
- suiteDir,
45
- downloadedAt: new Date(),
46
- };
47
- }
48
-
49
- /**
50
- * List all locally cached suites.
51
- */
52
- export function listCachedSuites(): Array<{ entityId: string; runId: string; suiteDir: string }> {
53
- const cacheDir = config.get('suiteCacheDir');
54
- if (!fs.existsSync(cacheDir)) return [];
55
-
56
- const result: Array<{ entityId: string; runId: string; suiteDir: string }> = [];
57
- for (const entityId of fs.readdirSync(cacheDir)) {
58
- const entityDir = path.join(cacheDir, entityId);
59
- if (!fs.statSync(entityDir).isDirectory()) continue;
60
- for (const runId of fs.readdirSync(entityDir)) {
61
- result.push({ entityId, runId, suiteDir: path.join(entityDir, runId) });
62
- }
63
- }
64
- return result;
65
- }
66
-
67
- /**
68
- * Remove a cached suite directory.
69
- */
70
- export function evictSuite(entityId: string, runId: string): void {
71
- const suiteDir = path.join(config.get('suiteCacheDir'), entityId, runId);
72
- fs.rmSync(suiteDir, { recursive: true, force: true });
73
- }
package/src/uploader.ts DELETED
@@ -1,74 +0,0 @@
1
- import os from 'os';
2
- import { FlowSpecQAApi, type RunResultPayload } from './api-client.js';
3
- import { sanitizeResults, assertNoSecrets } from './result-sanitizer.js';
4
- import type { ExecutionResult } from './executor.js';
5
-
6
- const RUNNER_VERSION = '0.1.0';
7
-
8
- /** Capture machine traceability info at upload time */
9
- function getMachineInfo(): { machine_name: string; machine_ip: string; os_info: string; executor: string } {
10
- const hostname = os.hostname();
11
- const platform = os.platform();
12
- const release = os.release();
13
- const arch = os.arch();
14
-
15
- // First non-internal IPv4 address across all interfaces
16
- const nets = os.networkInterfaces();
17
- let machine_ip = '0.0.0.0';
18
- for (const iface of Object.values(nets)) {
19
- const found = iface?.find((n) => n.family === 'IPv4' && !n.internal);
20
- if (found) { machine_ip = found.address; break; }
21
- }
22
-
23
- const platformLabel: Record<string, string> = {
24
- win32: 'Windows', darwin: 'macOS', linux: 'Linux',
25
- };
26
-
27
- return {
28
- machine_name: hostname,
29
- machine_ip,
30
- os_info: `${platformLabel[platform] ?? platform} ${release} (${arch})`,
31
- executor: 'flowspecqa-runner',
32
- };
33
- }
34
-
35
- export interface UploadOptions {
36
- runId: string;
37
- entityId: string;
38
- framework: string;
39
- envLabel: string;
40
- skipSecurityCheck?: boolean;
41
- }
42
-
43
- /**
44
- * Sanitize + upload test results to FlowSpecQA SaaS.
45
- * Returns the exec_id assigned by the server.
46
- */
47
- export async function uploadResults(
48
- execution: ExecutionResult,
49
- options: UploadOptions
50
- ): Promise<{ execId: string }> {
51
- // Step 1: Sanitize — strip URLs, IPs, tokens from error messages
52
- const sanitized = sanitizeResults(execution.results);
53
-
54
- // Step 2: Belt-and-suspenders security check
55
- if (!options.skipSecurityCheck) {
56
- assertNoSecrets(sanitized);
57
- }
58
-
59
- // Step 3: Build payload
60
- const payload: RunResultPayload = {
61
- run_id: options.runId,
62
- entity_id: options.entityId,
63
- framework: options.framework,
64
- env_label: options.envLabel,
65
- results: sanitized,
66
- started_at: execution.startedAt.toISOString(),
67
- finished_at: execution.finishedAt.toISOString(),
68
- runner_version: RUNNER_VERSION,
69
- ...getMachineInfo(),
70
- };
71
-
72
- const response = await FlowSpecQAApi.submitRunResult(payload);
73
- return { execId: response.exec_id };
74
- }
package/tsconfig.json DELETED
@@ -1,8 +0,0 @@
1
- {
2
- "extends": "../../tsconfig.json",
3
- "compilerOptions": {
4
- "rootDir": "src",
5
- "outDir": "dist"
6
- },
7
- "include": ["src/**/*"]
8
- }