swarmdo 1.4.8 → 1.5.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/.claude/helpers/statusline.cjs +7 -7
- package/README.md +3 -1
- package/package.json +5 -3
- package/v3/@swarmdo/cli/dist/src/commands/hooks.js +26 -24
- package/v3/@swarmdo/cli/dist/src/commands/index.js +4 -0
- package/v3/@swarmdo/cli/dist/src/commands/integrations.d.ts +14 -0
- package/v3/@swarmdo/cli/dist/src/commands/integrations.js +158 -0
- package/v3/@swarmdo/cli/dist/src/commands/memory.js +50 -1
- package/v3/@swarmdo/cli/dist/src/commands/providers.js +3 -0
- package/v3/@swarmdo/cli/dist/src/commands/release.d.ts +15 -0
- package/v3/@swarmdo/cli/dist/src/commands/release.js +224 -0
- package/v3/@swarmdo/cli/dist/src/commands/security.js +14 -0
- package/v3/@swarmdo/cli/dist/src/commands/transcript.js +82 -1
- package/v3/@swarmdo/cli/dist/src/commands/usage.js +80 -1
- package/v3/@swarmdo/cli/dist/src/config-lint/lint.js +11 -1
- package/v3/@swarmdo/cli/dist/src/init/statusline-generator.js +6 -6
- package/v3/@swarmdo/cli/dist/src/integrations/integrations.d.ts +54 -0
- package/v3/@swarmdo/cli/dist/src/integrations/integrations.js +162 -0
- package/v3/@swarmdo/cli/dist/src/mcp-tools/agent-execute-core.js +25 -3
- package/v3/@swarmdo/cli/dist/src/mcp-tools/agentdb-tools.js +8 -8
- package/v3/@swarmdo/cli/dist/src/memory/graph-edge-writer.d.ts +12 -0
- package/v3/@swarmdo/cli/dist/src/memory/graph-edge-writer.js +32 -1
- package/v3/@swarmdo/cli/dist/src/memory-vault/watch.d.ts +32 -0
- package/v3/@swarmdo/cli/dist/src/memory-vault/watch.js +66 -0
- package/v3/@swarmdo/cli/dist/src/providers/openrouter-config.d.ts +91 -0
- package/v3/@swarmdo/cli/dist/src/providers/openrouter-config.js +186 -0
- package/v3/@swarmdo/cli/dist/src/release/release.d.ts +72 -0
- package/v3/@swarmdo/cli/dist/src/release/release.js +86 -0
- package/v3/@swarmdo/cli/dist/src/resilience/backoff.d.ts +23 -0
- package/v3/@swarmdo/cli/dist/src/resilience/backoff.js +30 -0
- package/v3/@swarmdo/cli/dist/src/swarmvector/model-router.js +14 -0
- package/v3/@swarmdo/cli/dist/src/transcript/search.d.ts +39 -0
- package/v3/@swarmdo/cli/dist/src/transcript/search.js +67 -0
- package/v3/@swarmdo/cli/dist/src/usage/diff.d.ts +69 -0
- package/v3/@swarmdo/cli/dist/src/usage/diff.js +112 -0
- package/v3/@swarmdo/cli/package.json +4 -4
- package/v3/@swarmdo/cli-core/dist/src/index.js +1 -1
- package/v3/@swarmdo/codex/dist/cli.js +0 -0
- package/v3/@swarmdo/hooks/dist/cli/guidance-cli.js +0 -0
- package/v3/@swarmdo/hooks/dist/statusline/index.d.ts +3 -3
- package/v3/@swarmdo/hooks/dist/statusline/index.js +3 -3
- package/v3/@swarmdo/integration/dist/__tests__/agentic-flow-agent.test.js +4 -1
- package/v3/@swarmdo/neural/dist/flash-attention.d.ts +1 -1
- package/v3/@swarmdo/neural/dist/flash-attention.js +1 -1
- package/v3/@swarmdo/plugin-agent-federation/dist/plugin.js +1 -1
- package/v3/@swarmdo/plugin-agent-federation/dist/transport/midstream-aware-loader.js +2 -2
- package/v3/@swarmdo/providers/dist/swarmvector-provider.d.ts +1 -1
- package/v3/@swarmdo/providers/dist/swarmvector-provider.js +1 -1
- package/v3/@swarmdo/security/dist/input-validator.d.ts +6 -6
- package/v3/@swarmdo/shared/dist/hooks/safety/git-commit.js +1 -1
- package/v3/@swarmdo/shared/dist/mcp/transport/http.js +8 -1
- package/v3/vendor/agentdb/package.json +0 -1
- package/v3/vendor/agentic-flow/package.json +0 -1
- package/.claude/scheduled_tasks.lock +0 -1
- package/.claude/skills/sdo-caveman-compress/scripts/__pycache__/__init__.cpython-314.pyc +0 -0
- package/.claude/skills/sdo-caveman-compress/scripts/__pycache__/__main__.cpython-314.pyc +0 -0
- package/.claude/skills/sdo-caveman-compress/scripts/__pycache__/cli.cpython-314.pyc +0 -0
- package/.claude/skills/sdo-caveman-compress/scripts/__pycache__/compress.cpython-314.pyc +0 -0
- package/.claude/skills/sdo-caveman-compress/scripts/__pycache__/detect.cpython-314.pyc +0 -0
- package/.claude/skills/sdo-caveman-compress/scripts/__pycache__/validate.cpython-314.pyc +0 -0
- package/v3/@swarmdo/plugin-iot-cognitum/dist/application/index.d.ts +0 -2
- package/v3/@swarmdo/plugin-iot-cognitum/dist/application/index.js +0 -2
- package/v3/@swarmdo/plugin-iot-cognitum/dist/application/iot-coordinator.d.ts +0 -138
- package/v3/@swarmdo/plugin-iot-cognitum/dist/application/iot-coordinator.js +0 -418
- package/v3/@swarmdo/plugin-iot-cognitum/dist/bin.d.ts +0 -15
- package/v3/@swarmdo/plugin-iot-cognitum/dist/bin.js +0 -240
- package/v3/@swarmdo/plugin-iot-cognitum/dist/cli-commands.d.ts +0 -7
- package/v3/@swarmdo/plugin-iot-cognitum/dist/cli-commands.js +0 -508
- package/v3/@swarmdo/plugin-iot-cognitum/dist/domain/entities/device-agent.d.ts +0 -54
- package/v3/@swarmdo/plugin-iot-cognitum/dist/domain/entities/device-agent.js +0 -2
- package/v3/@swarmdo/plugin-iot-cognitum/dist/domain/entities/device-fleet.d.ts +0 -46
- package/v3/@swarmdo/plugin-iot-cognitum/dist/domain/entities/device-fleet.js +0 -2
- package/v3/@swarmdo/plugin-iot-cognitum/dist/domain/entities/device-trust-level.d.ts +0 -18
- package/v3/@swarmdo/plugin-iot-cognitum/dist/domain/entities/device-trust-level.js +0 -28
- package/v3/@swarmdo/plugin-iot-cognitum/dist/domain/entities/index.d.ts +0 -5
- package/v3/@swarmdo/plugin-iot-cognitum/dist/domain/entities/index.js +0 -2
- package/v3/@swarmdo/plugin-iot-cognitum/dist/domain/entities/telemetry.d.ts +0 -35
- package/v3/@swarmdo/plugin-iot-cognitum/dist/domain/entities/telemetry.js +0 -2
- package/v3/@swarmdo/plugin-iot-cognitum/dist/domain/repositories/device-repository.d.ts +0 -11
- package/v3/@swarmdo/plugin-iot-cognitum/dist/domain/repositories/device-repository.js +0 -2
- package/v3/@swarmdo/plugin-iot-cognitum/dist/domain/repositories/fleet-repository.d.ts +0 -9
- package/v3/@swarmdo/plugin-iot-cognitum/dist/domain/repositories/fleet-repository.js +0 -2
- package/v3/@swarmdo/plugin-iot-cognitum/dist/domain/repositories/index.d.ts +0 -5
- package/v3/@swarmdo/plugin-iot-cognitum/dist/domain/repositories/index.js +0 -2
- package/v3/@swarmdo/plugin-iot-cognitum/dist/domain/repositories/telemetry-repository.d.ts +0 -12
- package/v3/@swarmdo/plugin-iot-cognitum/dist/domain/repositories/telemetry-repository.js +0 -2
- package/v3/@swarmdo/plugin-iot-cognitum/dist/domain/repositories/trust-history-repository.d.ts +0 -19
- package/v3/@swarmdo/plugin-iot-cognitum/dist/domain/repositories/trust-history-repository.js +0 -2
- package/v3/@swarmdo/plugin-iot-cognitum/dist/domain/services/anomaly-detection-service.d.ts +0 -44
- package/v3/@swarmdo/plugin-iot-cognitum/dist/domain/services/anomaly-detection-service.js +0 -117
- package/v3/@swarmdo/plugin-iot-cognitum/dist/domain/services/device-lifecycle-service.d.ts +0 -70
- package/v3/@swarmdo/plugin-iot-cognitum/dist/domain/services/device-lifecycle-service.js +0 -194
- package/v3/@swarmdo/plugin-iot-cognitum/dist/domain/services/firmware-orchestration-service.d.ts +0 -69
- package/v3/@swarmdo/plugin-iot-cognitum/dist/domain/services/firmware-orchestration-service.js +0 -139
- package/v3/@swarmdo/plugin-iot-cognitum/dist/domain/services/fleet-topology-service.d.ts +0 -34
- package/v3/@swarmdo/plugin-iot-cognitum/dist/domain/services/fleet-topology-service.js +0 -101
- package/v3/@swarmdo/plugin-iot-cognitum/dist/domain/services/index.d.ts +0 -10
- package/v3/@swarmdo/plugin-iot-cognitum/dist/domain/services/index.js +0 -10
- package/v3/@swarmdo/plugin-iot-cognitum/dist/domain/services/mesh-service.d.ts +0 -64
- package/v3/@swarmdo/plugin-iot-cognitum/dist/domain/services/mesh-service.js +0 -70
- package/v3/@swarmdo/plugin-iot-cognitum/dist/domain/services/sona-integration-service.d.ts +0 -44
- package/v3/@swarmdo/plugin-iot-cognitum/dist/domain/services/sona-integration-service.js +0 -79
- package/v3/@swarmdo/plugin-iot-cognitum/dist/domain/services/telemetry-ingestion-service.d.ts +0 -37
- package/v3/@swarmdo/plugin-iot-cognitum/dist/domain/services/telemetry-ingestion-service.js +0 -39
- package/v3/@swarmdo/plugin-iot-cognitum/dist/domain/services/telemetry-service.d.ts +0 -67
- package/v3/@swarmdo/plugin-iot-cognitum/dist/domain/services/telemetry-service.js +0 -58
- package/v3/@swarmdo/plugin-iot-cognitum/dist/domain/services/witness-verification-service.d.ts +0 -45
- package/v3/@swarmdo/plugin-iot-cognitum/dist/domain/services/witness-verification-service.js +0 -63
- package/v3/@swarmdo/plugin-iot-cognitum/dist/index.d.ts +0 -26
- package/v3/@swarmdo/plugin-iot-cognitum/dist/index.js +0 -17
- package/v3/@swarmdo/plugin-iot-cognitum/dist/infrastructure/agentdb-telemetry-repository.d.ts +0 -51
- package/v3/@swarmdo/plugin-iot-cognitum/dist/infrastructure/agentdb-telemetry-repository.js +0 -110
- package/v3/@swarmdo/plugin-iot-cognitum/dist/infrastructure/in-memory-device-repository.d.ts +0 -13
- package/v3/@swarmdo/plugin-iot-cognitum/dist/infrastructure/in-memory-device-repository.js +0 -25
- package/v3/@swarmdo/plugin-iot-cognitum/dist/infrastructure/in-memory-fleet-repository.d.ts +0 -11
- package/v3/@swarmdo/plugin-iot-cognitum/dist/infrastructure/in-memory-fleet-repository.js +0 -19
- package/v3/@swarmdo/plugin-iot-cognitum/dist/infrastructure/in-memory-trust-history-repository.d.ts +0 -11
- package/v3/@swarmdo/plugin-iot-cognitum/dist/infrastructure/in-memory-trust-history-repository.js +0 -27
- package/v3/@swarmdo/plugin-iot-cognitum/dist/infrastructure/index.d.ts +0 -6
- package/v3/@swarmdo/plugin-iot-cognitum/dist/infrastructure/index.js +0 -6
- package/v3/@swarmdo/plugin-iot-cognitum/dist/infrastructure/seed-client-factory.d.ts +0 -41
- package/v3/@swarmdo/plugin-iot-cognitum/dist/infrastructure/seed-client-factory.js +0 -64
- package/v3/@swarmdo/plugin-iot-cognitum/dist/mcp-tools.d.ts +0 -8
- package/v3/@swarmdo/plugin-iot-cognitum/dist/mcp-tools.js +0 -703
- package/v3/@swarmdo/plugin-iot-cognitum/dist/plugin.d.ts +0 -23
- package/v3/@swarmdo/plugin-iot-cognitum/dist/plugin.js +0 -239
- package/v3/@swarmdo/plugin-iot-cognitum/dist/workers/anomaly-scan-worker.d.ts +0 -17
- package/v3/@swarmdo/plugin-iot-cognitum/dist/workers/anomaly-scan-worker.js +0 -42
- package/v3/@swarmdo/plugin-iot-cognitum/dist/workers/firmware-watch-worker.d.ts +0 -18
- package/v3/@swarmdo/plugin-iot-cognitum/dist/workers/firmware-watch-worker.js +0 -45
- package/v3/@swarmdo/plugin-iot-cognitum/dist/workers/health-probe-worker.d.ts +0 -19
- package/v3/@swarmdo/plugin-iot-cognitum/dist/workers/health-probe-worker.js +0 -50
- package/v3/@swarmdo/plugin-iot-cognitum/dist/workers/mesh-sync-worker.d.ts +0 -19
- package/v3/@swarmdo/plugin-iot-cognitum/dist/workers/mesh-sync-worker.js +0 -47
- package/v3/@swarmdo/plugin-iot-cognitum/dist/workers/telemetry-ingest-worker.d.ts +0 -17
- package/v3/@swarmdo/plugin-iot-cognitum/dist/workers/telemetry-ingest-worker.js +0 -40
- package/v3/@swarmdo/plugin-iot-cognitum/dist/workers/witness-audit-worker.d.ts +0 -18
- package/v3/@swarmdo/plugin-iot-cognitum/dist/workers/witness-audit-worker.js +0 -51
- package/v3/@swarmdo/testing/dist/fixtures/agent-fixtures.d.ts +0 -214
- package/v3/@swarmdo/testing/dist/fixtures/agent-fixtures.js +0 -595
- package/v3/@swarmdo/testing/dist/fixtures/agents.d.ts +0 -76
- package/v3/@swarmdo/testing/dist/fixtures/agents.js +0 -158
- package/v3/@swarmdo/testing/dist/fixtures/configurations.d.ts +0 -157
- package/v3/@swarmdo/testing/dist/fixtures/configurations.js +0 -337
- package/v3/@swarmdo/testing/dist/fixtures/index.d.ts +0 -10
- package/v3/@swarmdo/testing/dist/fixtures/index.js +0 -17
- package/v3/@swarmdo/testing/dist/fixtures/mcp-fixtures.d.ts +0 -329
- package/v3/@swarmdo/testing/dist/fixtures/mcp-fixtures.js +0 -714
- package/v3/@swarmdo/testing/dist/fixtures/memory-entries.d.ts +0 -159
- package/v3/@swarmdo/testing/dist/fixtures/memory-entries.js +0 -262
- package/v3/@swarmdo/testing/dist/fixtures/memory-fixtures.d.ts +0 -290
- package/v3/@swarmdo/testing/dist/fixtures/memory-fixtures.js +0 -547
- package/v3/@swarmdo/testing/dist/fixtures/swarm-fixtures.d.ts +0 -289
- package/v3/@swarmdo/testing/dist/fixtures/swarm-fixtures.js +0 -534
- package/v3/@swarmdo/testing/dist/fixtures/tasks.d.ts +0 -106
- package/v3/@swarmdo/testing/dist/fixtures/tasks.js +0 -229
- package/v3/@swarmdo/testing/dist/helpers/assertion-helpers.d.ts +0 -213
- package/v3/@swarmdo/testing/dist/helpers/assertion-helpers.js +0 -435
- package/v3/@swarmdo/testing/dist/helpers/assertions.d.ts +0 -135
- package/v3/@swarmdo/testing/dist/helpers/assertions.js +0 -217
- package/v3/@swarmdo/testing/dist/helpers/create-mock.d.ts +0 -96
- package/v3/@swarmdo/testing/dist/helpers/create-mock.js +0 -164
- package/v3/@swarmdo/testing/dist/helpers/index.d.ts +0 -14
- package/v3/@swarmdo/testing/dist/helpers/index.js +0 -22
- package/v3/@swarmdo/testing/dist/helpers/mock-factory.d.ts +0 -323
- package/v3/@swarmdo/testing/dist/helpers/mock-factory.js +0 -350
- package/v3/@swarmdo/testing/dist/helpers/setup-teardown.d.ts +0 -271
- package/v3/@swarmdo/testing/dist/helpers/setup-teardown.js +0 -446
- package/v3/@swarmdo/testing/dist/helpers/swarm-instance.d.ts +0 -142
- package/v3/@swarmdo/testing/dist/helpers/swarm-instance.js +0 -205
- package/v3/@swarmdo/testing/dist/helpers/test-application.d.ts +0 -190
- package/v3/@swarmdo/testing/dist/helpers/test-application.js +0 -138
- package/v3/@swarmdo/testing/dist/helpers/test-utils.d.ts +0 -274
- package/v3/@swarmdo/testing/dist/helpers/test-utils.js +0 -456
- package/v3/@swarmdo/testing/dist/index.d.ts +0 -42
- package/v3/@swarmdo/testing/dist/index.js +0 -66
- package/v3/@swarmdo/testing/dist/mocks/index.d.ts +0 -8
- package/v3/@swarmdo/testing/dist/mocks/index.js +0 -10
- package/v3/@swarmdo/testing/dist/mocks/mock-mcp-client.d.ts +0 -206
- package/v3/@swarmdo/testing/dist/mocks/mock-mcp-client.js +0 -575
- package/v3/@swarmdo/testing/dist/mocks/mock-services.d.ts +0 -287
- package/v3/@swarmdo/testing/dist/mocks/mock-services.js +0 -563
- package/v3/@swarmdo/testing/dist/regression/api-contract.d.ts +0 -109
- package/v3/@swarmdo/testing/dist/regression/api-contract.js +0 -374
- package/v3/@swarmdo/testing/dist/regression/index.d.ts +0 -18
- package/v3/@swarmdo/testing/dist/regression/index.js +0 -18
- package/v3/@swarmdo/testing/dist/regression/integration-regression.d.ts +0 -67
- package/v3/@swarmdo/testing/dist/regression/integration-regression.js +0 -334
- package/v3/@swarmdo/testing/dist/regression/performance-baseline.d.ts +0 -106
- package/v3/@swarmdo/testing/dist/regression/performance-baseline.js +0 -268
- package/v3/@swarmdo/testing/dist/regression/regression-runner.d.ts +0 -124
- package/v3/@swarmdo/testing/dist/regression/regression-runner.js +0 -227
- package/v3/@swarmdo/testing/dist/regression/security-regression.d.ts +0 -73
- package/v3/@swarmdo/testing/dist/regression/security-regression.js +0 -258
- package/v3/@swarmdo/testing/dist/setup.d.ts +0 -43
- package/v3/@swarmdo/testing/dist/setup.js +0 -91
- package/v3/@swarmdo/testing/dist/v2-compat/api-compat.test.d.ts +0 -10
- package/v3/@swarmdo/testing/dist/v2-compat/api-compat.test.js +0 -433
- package/v3/@swarmdo/testing/dist/v2-compat/cli-compat.test.d.ts +0 -10
- package/v3/@swarmdo/testing/dist/v2-compat/cli-compat.test.js +0 -352
- package/v3/@swarmdo/testing/dist/v2-compat/compatibility-validator.d.ts +0 -206
- package/v3/@swarmdo/testing/dist/v2-compat/compatibility-validator.js +0 -839
- package/v3/@swarmdo/testing/dist/v2-compat/hooks-compat.test.d.ts +0 -10
- package/v3/@swarmdo/testing/dist/v2-compat/hooks-compat.test.js +0 -428
- package/v3/@swarmdo/testing/dist/v2-compat/index.d.ts +0 -38
- package/v3/@swarmdo/testing/dist/v2-compat/index.js +0 -41
- package/v3/@swarmdo/testing/dist/v2-compat/mcp-compat.test.d.ts +0 -10
- package/v3/@swarmdo/testing/dist/v2-compat/mcp-compat.test.js +0 -419
- package/v3/@swarmdo/testing/dist/v2-compat/report-generator.d.ts +0 -34
- package/v3/@swarmdo/testing/dist/v2-compat/report-generator.js +0 -372
|
@@ -1,124 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Regression Test Runner
|
|
3
|
-
*
|
|
4
|
-
* Orchestrates all regression tests and generates comprehensive reports.
|
|
5
|
-
*
|
|
6
|
-
* @module v3/testing/regression/regression-runner
|
|
7
|
-
*/
|
|
8
|
-
import { type BaselineComparison } from './performance-baseline.js';
|
|
9
|
-
import { type SecurityReport } from './security-regression.js';
|
|
10
|
-
import { type ContractValidation } from './api-contract.js';
|
|
11
|
-
import { type IntegrationResult } from './integration-regression.js';
|
|
12
|
-
/**
|
|
13
|
-
* Regression test configuration
|
|
14
|
-
*/
|
|
15
|
-
export interface RegressionConfig {
|
|
16
|
-
/** Enable performance regression tests */
|
|
17
|
-
performanceTests: boolean;
|
|
18
|
-
/** Enable security regression tests */
|
|
19
|
-
securityTests: boolean;
|
|
20
|
-
/** Enable API contract tests */
|
|
21
|
-
contractTests: boolean;
|
|
22
|
-
/** Enable integration tests */
|
|
23
|
-
integrationTests: boolean;
|
|
24
|
-
/** Performance threshold (percentage allowed degradation) */
|
|
25
|
-
performanceThreshold: number;
|
|
26
|
-
/** Path to baseline data */
|
|
27
|
-
baselinePath: string;
|
|
28
|
-
/** Output path for reports */
|
|
29
|
-
reportPath: string;
|
|
30
|
-
/** Fail on any regression */
|
|
31
|
-
failOnRegression: boolean;
|
|
32
|
-
/** Verbose output */
|
|
33
|
-
verbose: boolean;
|
|
34
|
-
}
|
|
35
|
-
/**
|
|
36
|
-
* Individual test result
|
|
37
|
-
*/
|
|
38
|
-
export interface RegressionResult {
|
|
39
|
-
category: 'performance' | 'security' | 'contract' | 'integration';
|
|
40
|
-
name: string;
|
|
41
|
-
passed: boolean;
|
|
42
|
-
message: string;
|
|
43
|
-
details?: Record<string, unknown>;
|
|
44
|
-
duration: number;
|
|
45
|
-
}
|
|
46
|
-
/**
|
|
47
|
-
* Complete regression report
|
|
48
|
-
*/
|
|
49
|
-
export interface RegressionReport {
|
|
50
|
-
timestamp: Date;
|
|
51
|
-
duration: number;
|
|
52
|
-
passed: boolean;
|
|
53
|
-
totalTests: number;
|
|
54
|
-
passedTests: number;
|
|
55
|
-
failedTests: number;
|
|
56
|
-
skippedTests: number;
|
|
57
|
-
performance: {
|
|
58
|
-
tested: boolean;
|
|
59
|
-
results: BaselineComparison[];
|
|
60
|
-
regressions: string[];
|
|
61
|
-
};
|
|
62
|
-
security: {
|
|
63
|
-
tested: boolean;
|
|
64
|
-
report: SecurityReport | null;
|
|
65
|
-
newVulnerabilities: string[];
|
|
66
|
-
};
|
|
67
|
-
contract: {
|
|
68
|
-
tested: boolean;
|
|
69
|
-
results: ContractValidation[];
|
|
70
|
-
breakingChanges: string[];
|
|
71
|
-
};
|
|
72
|
-
integration: {
|
|
73
|
-
tested: boolean;
|
|
74
|
-
results: IntegrationResult[];
|
|
75
|
-
failures: string[];
|
|
76
|
-
};
|
|
77
|
-
summary: string;
|
|
78
|
-
}
|
|
79
|
-
/**
|
|
80
|
-
* Regression Test Runner
|
|
81
|
-
*
|
|
82
|
-
* Coordinates all regression testing activities.
|
|
83
|
-
*/
|
|
84
|
-
export declare class RegressionTestRunner {
|
|
85
|
-
private readonly config;
|
|
86
|
-
private readonly performanceBaseline;
|
|
87
|
-
private readonly securityChecker;
|
|
88
|
-
private readonly contractValidator;
|
|
89
|
-
private readonly integrationSuite;
|
|
90
|
-
constructor(config?: Partial<RegressionConfig>);
|
|
91
|
-
/**
|
|
92
|
-
* Run all configured regression tests
|
|
93
|
-
*/
|
|
94
|
-
runAll(): Promise<RegressionReport>;
|
|
95
|
-
/**
|
|
96
|
-
* Run only performance regression tests
|
|
97
|
-
*/
|
|
98
|
-
runPerformance(): Promise<BaselineComparison[]>;
|
|
99
|
-
/**
|
|
100
|
-
* Run only security regression tests
|
|
101
|
-
*/
|
|
102
|
-
runSecurity(): Promise<SecurityReport>;
|
|
103
|
-
/**
|
|
104
|
-
* Run only API contract tests
|
|
105
|
-
*/
|
|
106
|
-
runContracts(): Promise<ContractValidation[]>;
|
|
107
|
-
/**
|
|
108
|
-
* Run only integration tests
|
|
109
|
-
*/
|
|
110
|
-
runIntegration(): Promise<IntegrationResult[]>;
|
|
111
|
-
/**
|
|
112
|
-
* Update baselines with current values
|
|
113
|
-
*/
|
|
114
|
-
updateBaselines(): Promise<void>;
|
|
115
|
-
/**
|
|
116
|
-
* Generate human-readable summary
|
|
117
|
-
*/
|
|
118
|
-
private generateSummary;
|
|
119
|
-
/**
|
|
120
|
-
* Log message if verbose mode is enabled
|
|
121
|
-
*/
|
|
122
|
-
private log;
|
|
123
|
-
}
|
|
124
|
-
//# sourceMappingURL=regression-runner.d.ts.map
|
|
@@ -1,227 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Regression Test Runner
|
|
3
|
-
*
|
|
4
|
-
* Orchestrates all regression tests and generates comprehensive reports.
|
|
5
|
-
*
|
|
6
|
-
* @module v3/testing/regression/regression-runner
|
|
7
|
-
*/
|
|
8
|
-
import { PerformanceBaseline } from './performance-baseline.js';
|
|
9
|
-
import { SecurityRegressionChecker } from './security-regression.js';
|
|
10
|
-
import { APIContractValidator } from './api-contract.js';
|
|
11
|
-
import { IntegrationRegressionSuite } from './integration-regression.js';
|
|
12
|
-
/**
|
|
13
|
-
* Default configuration
|
|
14
|
-
*/
|
|
15
|
-
const DEFAULT_CONFIG = {
|
|
16
|
-
performanceTests: true,
|
|
17
|
-
securityTests: true,
|
|
18
|
-
contractTests: true,
|
|
19
|
-
integrationTests: true,
|
|
20
|
-
performanceThreshold: 10, // 10% degradation allowed
|
|
21
|
-
baselinePath: './.regression-baselines',
|
|
22
|
-
reportPath: './.regression-reports',
|
|
23
|
-
failOnRegression: true,
|
|
24
|
-
verbose: false,
|
|
25
|
-
};
|
|
26
|
-
/**
|
|
27
|
-
* Regression Test Runner
|
|
28
|
-
*
|
|
29
|
-
* Coordinates all regression testing activities.
|
|
30
|
-
*/
|
|
31
|
-
export class RegressionTestRunner {
|
|
32
|
-
config;
|
|
33
|
-
performanceBaseline;
|
|
34
|
-
securityChecker;
|
|
35
|
-
contractValidator;
|
|
36
|
-
integrationSuite;
|
|
37
|
-
constructor(config = {}) {
|
|
38
|
-
this.config = { ...DEFAULT_CONFIG, ...config };
|
|
39
|
-
this.performanceBaseline = new PerformanceBaseline(this.config);
|
|
40
|
-
this.securityChecker = new SecurityRegressionChecker();
|
|
41
|
-
this.contractValidator = new APIContractValidator();
|
|
42
|
-
this.integrationSuite = new IntegrationRegressionSuite();
|
|
43
|
-
}
|
|
44
|
-
/**
|
|
45
|
-
* Run all configured regression tests
|
|
46
|
-
*/
|
|
47
|
-
async runAll() {
|
|
48
|
-
const startTime = Date.now();
|
|
49
|
-
const results = [];
|
|
50
|
-
const report = {
|
|
51
|
-
timestamp: new Date(),
|
|
52
|
-
duration: 0,
|
|
53
|
-
passed: true,
|
|
54
|
-
totalTests: 0,
|
|
55
|
-
passedTests: 0,
|
|
56
|
-
failedTests: 0,
|
|
57
|
-
skippedTests: 0,
|
|
58
|
-
performance: { tested: false, results: [], regressions: [] },
|
|
59
|
-
security: { tested: false, report: null, newVulnerabilities: [] },
|
|
60
|
-
contract: { tested: false, results: [], breakingChanges: [] },
|
|
61
|
-
integration: { tested: false, results: [], failures: [] },
|
|
62
|
-
summary: '',
|
|
63
|
-
};
|
|
64
|
-
// Run performance tests
|
|
65
|
-
if (this.config.performanceTests) {
|
|
66
|
-
this.log('Running performance regression tests...');
|
|
67
|
-
report.performance.tested = true;
|
|
68
|
-
report.performance.results = await this.performanceBaseline.compare();
|
|
69
|
-
report.performance.regressions = report.performance.results
|
|
70
|
-
.filter((r) => r.regression && r.degradation > this.config.performanceThreshold)
|
|
71
|
-
.map((r) => `${r.metric}: ${r.degradation.toFixed(1)}% degradation`);
|
|
72
|
-
if (report.performance.regressions.length > 0) {
|
|
73
|
-
report.passed = false;
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
// Run security tests
|
|
77
|
-
if (this.config.securityTests) {
|
|
78
|
-
this.log('Running security regression tests...');
|
|
79
|
-
report.security.tested = true;
|
|
80
|
-
report.security.report = await this.securityChecker.check();
|
|
81
|
-
report.security.newVulnerabilities = report.security.report?.newIssues || [];
|
|
82
|
-
if (report.security.newVulnerabilities.length > 0) {
|
|
83
|
-
report.passed = false;
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
// Run contract tests
|
|
87
|
-
if (this.config.contractTests) {
|
|
88
|
-
this.log('Running API contract tests...');
|
|
89
|
-
report.contract.tested = true;
|
|
90
|
-
report.contract.results = await this.contractValidator.validateAll();
|
|
91
|
-
report.contract.breakingChanges = report.contract.results
|
|
92
|
-
.filter((r) => !r.valid && r.breaking)
|
|
93
|
-
.map((r) => `${r.endpoint}: ${r.message}`);
|
|
94
|
-
if (report.contract.breakingChanges.length > 0) {
|
|
95
|
-
report.passed = false;
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
// Run integration tests
|
|
99
|
-
if (this.config.integrationTests) {
|
|
100
|
-
this.log('Running integration regression tests...');
|
|
101
|
-
report.integration.tested = true;
|
|
102
|
-
report.integration.results = await this.integrationSuite.runAll();
|
|
103
|
-
report.integration.failures = report.integration.results
|
|
104
|
-
.filter((r) => !r.passed)
|
|
105
|
-
.map((r) => `${r.name}: ${r.error}`);
|
|
106
|
-
if (report.integration.failures.length > 0) {
|
|
107
|
-
report.passed = false;
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
// Calculate summary
|
|
111
|
-
report.duration = Date.now() - startTime;
|
|
112
|
-
report.totalTests =
|
|
113
|
-
report.performance.results.length +
|
|
114
|
-
(report.security.report?.checks.length || 0) +
|
|
115
|
-
report.contract.results.length +
|
|
116
|
-
report.integration.results.length;
|
|
117
|
-
report.passedTests = report.totalTests - (report.performance.regressions.length +
|
|
118
|
-
report.security.newVulnerabilities.length +
|
|
119
|
-
report.contract.breakingChanges.length +
|
|
120
|
-
report.integration.failures.length);
|
|
121
|
-
report.failedTests = report.totalTests - report.passedTests;
|
|
122
|
-
report.summary = this.generateSummary(report);
|
|
123
|
-
return report;
|
|
124
|
-
}
|
|
125
|
-
/**
|
|
126
|
-
* Run only performance regression tests
|
|
127
|
-
*/
|
|
128
|
-
async runPerformance() {
|
|
129
|
-
return this.performanceBaseline.compare();
|
|
130
|
-
}
|
|
131
|
-
/**
|
|
132
|
-
* Run only security regression tests
|
|
133
|
-
*/
|
|
134
|
-
async runSecurity() {
|
|
135
|
-
return this.securityChecker.check();
|
|
136
|
-
}
|
|
137
|
-
/**
|
|
138
|
-
* Run only API contract tests
|
|
139
|
-
*/
|
|
140
|
-
async runContracts() {
|
|
141
|
-
return this.contractValidator.validateAll();
|
|
142
|
-
}
|
|
143
|
-
/**
|
|
144
|
-
* Run only integration tests
|
|
145
|
-
*/
|
|
146
|
-
async runIntegration() {
|
|
147
|
-
return this.integrationSuite.runAll();
|
|
148
|
-
}
|
|
149
|
-
/**
|
|
150
|
-
* Update baselines with current values
|
|
151
|
-
*/
|
|
152
|
-
async updateBaselines() {
|
|
153
|
-
await this.performanceBaseline.captureBaseline();
|
|
154
|
-
await this.contractValidator.captureContracts();
|
|
155
|
-
this.log('Baselines updated successfully');
|
|
156
|
-
}
|
|
157
|
-
/**
|
|
158
|
-
* Generate human-readable summary
|
|
159
|
-
*/
|
|
160
|
-
generateSummary(report) {
|
|
161
|
-
const lines = [
|
|
162
|
-
'═══════════════════════════════════════════════════════════════',
|
|
163
|
-
' REGRESSION TEST REPORT ',
|
|
164
|
-
'═══════════════════════════════════════════════════════════════',
|
|
165
|
-
'',
|
|
166
|
-
`Status: ${report.passed ? '✅ PASSED' : '❌ FAILED'}`,
|
|
167
|
-
`Duration: ${report.duration}ms`,
|
|
168
|
-
`Tests: ${report.passedTests}/${report.totalTests} passed`,
|
|
169
|
-
'',
|
|
170
|
-
];
|
|
171
|
-
if (report.performance.tested) {
|
|
172
|
-
lines.push('📊 Performance:');
|
|
173
|
-
if (report.performance.regressions.length === 0) {
|
|
174
|
-
lines.push(' ✅ No performance regressions detected');
|
|
175
|
-
}
|
|
176
|
-
else {
|
|
177
|
-
lines.push(` ❌ ${report.performance.regressions.length} regressions:`);
|
|
178
|
-
report.performance.regressions.forEach((r) => lines.push(` - ${r}`));
|
|
179
|
-
}
|
|
180
|
-
lines.push('');
|
|
181
|
-
}
|
|
182
|
-
if (report.security.tested) {
|
|
183
|
-
lines.push('🔒 Security:');
|
|
184
|
-
if (report.security.newVulnerabilities.length === 0) {
|
|
185
|
-
lines.push(' ✅ No new security vulnerabilities');
|
|
186
|
-
}
|
|
187
|
-
else {
|
|
188
|
-
lines.push(` ❌ ${report.security.newVulnerabilities.length} new vulnerabilities:`);
|
|
189
|
-
report.security.newVulnerabilities.forEach((v) => lines.push(` - ${v}`));
|
|
190
|
-
}
|
|
191
|
-
lines.push('');
|
|
192
|
-
}
|
|
193
|
-
if (report.contract.tested) {
|
|
194
|
-
lines.push('📋 API Contracts:');
|
|
195
|
-
if (report.contract.breakingChanges.length === 0) {
|
|
196
|
-
lines.push(' ✅ No breaking changes detected');
|
|
197
|
-
}
|
|
198
|
-
else {
|
|
199
|
-
lines.push(` ❌ ${report.contract.breakingChanges.length} breaking changes:`);
|
|
200
|
-
report.contract.breakingChanges.forEach((c) => lines.push(` - ${c}`));
|
|
201
|
-
}
|
|
202
|
-
lines.push('');
|
|
203
|
-
}
|
|
204
|
-
if (report.integration.tested) {
|
|
205
|
-
lines.push('🔗 Integration:');
|
|
206
|
-
if (report.integration.failures.length === 0) {
|
|
207
|
-
lines.push(' ✅ All integration tests passed');
|
|
208
|
-
}
|
|
209
|
-
else {
|
|
210
|
-
lines.push(` ❌ ${report.integration.failures.length} failures:`);
|
|
211
|
-
report.integration.failures.forEach((f) => lines.push(` - ${f}`));
|
|
212
|
-
}
|
|
213
|
-
lines.push('');
|
|
214
|
-
}
|
|
215
|
-
lines.push('═══════════════════════════════════════════════════════════════');
|
|
216
|
-
return lines.join('\n');
|
|
217
|
-
}
|
|
218
|
-
/**
|
|
219
|
-
* Log message if verbose mode is enabled
|
|
220
|
-
*/
|
|
221
|
-
log(message) {
|
|
222
|
-
if (this.config.verbose) {
|
|
223
|
-
console.log(`[Regression] ${message}`);
|
|
224
|
-
}
|
|
225
|
-
}
|
|
226
|
-
}
|
|
227
|
-
//# sourceMappingURL=regression-runner.js.map
|
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Security Regression Checker
|
|
3
|
-
*
|
|
4
|
-
* Detects new security vulnerabilities and regressions.
|
|
5
|
-
*
|
|
6
|
-
* @module v3/testing/regression/security-regression
|
|
7
|
-
*/
|
|
8
|
-
/**
|
|
9
|
-
* Security check definition
|
|
10
|
-
*/
|
|
11
|
-
export interface SecurityCheck {
|
|
12
|
-
id: string;
|
|
13
|
-
name: string;
|
|
14
|
-
description: string;
|
|
15
|
-
severity: 'critical' | 'high' | 'medium' | 'low' | 'info';
|
|
16
|
-
passed: boolean;
|
|
17
|
-
message: string;
|
|
18
|
-
location?: string;
|
|
19
|
-
line?: number;
|
|
20
|
-
}
|
|
21
|
-
/**
|
|
22
|
-
* Security vulnerability
|
|
23
|
-
*/
|
|
24
|
-
export interface SecurityVulnerability {
|
|
25
|
-
id: string;
|
|
26
|
-
type: string;
|
|
27
|
-
severity: 'critical' | 'high' | 'medium' | 'low';
|
|
28
|
-
file: string;
|
|
29
|
-
line: number;
|
|
30
|
-
description: string;
|
|
31
|
-
recommendation: string;
|
|
32
|
-
cwe?: string;
|
|
33
|
-
}
|
|
34
|
-
/**
|
|
35
|
-
* Security report
|
|
36
|
-
*/
|
|
37
|
-
export interface SecurityReport {
|
|
38
|
-
timestamp: Date;
|
|
39
|
-
duration: number;
|
|
40
|
-
passed: boolean;
|
|
41
|
-
checks: SecurityCheck[];
|
|
42
|
-
vulnerabilities: SecurityVulnerability[];
|
|
43
|
-
newIssues: string[];
|
|
44
|
-
resolvedIssues: string[];
|
|
45
|
-
summary: {
|
|
46
|
-
critical: number;
|
|
47
|
-
high: number;
|
|
48
|
-
medium: number;
|
|
49
|
-
low: number;
|
|
50
|
-
};
|
|
51
|
-
}
|
|
52
|
-
/**
|
|
53
|
-
* Security Regression Checker
|
|
54
|
-
*
|
|
55
|
-
* Scans codebase for security vulnerabilities.
|
|
56
|
-
*/
|
|
57
|
-
export declare class SecurityRegressionChecker {
|
|
58
|
-
private readonly basePath;
|
|
59
|
-
constructor(basePath?: string);
|
|
60
|
-
/**
|
|
61
|
-
* Run full security check
|
|
62
|
-
*/
|
|
63
|
-
check(): Promise<SecurityReport>;
|
|
64
|
-
/**
|
|
65
|
-
* Find all scannable files
|
|
66
|
-
*/
|
|
67
|
-
private findFiles;
|
|
68
|
-
/**
|
|
69
|
-
* Scan a single file for vulnerabilities
|
|
70
|
-
*/
|
|
71
|
-
private scanFile;
|
|
72
|
-
}
|
|
73
|
-
//# sourceMappingURL=security-regression.d.ts.map
|
|
@@ -1,258 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Security Regression Checker
|
|
3
|
-
*
|
|
4
|
-
* Detects new security vulnerabilities and regressions.
|
|
5
|
-
*
|
|
6
|
-
* @module v3/testing/regression/security-regression
|
|
7
|
-
*/
|
|
8
|
-
import { readFile, readdir } from 'fs/promises';
|
|
9
|
-
import { join, extname } from 'path';
|
|
10
|
-
/**
|
|
11
|
-
* Security patterns to check
|
|
12
|
-
*/
|
|
13
|
-
const SECURITY_PATTERNS = [
|
|
14
|
-
{
|
|
15
|
-
id: 'sql-injection',
|
|
16
|
-
name: 'SQL Injection',
|
|
17
|
-
pattern: /\$\{[^}]*\}.*(?:SELECT|INSERT|UPDATE|DELETE|FROM|WHERE)/gi,
|
|
18
|
-
altPattern: /['"`]\s*\+\s*\w+.*(?:SELECT|INSERT|UPDATE|DELETE|FROM|WHERE)/gi,
|
|
19
|
-
severity: 'critical',
|
|
20
|
-
cwe: 'CWE-89',
|
|
21
|
-
description: 'Potential SQL injection vulnerability',
|
|
22
|
-
recommendation: 'Use parameterized queries instead of string concatenation',
|
|
23
|
-
},
|
|
24
|
-
{
|
|
25
|
-
id: 'command-injection',
|
|
26
|
-
name: 'Command Injection',
|
|
27
|
-
pattern: /exec\s*\(\s*['"`].*\$\{|exec\s*\(\s*\w+\s*\+/gi,
|
|
28
|
-
altPattern: /child_process.*exec.*\+|spawn.*shell:\s*true/gi,
|
|
29
|
-
severity: 'critical',
|
|
30
|
-
cwe: 'CWE-78',
|
|
31
|
-
description: 'Potential command injection vulnerability',
|
|
32
|
-
recommendation: 'Avoid shell execution with user input; use parameterized commands',
|
|
33
|
-
},
|
|
34
|
-
{
|
|
35
|
-
id: 'path-traversal',
|
|
36
|
-
name: 'Path Traversal',
|
|
37
|
-
pattern: /\.\.\//g,
|
|
38
|
-
altPattern: /path\.join.*req\.|path\.resolve.*req\./gi,
|
|
39
|
-
severity: 'high',
|
|
40
|
-
cwe: 'CWE-22',
|
|
41
|
-
description: 'Potential path traversal vulnerability',
|
|
42
|
-
recommendation: 'Validate and sanitize file paths; use path.normalize()',
|
|
43
|
-
},
|
|
44
|
-
{
|
|
45
|
-
id: 'weak-random',
|
|
46
|
-
name: 'Weak Random',
|
|
47
|
-
pattern: /Math\.random\(\)/g,
|
|
48
|
-
severity: 'medium',
|
|
49
|
-
cwe: 'CWE-330',
|
|
50
|
-
description: 'Use of weak random number generator',
|
|
51
|
-
recommendation: 'Use crypto.randomBytes() or crypto.randomUUID() for security-sensitive operations',
|
|
52
|
-
},
|
|
53
|
-
{
|
|
54
|
-
id: 'hardcoded-secret',
|
|
55
|
-
name: 'Hardcoded Secret',
|
|
56
|
-
pattern: /(?:password|secret|api_key|apikey|token)\s*[=:]\s*['"][^'"]{8,}/gi,
|
|
57
|
-
severity: 'high',
|
|
58
|
-
cwe: 'CWE-798',
|
|
59
|
-
description: 'Potential hardcoded secret or credential',
|
|
60
|
-
recommendation: 'Use environment variables or secure vault for secrets',
|
|
61
|
-
},
|
|
62
|
-
{
|
|
63
|
-
id: 'cors-wildcard',
|
|
64
|
-
name: 'CORS Wildcard',
|
|
65
|
-
pattern: /origin:\s*['"]?\*/gi,
|
|
66
|
-
altPattern: /Access-Control-Allow-Origin.*\*/gi,
|
|
67
|
-
severity: 'medium',
|
|
68
|
-
cwe: 'CWE-942',
|
|
69
|
-
description: 'Permissive CORS configuration',
|
|
70
|
-
recommendation: 'Specify explicit allowed origins instead of wildcard',
|
|
71
|
-
},
|
|
72
|
-
{
|
|
73
|
-
id: 'eval-usage',
|
|
74
|
-
name: 'Eval Usage',
|
|
75
|
-
pattern: /\beval\s*\(/gi,
|
|
76
|
-
altPattern: /new\s+Function\s*\(/gi,
|
|
77
|
-
severity: 'high',
|
|
78
|
-
cwe: 'CWE-95',
|
|
79
|
-
description: 'Use of eval() or dynamic code execution',
|
|
80
|
-
recommendation: 'Avoid eval(); use safer alternatives like JSON.parse()',
|
|
81
|
-
},
|
|
82
|
-
{
|
|
83
|
-
id: 'unsafe-regex',
|
|
84
|
-
name: 'Unsafe Regex',
|
|
85
|
-
pattern: /new\s+RegExp\s*\(\s*\w+\s*\)/gi,
|
|
86
|
-
severity: 'medium',
|
|
87
|
-
cwe: 'CWE-1333',
|
|
88
|
-
description: 'Potentially unsafe dynamic regex construction',
|
|
89
|
-
recommendation: 'Validate and escape regex input; consider using regex-safe libraries',
|
|
90
|
-
},
|
|
91
|
-
{
|
|
92
|
-
id: 'missing-csrf',
|
|
93
|
-
name: 'Missing CSRF Protection',
|
|
94
|
-
pattern: /router\.(?:post|put|patch|delete)\s*\([^)]*\)/gi,
|
|
95
|
-
severity: 'medium',
|
|
96
|
-
cwe: 'CWE-352',
|
|
97
|
-
description: 'Endpoint may lack CSRF protection',
|
|
98
|
-
recommendation: 'Implement CSRF tokens for state-changing operations',
|
|
99
|
-
},
|
|
100
|
-
{
|
|
101
|
-
id: 'insecure-http',
|
|
102
|
-
name: 'Insecure HTTP',
|
|
103
|
-
pattern: /http:\/\/(?!localhost|127\.0\.0\.1)/gi,
|
|
104
|
-
severity: 'low',
|
|
105
|
-
cwe: 'CWE-319',
|
|
106
|
-
description: 'Use of insecure HTTP protocol',
|
|
107
|
-
recommendation: 'Use HTTPS for all external communications',
|
|
108
|
-
},
|
|
109
|
-
];
|
|
110
|
-
/**
|
|
111
|
-
* File extensions to scan
|
|
112
|
-
*/
|
|
113
|
-
const SCANNABLE_EXTENSIONS = ['.ts', '.tsx', '.js', '.jsx', '.mjs', '.cjs'];
|
|
114
|
-
/**
|
|
115
|
-
* Directories to exclude
|
|
116
|
-
*/
|
|
117
|
-
const EXCLUDED_DIRS = ['node_modules', 'dist', 'build', '.git', 'coverage', '__tests__'];
|
|
118
|
-
/**
|
|
119
|
-
* Security Regression Checker
|
|
120
|
-
*
|
|
121
|
-
* Scans codebase for security vulnerabilities.
|
|
122
|
-
*/
|
|
123
|
-
export class SecurityRegressionChecker {
|
|
124
|
-
basePath;
|
|
125
|
-
constructor(basePath = process.cwd()) {
|
|
126
|
-
this.basePath = basePath;
|
|
127
|
-
}
|
|
128
|
-
/**
|
|
129
|
-
* Run full security check
|
|
130
|
-
*/
|
|
131
|
-
async check() {
|
|
132
|
-
const startTime = Date.now();
|
|
133
|
-
const vulnerabilities = [];
|
|
134
|
-
const checks = [];
|
|
135
|
-
// Scan all TypeScript/JavaScript files
|
|
136
|
-
const files = await this.findFiles(join(this.basePath, 'v3'));
|
|
137
|
-
for (const file of files) {
|
|
138
|
-
const fileVulns = await this.scanFile(file);
|
|
139
|
-
vulnerabilities.push(...fileVulns);
|
|
140
|
-
}
|
|
141
|
-
// Create checks from patterns
|
|
142
|
-
for (const pattern of SECURITY_PATTERNS) {
|
|
143
|
-
const patternVulns = vulnerabilities.filter((v) => v.type === pattern.id);
|
|
144
|
-
checks.push({
|
|
145
|
-
id: pattern.id,
|
|
146
|
-
name: pattern.name,
|
|
147
|
-
description: pattern.description,
|
|
148
|
-
severity: pattern.severity,
|
|
149
|
-
passed: patternVulns.length === 0,
|
|
150
|
-
message: patternVulns.length === 0
|
|
151
|
-
? `No ${pattern.name} vulnerabilities found`
|
|
152
|
-
: `Found ${patternVulns.length} potential ${pattern.name} issues`,
|
|
153
|
-
});
|
|
154
|
-
}
|
|
155
|
-
// Calculate summary
|
|
156
|
-
const summary = {
|
|
157
|
-
critical: vulnerabilities.filter((v) => v.severity === 'critical').length,
|
|
158
|
-
high: vulnerabilities.filter((v) => v.severity === 'high').length,
|
|
159
|
-
medium: vulnerabilities.filter((v) => v.severity === 'medium').length,
|
|
160
|
-
low: vulnerabilities.filter((v) => v.severity === 'low').length,
|
|
161
|
-
};
|
|
162
|
-
const report = {
|
|
163
|
-
timestamp: new Date(),
|
|
164
|
-
duration: Date.now() - startTime,
|
|
165
|
-
passed: summary.critical === 0 && summary.high === 0,
|
|
166
|
-
checks,
|
|
167
|
-
vulnerabilities,
|
|
168
|
-
newIssues: vulnerabilities.map((v) => `${v.severity.toUpperCase()}: ${v.type} in ${v.file}:${v.line}`),
|
|
169
|
-
resolvedIssues: [],
|
|
170
|
-
summary,
|
|
171
|
-
};
|
|
172
|
-
return report;
|
|
173
|
-
}
|
|
174
|
-
/**
|
|
175
|
-
* Find all scannable files
|
|
176
|
-
*/
|
|
177
|
-
async findFiles(dir) {
|
|
178
|
-
const files = [];
|
|
179
|
-
try {
|
|
180
|
-
const entries = await readdir(dir, { withFileTypes: true });
|
|
181
|
-
for (const entry of entries) {
|
|
182
|
-
const fullPath = join(dir, entry.name);
|
|
183
|
-
if (entry.isDirectory()) {
|
|
184
|
-
if (!EXCLUDED_DIRS.includes(entry.name)) {
|
|
185
|
-
const subFiles = await this.findFiles(fullPath);
|
|
186
|
-
files.push(...subFiles);
|
|
187
|
-
}
|
|
188
|
-
}
|
|
189
|
-
else if (entry.isFile()) {
|
|
190
|
-
if (SCANNABLE_EXTENSIONS.includes(extname(entry.name))) {
|
|
191
|
-
files.push(fullPath);
|
|
192
|
-
}
|
|
193
|
-
}
|
|
194
|
-
}
|
|
195
|
-
}
|
|
196
|
-
catch {
|
|
197
|
-
// Directory doesn't exist or not accessible
|
|
198
|
-
}
|
|
199
|
-
return files;
|
|
200
|
-
}
|
|
201
|
-
/**
|
|
202
|
-
* Scan a single file for vulnerabilities
|
|
203
|
-
*/
|
|
204
|
-
async scanFile(filePath) {
|
|
205
|
-
const vulnerabilities = [];
|
|
206
|
-
try {
|
|
207
|
-
const content = await readFile(filePath, 'utf-8');
|
|
208
|
-
const lines = content.split('\n');
|
|
209
|
-
for (const pattern of SECURITY_PATTERNS) {
|
|
210
|
-
// Skip weak-random checks in test files
|
|
211
|
-
if (pattern.id === 'weak-random' && filePath.includes('test')) {
|
|
212
|
-
continue;
|
|
213
|
-
}
|
|
214
|
-
for (let i = 0; i < lines.length; i++) {
|
|
215
|
-
const line = lines[i];
|
|
216
|
-
// Check main pattern
|
|
217
|
-
if (pattern.pattern.test(line)) {
|
|
218
|
-
// Reset lastIndex for global patterns
|
|
219
|
-
pattern.pattern.lastIndex = 0;
|
|
220
|
-
vulnerabilities.push({
|
|
221
|
-
id: `${pattern.id}-${filePath}-${i + 1}`,
|
|
222
|
-
type: pattern.id,
|
|
223
|
-
severity: pattern.severity,
|
|
224
|
-
file: filePath.replace(this.basePath + '/', ''),
|
|
225
|
-
line: i + 1,
|
|
226
|
-
description: pattern.description,
|
|
227
|
-
recommendation: pattern.recommendation,
|
|
228
|
-
cwe: pattern.cwe,
|
|
229
|
-
});
|
|
230
|
-
}
|
|
231
|
-
// Check alternate pattern if exists
|
|
232
|
-
if (pattern.altPattern && pattern.altPattern.test(line)) {
|
|
233
|
-
pattern.altPattern.lastIndex = 0;
|
|
234
|
-
// Avoid duplicates
|
|
235
|
-
const existingVuln = vulnerabilities.find((v) => v.type === pattern.id && v.line === i + 1 && v.file === filePath.replace(this.basePath + '/', ''));
|
|
236
|
-
if (!existingVuln) {
|
|
237
|
-
vulnerabilities.push({
|
|
238
|
-
id: `${pattern.id}-${filePath}-${i + 1}`,
|
|
239
|
-
type: pattern.id,
|
|
240
|
-
severity: pattern.severity,
|
|
241
|
-
file: filePath.replace(this.basePath + '/', ''),
|
|
242
|
-
line: i + 1,
|
|
243
|
-
description: pattern.description,
|
|
244
|
-
recommendation: pattern.recommendation,
|
|
245
|
-
cwe: pattern.cwe,
|
|
246
|
-
});
|
|
247
|
-
}
|
|
248
|
-
}
|
|
249
|
-
}
|
|
250
|
-
}
|
|
251
|
-
}
|
|
252
|
-
catch {
|
|
253
|
-
// File not readable
|
|
254
|
-
}
|
|
255
|
-
return vulnerabilities;
|
|
256
|
-
}
|
|
257
|
-
}
|
|
258
|
-
//# sourceMappingURL=security-regression.js.map
|