@j3r3mcdev/oast-server 1.1.9 → 1.1.10
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/package.json
CHANGED
|
@@ -19,11 +19,17 @@ export class SmtpListener {
|
|
|
19
19
|
this.server.onData = async (stream: any, session: any, callback: any) => {
|
|
20
20
|
let chunks: string[] = [];
|
|
21
21
|
|
|
22
|
-
|
|
22
|
+
const onData = (chunk: any) => {
|
|
23
23
|
chunks.push(chunk.toString());
|
|
24
|
-
}
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
const onEnd = async () => {
|
|
27
|
+
// 🔥 Compatible Node + Jest + mocks
|
|
28
|
+
if (stream.removeListener) {
|
|
29
|
+
stream.removeListener("data", onData);
|
|
30
|
+
stream.removeListener("end", onEnd);
|
|
31
|
+
}
|
|
25
32
|
|
|
26
|
-
stream.on("end", async () => {
|
|
27
33
|
const body = chunks.join("");
|
|
28
34
|
|
|
29
35
|
let event;
|
|
@@ -44,14 +50,26 @@ export class SmtpListener {
|
|
|
44
50
|
try {
|
|
45
51
|
await this.router.dispatch(event);
|
|
46
52
|
callback(null);
|
|
47
|
-
} catch
|
|
48
|
-
callback(new Error("dispatch failed"));
|
|
53
|
+
} catch {
|
|
54
|
+
callback(new Error("dispatch failed"));
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
// 🔥 Empêche les fuites de stream
|
|
58
|
+
if (stream.destroy) {
|
|
59
|
+
stream.destroy();
|
|
49
60
|
}
|
|
50
|
-
}
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
stream.on("data", onData);
|
|
64
|
+
stream.on("end", onEnd);
|
|
51
65
|
};
|
|
52
66
|
}
|
|
53
67
|
|
|
54
68
|
async stop() {
|
|
69
|
+
if (this.server) {
|
|
70
|
+
this.server.onData = undefined;
|
|
71
|
+
}
|
|
72
|
+
|
|
55
73
|
if (this.server?.close) {
|
|
56
74
|
this.server.close();
|
|
57
75
|
this.logger.info("SMTP Listener stopped");
|
package/src/types/event.types.ts
CHANGED
|
@@ -56,6 +56,12 @@ export interface RawWebSocketEvent {
|
|
|
56
56
|
raw: any;
|
|
57
57
|
}
|
|
58
58
|
|
|
59
|
+
export interface RawApiEvent {
|
|
60
|
+
ip: string;
|
|
61
|
+
body: any;
|
|
62
|
+
raw: any;
|
|
63
|
+
}
|
|
64
|
+
|
|
59
65
|
//
|
|
60
66
|
// NORMALIZED EVENTS
|
|
61
67
|
//
|
|
@@ -104,6 +110,7 @@ export interface NormalizedTcpEvent {
|
|
|
104
110
|
data: string;
|
|
105
111
|
raw: any;
|
|
106
112
|
}
|
|
113
|
+
|
|
107
114
|
export interface NormalizedSsrfEvent {
|
|
108
115
|
id: string;
|
|
109
116
|
type: "ssrf";
|
|
@@ -134,6 +141,17 @@ export interface NormalizedWebSocketEvent {
|
|
|
134
141
|
message: string;
|
|
135
142
|
}
|
|
136
143
|
|
|
144
|
+
export interface NormalizedApiEvent {
|
|
145
|
+
id: string;
|
|
146
|
+
type: "api";
|
|
147
|
+
timestamp: number;
|
|
148
|
+
sourceIp: string;
|
|
149
|
+
request: {
|
|
150
|
+
body: any;
|
|
151
|
+
};
|
|
152
|
+
raw: any;
|
|
153
|
+
}
|
|
154
|
+
|
|
137
155
|
//
|
|
138
156
|
// UNION
|
|
139
157
|
//
|
|
@@ -144,4 +162,5 @@ export type AnyNormalizedEvent =
|
|
|
144
162
|
| NormalizedTcpEvent
|
|
145
163
|
| NormalizedSsrfEvent
|
|
146
164
|
| NormalizedWebhookEvent
|
|
147
|
-
| NormalizedWebSocketEvent
|
|
165
|
+
| NormalizedWebSocketEvent
|
|
166
|
+
| NormalizedApiEvent;
|