@develler/remediation-agent 1.0.2
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/commands/connect.d.ts +17 -0
- package/dist/commands/connect.d.ts.map +1 -0
- package/dist/commands/connect.js +138 -0
- package/dist/commands/connect.js.map +1 -0
- package/dist/contracts/agentConnection.d.ts +28 -0
- package/dist/contracts/agentConnection.d.ts.map +1 -0
- package/dist/contracts/agentConnection.js +3 -0
- package/dist/contracts/agentConnection.js.map +1 -0
- package/dist/contracts/lifecycleInterceptor.d.ts +22 -0
- package/dist/contracts/lifecycleInterceptor.d.ts.map +1 -0
- package/dist/contracts/lifecycleInterceptor.js +3 -0
- package/dist/contracts/lifecycleInterceptor.js.map +1 -0
- package/dist/controllers/extractionController.d.ts +12 -0
- package/dist/controllers/extractionController.d.ts.map +1 -0
- package/dist/controllers/extractionController.js +91 -0
- package/dist/controllers/extractionController.js.map +1 -0
- package/dist/controllers/webhookController.d.ts +16 -0
- package/dist/controllers/webhookController.d.ts.map +1 -0
- package/dist/controllers/webhookController.js +74 -0
- package/dist/controllers/webhookController.js.map +1 -0
- package/dist/exceptions/ReplayError.d.ts +4 -0
- package/dist/exceptions/ReplayError.d.ts.map +1 -0
- package/dist/exceptions/ReplayError.js +11 -0
- package/dist/exceptions/ReplayError.js.map +1 -0
- package/dist/exceptions/SignatureError.d.ts +4 -0
- package/dist/exceptions/SignatureError.d.ts.map +1 -0
- package/dist/exceptions/SignatureError.js +11 -0
- package/dist/exceptions/SignatureError.js.map +1 -0
- package/dist/index.d.ts +48 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +98 -0
- package/dist/index.js.map +1 -0
- package/dist/logger.d.ts +7 -0
- package/dist/logger.d.ts.map +1 -0
- package/dist/logger.js +26 -0
- package/dist/logger.js.map +1 -0
- package/dist/middleware/remediationInterceptor.d.ts +42 -0
- package/dist/middleware/remediationInterceptor.d.ts.map +1 -0
- package/dist/middleware/remediationInterceptor.js +144 -0
- package/dist/middleware/remediationInterceptor.js.map +1 -0
- package/dist/services/AgentConnectionService.d.ts +37 -0
- package/dist/services/AgentConnectionService.d.ts.map +1 -0
- package/dist/services/AgentConnectionService.js +186 -0
- package/dist/services/AgentConnectionService.js.map +1 -0
- package/dist/services/AstExtractorService.d.ts +18 -0
- package/dist/services/AstExtractorService.d.ts.map +1 -0
- package/dist/services/AstExtractorService.js +166 -0
- package/dist/services/AstExtractorService.js.map +1 -0
- package/dist/services/CircuitBreakerService.d.ts +29 -0
- package/dist/services/CircuitBreakerService.d.ts.map +1 -0
- package/dist/services/CircuitBreakerService.js +93 -0
- package/dist/services/CircuitBreakerService.js.map +1 -0
- package/dist/services/InstructionCacheService.d.ts +28 -0
- package/dist/services/InstructionCacheService.d.ts.map +1 -0
- package/dist/services/InstructionCacheService.js +79 -0
- package/dist/services/InstructionCacheService.js.map +1 -0
- package/dist/services/MaskingEngine.d.ts +27 -0
- package/dist/services/MaskingEngine.d.ts.map +1 -0
- package/dist/services/MaskingEngine.js +88 -0
- package/dist/services/MaskingEngine.js.map +1 -0
- package/dist/types/extraction.d.ts +27 -0
- package/dist/types/extraction.d.ts.map +1 -0
- package/dist/types/extraction.js +16 -0
- package/dist/types/extraction.js.map +1 -0
- package/dist/types/instructions.d.ts +58 -0
- package/dist/types/instructions.d.ts.map +1 -0
- package/dist/types/instructions.js +203 -0
- package/dist/types/instructions.js.map +1 -0
- package/dist/types/wireProtocol.d.ts +117 -0
- package/dist/types/wireProtocol.d.ts.map +1 -0
- package/dist/types/wireProtocol.js +8 -0
- package/dist/types/wireProtocol.js.map +1 -0
- package/package.json +46 -0
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* npx remediation-connect
|
|
4
|
+
*
|
|
5
|
+
* Performs the initial handshake with the SaaS, stores the returned
|
|
6
|
+
* client_id, raw token, and channel configuration in
|
|
7
|
+
* .remediation-connection.json at the project root.
|
|
8
|
+
*
|
|
9
|
+
* Safe to re-run — overwrites any existing connection file.
|
|
10
|
+
*
|
|
11
|
+
* Usage:
|
|
12
|
+
* REMEDIATION_SAAS_URL=https://saas.example.com \
|
|
13
|
+
* REMEDIATION_CONNECTION_KEY=<key from dashboard> \
|
|
14
|
+
* npx remediation-connect
|
|
15
|
+
*/
|
|
16
|
+
export {};
|
|
17
|
+
//# sourceMappingURL=connect.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"connect.d.ts","sourceRoot":"","sources":["../../src/commands/connect.ts"],"names":[],"mappings":";AACA;;;;;;;;;;;;;GAaG"}
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";
|
|
3
|
+
/**
|
|
4
|
+
* npx remediation-connect
|
|
5
|
+
*
|
|
6
|
+
* Performs the initial handshake with the SaaS, stores the returned
|
|
7
|
+
* client_id, raw token, and channel configuration in
|
|
8
|
+
* .remediation-connection.json at the project root.
|
|
9
|
+
*
|
|
10
|
+
* Safe to re-run — overwrites any existing connection file.
|
|
11
|
+
*
|
|
12
|
+
* Usage:
|
|
13
|
+
* REMEDIATION_SAAS_URL=https://saas.example.com \
|
|
14
|
+
* REMEDIATION_CONNECTION_KEY=<key from dashboard> \
|
|
15
|
+
* npx remediation-connect
|
|
16
|
+
*/
|
|
17
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
18
|
+
if (k2 === undefined) k2 = k;
|
|
19
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
20
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
21
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
22
|
+
}
|
|
23
|
+
Object.defineProperty(o, k2, desc);
|
|
24
|
+
}) : (function(o, m, k, k2) {
|
|
25
|
+
if (k2 === undefined) k2 = k;
|
|
26
|
+
o[k2] = m[k];
|
|
27
|
+
}));
|
|
28
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
29
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
30
|
+
}) : function(o, v) {
|
|
31
|
+
o["default"] = v;
|
|
32
|
+
});
|
|
33
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
34
|
+
var ownKeys = function(o) {
|
|
35
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
36
|
+
var ar = [];
|
|
37
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
38
|
+
return ar;
|
|
39
|
+
};
|
|
40
|
+
return ownKeys(o);
|
|
41
|
+
};
|
|
42
|
+
return function (mod) {
|
|
43
|
+
if (mod && mod.__esModule) return mod;
|
|
44
|
+
var result = {};
|
|
45
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
46
|
+
__setModuleDefault(result, mod);
|
|
47
|
+
return result;
|
|
48
|
+
};
|
|
49
|
+
})();
|
|
50
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
51
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
52
|
+
};
|
|
53
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
54
|
+
const axios_1 = __importDefault(require("axios"));
|
|
55
|
+
const fs_1 = require("fs");
|
|
56
|
+
const path_1 = require("path");
|
|
57
|
+
const CONNECTION_FILE = (0, path_1.join)(process.cwd(), '.remediation-connection.json');
|
|
58
|
+
async function main() {
|
|
59
|
+
const saasUrl = (process.env['REMEDIATION_SAAS_URL'] ?? '').replace(/\/+$/, '');
|
|
60
|
+
const connectionKey = process.env['REMEDIATION_CONNECTION_KEY'] ?? '';
|
|
61
|
+
const webhookUrl = process.env['REMEDIATION_WEBHOOK_URL'] ?? null;
|
|
62
|
+
if (!saasUrl || !connectionKey) {
|
|
63
|
+
console.error('ERROR: REMEDIATION_SAAS_URL and REMEDIATION_CONNECTION_KEY must both be set.');
|
|
64
|
+
process.exit(1);
|
|
65
|
+
}
|
|
66
|
+
console.log(`Connecting to: ${saasUrl}`);
|
|
67
|
+
const payload = {
|
|
68
|
+
connection_key: connectionKey,
|
|
69
|
+
site_url: process.env['APP_URL'] ?? `http://localhost:${process.env['PORT'] ?? 3000}`,
|
|
70
|
+
site_name: process.env['APP_NAME'] ?? null,
|
|
71
|
+
language_runtime: 'node',
|
|
72
|
+
runtime_version: process.version,
|
|
73
|
+
framework: process.env['REMEDIATION_FRAMEWORK'] ?? 'express',
|
|
74
|
+
framework_version: process.env['REMEDIATION_FRAMEWORK_VERSION'] ?? null,
|
|
75
|
+
agent_version: process.env['npm_package_version'] ?? null,
|
|
76
|
+
environment: (process.env['NODE_ENV'] ?? 'production'),
|
|
77
|
+
capabilities: {
|
|
78
|
+
mode_a_ast: false,
|
|
79
|
+
mode_b_interceptor: true,
|
|
80
|
+
redis_available: await checkRedis(),
|
|
81
|
+
git_access: false,
|
|
82
|
+
},
|
|
83
|
+
webhook_url: webhookUrl,
|
|
84
|
+
};
|
|
85
|
+
let response;
|
|
86
|
+
try {
|
|
87
|
+
const result = await axios_1.default.post(`${saasUrl}/api/remediation/v1/handshake`, payload, { timeout: 15000 });
|
|
88
|
+
response = result.data;
|
|
89
|
+
}
|
|
90
|
+
catch (err) {
|
|
91
|
+
const message = axios_1.default.isAxiosError(err)
|
|
92
|
+
? `HTTP ${err.response?.status ?? 'timeout'}: ${JSON.stringify(err.response?.data)}`
|
|
93
|
+
: String(err);
|
|
94
|
+
console.error(`ERROR: Connection request failed — ${message}`);
|
|
95
|
+
process.exit(1);
|
|
96
|
+
}
|
|
97
|
+
if (response.status !== 'accepted') {
|
|
98
|
+
console.error('ERROR: SaaS rejected the handshake. Check your REMEDIATION_CONNECTION_KEY.');
|
|
99
|
+
process.exit(1);
|
|
100
|
+
}
|
|
101
|
+
const config = {
|
|
102
|
+
client_id: response.client_id,
|
|
103
|
+
token: response.token,
|
|
104
|
+
saas_url: saasUrl,
|
|
105
|
+
channel_type: response.instruction_channel.type,
|
|
106
|
+
poll_url: response.instruction_channel.poll_url,
|
|
107
|
+
poll_interval_seconds: response.instruction_channel.poll_interval_seconds,
|
|
108
|
+
connected_at: new Date().toISOString(),
|
|
109
|
+
};
|
|
110
|
+
(0, fs_1.writeFileSync)(CONNECTION_FILE, JSON.stringify(config, null, 2), { mode: 0o600 });
|
|
111
|
+
console.log(`Connected successfully.`);
|
|
112
|
+
console.log(` client_id : ${config.client_id}`);
|
|
113
|
+
console.log(` channel : ${config.channel_type}`);
|
|
114
|
+
console.log(` config : ${CONNECTION_FILE}`);
|
|
115
|
+
console.log('');
|
|
116
|
+
console.log('Add .remediation-connection.json to your .gitignore.');
|
|
117
|
+
}
|
|
118
|
+
async function checkRedis() {
|
|
119
|
+
const redisUrl = process.env['REDIS_URL'] ?? process.env['REMEDIATION_REDIS_URL'] ?? null;
|
|
120
|
+
if (!redisUrl)
|
|
121
|
+
return false;
|
|
122
|
+
try {
|
|
123
|
+
const { default: Redis } = await Promise.resolve().then(() => __importStar(require('ioredis')));
|
|
124
|
+
const client = new Redis(redisUrl, { lazyConnect: true, connectTimeout: 3000 });
|
|
125
|
+
await client.connect();
|
|
126
|
+
await client.ping();
|
|
127
|
+
await client.disconnect();
|
|
128
|
+
return true;
|
|
129
|
+
}
|
|
130
|
+
catch {
|
|
131
|
+
return false;
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
main().catch((err) => {
|
|
135
|
+
console.error('Unexpected error:', err);
|
|
136
|
+
process.exit(1);
|
|
137
|
+
});
|
|
138
|
+
//# sourceMappingURL=connect.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"connect.js","sourceRoot":"","sources":["../../src/commands/connect.ts"],"names":[],"mappings":";;AACA;;;;;;;;;;;;;GAaG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,kDAA0B;A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AC,MAAM,CAAC;QACP,OAAO,KAAK,CAAC;IACf,CAAC;AACH,CAAC;AAED,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC,GAAG,EAAE,EAAE;IACnB,OAAO,CAAC,KAAK,CAAC,mBAAmB,EAAE,GAAG,CAAC,CAAC;IACxC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { WireEnvelope } from '../types/wireProtocol.js';
|
|
2
|
+
import type { InstructionCollection, RuntimeInstruction } from '../types/instructions.js';
|
|
3
|
+
export interface AgentConnectionInterface {
|
|
4
|
+
/**
|
|
5
|
+
* Verify HMAC-SHA256 envelope signature plus replay-attack guards.
|
|
6
|
+
* Uses crypto.timingSafeEqual. Throws SignatureError | ReplayError on failure.
|
|
7
|
+
*/
|
|
8
|
+
verifyEnvelope(raw: unknown): Promise<WireEnvelope>;
|
|
9
|
+
/**
|
|
10
|
+
* Persist a verified RuntimeInstruction to the Redis instruction cache.
|
|
11
|
+
* TTL derived from instruction.expiresAt - Date.now()/1000.
|
|
12
|
+
*/
|
|
13
|
+
cacheInstruction(instruction: RuntimeInstruction): Promise<void>;
|
|
14
|
+
/**
|
|
15
|
+
* Return all currently active (non-expired) RuntimeInstructions from cache.
|
|
16
|
+
* Must complete in <1ms on a local Redis socket. Never does I/O to SaaS.
|
|
17
|
+
*/
|
|
18
|
+
getActiveInstructions(): Promise<InstructionCollection>;
|
|
19
|
+
/**
|
|
20
|
+
* POST acknowledgement to the SaaS for a delivered instruction.
|
|
21
|
+
*/
|
|
22
|
+
acknowledgeInstruction(instructionId: string): Promise<void>;
|
|
23
|
+
/**
|
|
24
|
+
* Poll the SaaS pending-instructions endpoint (used when channel = 'polling').
|
|
25
|
+
*/
|
|
26
|
+
pollPendingInstructions(): Promise<InstructionCollection>;
|
|
27
|
+
}
|
|
28
|
+
//# sourceMappingURL=agentConnection.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agentConnection.d.ts","sourceRoot":"","sources":["../../src/contracts/agentConnection.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAC7D,OAAO,KAAK,EAAE,qBAAqB,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAE1F,MAAM,WAAW,wBAAwB;IACvC;;;OAGG;IACH,cAAc,CAAC,GAAG,EAAE,OAAO,GAAG,OAAO,CAAC,YAAY,CAAC,CAAC;IAEpD;;;OAGG;IACH,gBAAgB,CAAC,WAAW,EAAE,kBAAkB,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAEjE;;;OAGG;IACH,qBAAqB,IAAI,OAAO,CAAC,qBAAqB,CAAC,CAAC;IAExD;;OAEG;IACH,sBAAsB,CAAC,aAAa,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAE7D;;OAEG;IACH,uBAAuB,IAAI,OAAO,CAAC,qBAAqB,CAAC,CAAC;CAC3D"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agentConnection.js","sourceRoot":"","sources":["../../src/contracts/agentConnection.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { Request, Response } from 'express';
|
|
2
|
+
import type { MaskRule } from '../types/instructions.js';
|
|
3
|
+
export interface LifecycleInterceptorInterface {
|
|
4
|
+
/**
|
|
5
|
+
* Hook into the inbound HTTP request.
|
|
6
|
+
* Returns true if the request should continue, false if it was blocked.
|
|
7
|
+
* Must never throw.
|
|
8
|
+
*/
|
|
9
|
+
interceptRequest(req: Request, res: Response): Promise<boolean>;
|
|
10
|
+
/**
|
|
11
|
+
* Apply PII masking rules to a data structure.
|
|
12
|
+
* Operates on a deep clone — never mutates the original.
|
|
13
|
+
*/
|
|
14
|
+
applyMaskingRules(data: unknown, maskRules: MaskRule[]): unknown;
|
|
15
|
+
/** Returns true when the circuit breaker is open (all interception bypassed). */
|
|
16
|
+
isCircuitBreakerOpen(): Promise<boolean>;
|
|
17
|
+
/** Trip the circuit breaker on Redis failure or unhandled exception. */
|
|
18
|
+
tripCircuitBreaker(reason: Error): Promise<void>;
|
|
19
|
+
/** Reset the circuit breaker manually. Also auto-resets via Redis TTL. */
|
|
20
|
+
resetCircuitBreaker(): Promise<void>;
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=lifecycleInterceptor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lifecycleInterceptor.d.ts","sourceRoot":"","sources":["../../src/contracts/lifecycleInterceptor.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AACjD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AAEzD,MAAM,WAAW,6BAA6B;IAC5C;;;;OAIG;IACH,gBAAgB,CAAC,GAAG,EAAE,OAAO,EAAE,GAAG,EAAE,QAAQ,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;IAEhE;;;OAGG;IACH,iBAAiB,CAAC,IAAI,EAAE,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,GAAG,OAAO,CAAC;IAEjE,iFAAiF;IACjF,oBAAoB,IAAI,OAAO,CAAC,OAAO,CAAC,CAAC;IAEzC,wEAAwE;IACxE,kBAAkB,CAAC,MAAM,EAAE,KAAK,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAEjD,0EAA0E;IAC1E,mBAAmB,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CACtC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lifecycleInterceptor.js","sourceRoot":"","sources":["../../src/contracts/lifecycleInterceptor.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { ConnectionConfig } from '../types/wireProtocol.js';
|
|
2
|
+
/**
|
|
3
|
+
* Handles extraction_request envelopes dispatched from the SaaS.
|
|
4
|
+
*
|
|
5
|
+
* Runs AST extraction for each target synchronously within the webhook
|
|
6
|
+
* handler (Express async), then POSTs the results back to the SaaS callback URL.
|
|
7
|
+
*
|
|
8
|
+
* For large extraction jobs, this can be deferred to a worker thread or
|
|
9
|
+
* a background queue — the callback pattern means the SaaS is not blocked.
|
|
10
|
+
*/
|
|
11
|
+
export declare function handleExtractionRequest(payload: Record<string, unknown>, config: ConnectionConfig): Promise<void>;
|
|
12
|
+
//# sourceMappingURL=extractionController.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"extractionController.d.ts","sourceRoot":"","sources":["../../src/controllers/extractionController.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAGjE;;;;;;;;GAQG;AACH,wBAAsB,uBAAuB,CAC3C,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAChC,MAAM,EAAE,gBAAgB,GACvB,OAAO,CAAC,IAAI,CAAC,CAgDf"}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
36
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
37
|
+
};
|
|
38
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
+
exports.handleExtractionRequest = handleExtractionRequest;
|
|
40
|
+
const axios_1 = __importDefault(require("axios"));
|
|
41
|
+
const path = __importStar(require("path"));
|
|
42
|
+
const AstExtractorService_js_1 = require("../services/AstExtractorService.js");
|
|
43
|
+
const extraction_js_1 = require("../types/extraction.js");
|
|
44
|
+
const logger_js_1 = require("../logger.js");
|
|
45
|
+
/**
|
|
46
|
+
* Handles extraction_request envelopes dispatched from the SaaS.
|
|
47
|
+
*
|
|
48
|
+
* Runs AST extraction for each target synchronously within the webhook
|
|
49
|
+
* handler (Express async), then POSTs the results back to the SaaS callback URL.
|
|
50
|
+
*
|
|
51
|
+
* For large extraction jobs, this can be deferred to a worker thread or
|
|
52
|
+
* a background queue — the callback pattern means the SaaS is not blocked.
|
|
53
|
+
*/
|
|
54
|
+
async function handleExtractionRequest(payload, config) {
|
|
55
|
+
const request = (0, extraction_js_1.parseExtractionRequestPayload)(payload);
|
|
56
|
+
const extractor = new AstExtractorService_js_1.AstExtractorService();
|
|
57
|
+
const results = [];
|
|
58
|
+
for (const target of request.targets) {
|
|
59
|
+
// Resolve relative file paths from the process working directory.
|
|
60
|
+
const absolutePath = path.resolve(process.cwd(), target.filePath);
|
|
61
|
+
const result = extractor.extract(absolutePath, target);
|
|
62
|
+
if (result === null) {
|
|
63
|
+
logger_js_1.logger.warn('AstExtractor: symbol not found.', {
|
|
64
|
+
file: target.filePath,
|
|
65
|
+
symbol: target.symbolName,
|
|
66
|
+
});
|
|
67
|
+
continue;
|
|
68
|
+
}
|
|
69
|
+
results.push(result);
|
|
70
|
+
}
|
|
71
|
+
if (results.length === 0) {
|
|
72
|
+
logger_js_1.logger.error('ProcessExtraction: no results extracted.', {
|
|
73
|
+
extraction_id: request.extraction_id,
|
|
74
|
+
});
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
const callbackUrl = config.saas_url.replace(/\/$/, '') + request.callback_url;
|
|
78
|
+
await axios_1.default.post(callbackUrl, { results }, {
|
|
79
|
+
headers: {
|
|
80
|
+
'X-Remediation-Client-Id': config.client_id,
|
|
81
|
+
'X-Remediation-Token': config.token,
|
|
82
|
+
'Content-Type': 'application/json',
|
|
83
|
+
},
|
|
84
|
+
timeout: 30_000,
|
|
85
|
+
});
|
|
86
|
+
logger_js_1.logger.info('Extraction results posted to SaaS.', {
|
|
87
|
+
extraction_id: request.extraction_id,
|
|
88
|
+
count: results.length,
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
//# sourceMappingURL=extractionController.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"extractionController.js","sourceRoot":"","sources":["../../src/controllers/extractionController.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiBA,0DAmDC;AAnED,kDAA0B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YAC3C,qBAAqB,EAAM,MAAM,CAAC,KAAK;YACvC,cAAc,EAAa,kBAAkB;SAC9C;QACD,OAAO,EAAE,MAAM;KAChB,CACF,CAAC;IAEF,kBAAM,CAAC,IAAI,CAAC,oCAAoC,EAAE;QAChD,aAAa,EAAE,OAAO,CAAC,aAAa;QACpC,KAAK,EAAU,OAAO,CAAC,MAAM;KAC9B,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { Router } from 'express';
|
|
2
|
+
import type { AgentConnectionInterface } from '../contracts/agentConnection.js';
|
|
3
|
+
import type { ConnectionConfig } from '../types/wireProtocol.js';
|
|
4
|
+
/**
|
|
5
|
+
* Receives signed envelopes pushed by the SaaS.
|
|
6
|
+
*
|
|
7
|
+
* POST {webhook_path}
|
|
8
|
+
*
|
|
9
|
+
* Supported message_types:
|
|
10
|
+
* runtime_instruction → cache and ack immediately
|
|
11
|
+
* extraction_request → run AST extraction and POST results back to SaaS
|
|
12
|
+
*
|
|
13
|
+
* Any HMAC/replay verification failure returns generic 400 — no oracle detail.
|
|
14
|
+
*/
|
|
15
|
+
export declare function registerWebhookRoute(router: Router, connection: AgentConnectionInterface, config: ConnectionConfig, webhookPath: string, enabled: boolean): void;
|
|
16
|
+
//# sourceMappingURL=webhookController.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"webhookController.d.ts","sourceRoot":"","sources":["../../src/controllers/webhookController.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAqB,MAAM,EAAE,MAAM,SAAS,CAAC;AACzD,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,iCAAiC,CAAC;AAChF,OAAO,KAAK,EAAE,gBAAgB,EAAiC,MAAM,0BAA0B,CAAC;AAOhG;;;;;;;;;;GAUG;AACH,wBAAgB,oBAAoB,CAClC,MAAM,EAAE,MAAM,EACd,UAAU,EAAE,wBAAwB,EACpC,MAAM,EAAE,gBAAgB,EACxB,WAAW,EAAE,MAAM,EACnB,OAAO,EAAE,OAAO,GACf,IAAI,CAiEN"}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.registerWebhookRoute = registerWebhookRoute;
|
|
4
|
+
const instructions_js_1 = require("../types/instructions.js");
|
|
5
|
+
const SignatureError_js_1 = require("../exceptions/SignatureError.js");
|
|
6
|
+
const ReplayError_js_1 = require("../exceptions/ReplayError.js");
|
|
7
|
+
const extractionController_js_1 = require("./extractionController.js");
|
|
8
|
+
const logger_js_1 = require("../logger.js");
|
|
9
|
+
/**
|
|
10
|
+
* Receives signed envelopes pushed by the SaaS.
|
|
11
|
+
*
|
|
12
|
+
* POST {webhook_path}
|
|
13
|
+
*
|
|
14
|
+
* Supported message_types:
|
|
15
|
+
* runtime_instruction → cache and ack immediately
|
|
16
|
+
* extraction_request → run AST extraction and POST results back to SaaS
|
|
17
|
+
*
|
|
18
|
+
* Any HMAC/replay verification failure returns generic 400 — no oracle detail.
|
|
19
|
+
*/
|
|
20
|
+
function registerWebhookRoute(router, connection, config, webhookPath, enabled) {
|
|
21
|
+
if (!enabled)
|
|
22
|
+
return;
|
|
23
|
+
router.post(webhookPath, async (req, res) => {
|
|
24
|
+
const raw = req.body;
|
|
25
|
+
let envelope;
|
|
26
|
+
try {
|
|
27
|
+
envelope = await connection.verifyEnvelope(raw);
|
|
28
|
+
}
|
|
29
|
+
catch (err) {
|
|
30
|
+
if (err instanceof SignatureError_js_1.SignatureError || err instanceof ReplayError_js_1.ReplayError) {
|
|
31
|
+
logger_js_1.logger.warn('RemediationEngine: webhook verification failed.', {
|
|
32
|
+
error: err.message,
|
|
33
|
+
name: err.name,
|
|
34
|
+
});
|
|
35
|
+
res.status(400).json({ error: 'Bad request.' });
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
logger_js_1.logger.error('RemediationEngine: webhook error.', {
|
|
39
|
+
error: err instanceof Error ? err.message : String(err),
|
|
40
|
+
});
|
|
41
|
+
res.status(500).json({ error: 'Internal error.' });
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
const messageType = String(envelope['message_type'] ?? '');
|
|
45
|
+
try {
|
|
46
|
+
if (messageType === 'runtime_instruction') {
|
|
47
|
+
const instruction = instructions_js_1.RuntimeInstruction.fromWirePayload(envelope.payload);
|
|
48
|
+
await connection.cacheInstruction(instruction);
|
|
49
|
+
await connection.acknowledgeInstruction(instruction.instructionId);
|
|
50
|
+
res.status(200).json({ status: 'accepted' });
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
if (messageType === 'extraction_request') {
|
|
54
|
+
// Respond immediately — extraction runs async so the SaaS webhook
|
|
55
|
+
// call does not time out waiting for the AST pass to complete.
|
|
56
|
+
res.status(202).json({ status: 'queued' });
|
|
57
|
+
void (0, extractionController_js_1.handleExtractionRequest)(envelope.payload, config).catch((err) => {
|
|
58
|
+
logger_js_1.logger.error('RemediationEngine: extraction failed.', {
|
|
59
|
+
error: err instanceof Error ? err.message : String(err),
|
|
60
|
+
});
|
|
61
|
+
});
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
res.status(400).json({ error: 'Unknown message_type.' });
|
|
65
|
+
}
|
|
66
|
+
catch (err) {
|
|
67
|
+
logger_js_1.logger.error('RemediationEngine: webhook processing error.', {
|
|
68
|
+
error: err instanceof Error ? err.message : String(err),
|
|
69
|
+
});
|
|
70
|
+
res.status(500).json({ error: 'Internal error.' });
|
|
71
|
+
}
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
//# sourceMappingURL=webhookController.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"webhookController.js","sourceRoot":"","sources":["../../src/controllers/webhookController.ts"],"names":[],"mappings":";;AAoBA,oDAuEC;AAxFD,8DAA8D;AAC9D,uEAAiE;AACjE,iEAA2D;AAC3D,uEAAoE;AACpE,4CAAsC;AAEtC;;;;;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AAE,KAAK,EAAE,iBAAiB,EAAE,CAAC,CAAC;QACrD,CAAC;IACH,CAAC,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ReplayError.d.ts","sourceRoot":"","sources":["../../src/exceptions/ReplayError.ts"],"names":[],"mappings":"AAAA,qBAAa,WAAY,SAAQ,KAAK;gBACxB,OAAO,EAAE,MAAM;CAI5B"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ReplayError = void 0;
|
|
4
|
+
class ReplayError extends Error {
|
|
5
|
+
constructor(message) {
|
|
6
|
+
super(message);
|
|
7
|
+
this.name = 'ReplayError';
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
exports.ReplayError = ReplayError;
|
|
11
|
+
//# sourceMappingURL=ReplayError.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ReplayError.js","sourceRoot":"","sources":["../../src/exceptions/ReplayError.ts"],"names":[],"mappings":";;;AAAA,MAAa,WAAY,SAAQ,KAAK;IACpC,YAAY,OAAe;QACzB,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,aAAa,CAAC;IAC5B,CAAC;CACF;AALD,kCAKC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SignatureError.d.ts","sourceRoot":"","sources":["../../src/exceptions/SignatureError.ts"],"names":[],"mappings":"AAAA,qBAAa,cAAe,SAAQ,KAAK;gBAC3B,OAAO,EAAE,MAAM;CAI5B"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SignatureError = void 0;
|
|
4
|
+
class SignatureError extends Error {
|
|
5
|
+
constructor(message) {
|
|
6
|
+
super(message);
|
|
7
|
+
this.name = 'SignatureError';
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
exports.SignatureError = SignatureError;
|
|
11
|
+
//# sourceMappingURL=SignatureError.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SignatureError.js","sourceRoot":"","sources":["../../src/exceptions/SignatureError.ts"],"names":[],"mappings":";;;AAAA,MAAa,cAAe,SAAQ,KAAK;IACvC,YAAY,OAAe;QACzB,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,gBAAgB,CAAC;IAC/B,CAAC;CACF;AALD,wCAKC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Develler — Node.js/Express Agent
|
|
3
|
+
*
|
|
4
|
+
* Public API. Import and call createRemediationMiddleware() in your Express app:
|
|
5
|
+
*
|
|
6
|
+
* import { createRemediationMiddleware } from 'develler-remediation-agent';
|
|
7
|
+
*
|
|
8
|
+
* const remediation = await createRemediationMiddleware();
|
|
9
|
+
* app.use(remediation.handler());
|
|
10
|
+
*
|
|
11
|
+
* // Optional: mount the webhook receiver so the SaaS can push instructions.
|
|
12
|
+
* app.use(remediation.webhookRouter());
|
|
13
|
+
*/
|
|
14
|
+
import { Router, type RequestHandler } from 'express';
|
|
15
|
+
import type { ConnectionConfig } from './types/wireProtocol.js';
|
|
16
|
+
export type { ConnectionConfig } from './types/wireProtocol.js';
|
|
17
|
+
export type { AgentConnectionInterface } from './contracts/agentConnection.js';
|
|
18
|
+
export type { LifecycleInterceptorInterface } from './contracts/lifecycleInterceptor.js';
|
|
19
|
+
export { MaskRule, RuntimeInstruction, InstructionCollection } from './types/instructions.js';
|
|
20
|
+
export { SignatureError } from './exceptions/SignatureError.js';
|
|
21
|
+
export { ReplayError } from './exceptions/ReplayError.js';
|
|
22
|
+
export { MaskingEngine } from './services/MaskingEngine.js';
|
|
23
|
+
export { AstExtractorService } from './services/AstExtractorService.js';
|
|
24
|
+
export type { ExtractionTarget, ExtractionResult, ExtractionRequestPayload } from './types/extraction.js';
|
|
25
|
+
export interface RemediationConfig {
|
|
26
|
+
/** URL of the Redis instance. Defaults to REDIS_URL env var. */
|
|
27
|
+
readonly redisUrl?: string;
|
|
28
|
+
/** Connection config object. If omitted, reads .remediation-connection.json. */
|
|
29
|
+
readonly connection?: ConnectionConfig;
|
|
30
|
+
/** Disable the interceptor entirely (useful for local dev). Default: true. */
|
|
31
|
+
readonly enabled?: boolean;
|
|
32
|
+
/** Circuit breaker open duration in seconds. Default: 60. */
|
|
33
|
+
readonly cbTtlSeconds?: number;
|
|
34
|
+
/** Path the SaaS will POST instructions to. Default: /api/remediation/v1/webhook */
|
|
35
|
+
readonly webhookPath?: string;
|
|
36
|
+
/** Set false to skip registering the webhook route. Default: true. */
|
|
37
|
+
readonly webhookEnabled?: boolean;
|
|
38
|
+
}
|
|
39
|
+
export interface RemediationAgent {
|
|
40
|
+
/** Express RequestHandler — register with app.use(). */
|
|
41
|
+
handler(): RequestHandler;
|
|
42
|
+
/** Express Router with the webhook POST endpoint — register with app.use(). */
|
|
43
|
+
webhookRouter(): Router;
|
|
44
|
+
/** Reset the circuit breaker manually. */
|
|
45
|
+
resetCircuitBreaker(): Promise<void>;
|
|
46
|
+
}
|
|
47
|
+
export declare function createRemediationMiddleware(cfg?: RemediationConfig): Promise<RemediationAgent>;
|
|
48
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAGH,OAAO,EAAE,MAAM,EAAE,KAAK,cAAc,EAAE,MAAM,SAAS,CAAC;AAUtD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAS,yBAAyB,CAAC;AAGnE,YAAY,EAAE,gBAAgB,EAAE,MAAqC,yBAAyB,CAAC;AAC/F,YAAY,EAAE,wBAAwB,EAAE,MA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