@goodtools/wiregasm 1.9.1 → 2.0.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/README.md +92 -75
- package/dist/main.js +143 -61
- package/dist/main.js.map +1 -1
- package/dist/module.js +141 -59
- package/dist/module.js.map +1 -1
- package/dist/types.d.ts +113 -16
- package/dist/types.d.ts.map +1 -1
- package/dist/wiregasm.data +11227 -12500
- package/dist/wiregasm.data.gz +0 -0
- package/dist/wiregasm.js +6636 -5714
- package/dist/wiregasm.wasm +2 -2
- package/dist/wiregasm.wasm.gz +0 -0
- package/package.json +17 -18
package/dist/types.d.ts
CHANGED
|
@@ -3,8 +3,8 @@ export interface EmscriptenFileSystem {
|
|
|
3
3
|
flags?: string | undefined;
|
|
4
4
|
}): void;
|
|
5
5
|
readdir(path: string): string[];
|
|
6
|
-
mkdirTree(path: string, mode?: number):
|
|
7
|
-
mkdir(path: string, mode?: number):
|
|
6
|
+
mkdirTree(path: string, mode?: number): void;
|
|
7
|
+
mkdir(path: string, mode?: number): void;
|
|
8
8
|
}
|
|
9
9
|
export interface EmscriptenHeap {
|
|
10
10
|
buffer: ArrayBufferLike;
|
|
@@ -17,6 +17,8 @@ export interface EmscriptenModule {
|
|
|
17
17
|
export interface Vector<T> {
|
|
18
18
|
size(): number;
|
|
19
19
|
get(index: number): T;
|
|
20
|
+
/** Frees the vector on the wasm heap (embind handle). */
|
|
21
|
+
delete(): void;
|
|
20
22
|
}
|
|
21
23
|
export interface DataSource {
|
|
22
24
|
name: string;
|
|
@@ -44,7 +46,9 @@ export enum PrefType {
|
|
|
44
46
|
PREF_DECODE_AS_UINT = 4096,
|
|
45
47
|
PREF_DECODE_AS_RANGE = 8192,
|
|
46
48
|
PREF_OPEN_FILENAME = 16384,
|
|
47
|
-
PREF_PASSWORD = 32768
|
|
49
|
+
PREF_PASSWORD = 32768,
|
|
50
|
+
PREF_PROTO_TCP_SNDAMB_ENUM = 65536,
|
|
51
|
+
PREF_DISSECTOR = 131072
|
|
48
52
|
}
|
|
49
53
|
export interface PrefModule {
|
|
50
54
|
name: string;
|
|
@@ -210,6 +214,23 @@ export interface IoGraphResult {
|
|
|
210
214
|
export interface IoGraph {
|
|
211
215
|
items: Vector<number>;
|
|
212
216
|
}
|
|
217
|
+
export interface ProtocolInfo {
|
|
218
|
+
id: number;
|
|
219
|
+
name: string;
|
|
220
|
+
long_name: string;
|
|
221
|
+
enabled: boolean;
|
|
222
|
+
enabled_by_default: boolean;
|
|
223
|
+
can_toggle: boolean;
|
|
224
|
+
}
|
|
225
|
+
export interface HeuristicInfo {
|
|
226
|
+
short_name: string;
|
|
227
|
+
display_name: string;
|
|
228
|
+
list_name: string;
|
|
229
|
+
protocol_name: string;
|
|
230
|
+
protocol_id: number;
|
|
231
|
+
enabled: boolean;
|
|
232
|
+
enabled_by_default: boolean;
|
|
233
|
+
}
|
|
213
234
|
export interface DissectSession {
|
|
214
235
|
/**
|
|
215
236
|
* Free up any memory used by the session
|
|
@@ -386,16 +407,56 @@ export interface WiregasmLib extends EmscriptenModule {
|
|
|
386
407
|
* @param length Length of the data
|
|
387
408
|
*/
|
|
388
409
|
upload(file_name: string, data_ptr: number, length: number): string;
|
|
410
|
+
/**
|
|
411
|
+
* List all registered protocols
|
|
412
|
+
*
|
|
413
|
+
* @returns List of all protocols with their enabled state
|
|
414
|
+
*/
|
|
415
|
+
listProtocols(): Vector<ProtocolInfo>;
|
|
416
|
+
/**
|
|
417
|
+
* Enable or disable a protocol by its ID
|
|
418
|
+
*
|
|
419
|
+
* @param protoId Protocol ID
|
|
420
|
+
* @param enabled Whether to enable or disable the protocol
|
|
421
|
+
* @returns true if successful, false otherwise
|
|
422
|
+
*/
|
|
423
|
+
setProtocolEnabled(protoId: number, enabled: boolean): boolean;
|
|
424
|
+
/**
|
|
425
|
+
* Enable or disable a protocol by its filter name
|
|
426
|
+
*
|
|
427
|
+
* @param protoName Protocol filter name (e.g., "tcp", "udp")
|
|
428
|
+
* @param enabled Whether to enable or disable the protocol
|
|
429
|
+
* @returns true if successful, false otherwise
|
|
430
|
+
*/
|
|
431
|
+
setProtocolEnabledByName(protoName: string, enabled: boolean): boolean;
|
|
432
|
+
/**
|
|
433
|
+
* List all registered heuristic dissectors
|
|
434
|
+
*
|
|
435
|
+
* @returns List of all heuristic dissectors with their enabled state
|
|
436
|
+
*/
|
|
437
|
+
listHeuristicDissectors(): Vector<HeuristicInfo>;
|
|
438
|
+
/**
|
|
439
|
+
* Enable or disable a heuristic dissector by its unique short name
|
|
440
|
+
*
|
|
441
|
+
* @param shortName Unique short name of the heuristic dissector (e.g., "mac_nr_udp")
|
|
442
|
+
* @param enabled Whether to enable or disable the heuristic
|
|
443
|
+
* @returns true if successful, false otherwise
|
|
444
|
+
*/
|
|
445
|
+
setHeuristicEnabled(shortName: string, enabled: boolean): boolean;
|
|
389
446
|
}
|
|
390
447
|
export type WiregasmLoader = (overrides: WiregasmLibOverrides) => Promise<WiregasmLib>;
|
|
391
448
|
export type BeforeInitCallback = (lib: WiregasmLib) => Promise<void>;
|
|
392
449
|
/**
|
|
393
|
-
* Converts a Vector to a JS array
|
|
450
|
+
* Converts a Vector to a JS array and frees the Vector
|
|
394
451
|
*
|
|
395
452
|
* @param vec Vector
|
|
396
453
|
* @returns JS array of the Vector contents
|
|
397
454
|
*/
|
|
398
455
|
export function vectorToArray<T>(vec: Vector<T>): T[];
|
|
456
|
+
/**
|
|
457
|
+
* Frees an embind object (class instance, vector or map) on the wasm heap.
|
|
458
|
+
*/
|
|
459
|
+
export function free(handle: unknown): void;
|
|
399
460
|
export function preferenceSetCodeToError(code: number): string;
|
|
400
461
|
/**
|
|
401
462
|
* Wraps the WiregasmLib lib functionality and manages a single DissectSession
|
|
@@ -413,19 +474,19 @@ export class Wiregasm {
|
|
|
413
474
|
* @param loader Loader function for the Emscripten module
|
|
414
475
|
* @param overrides Overrides
|
|
415
476
|
*/
|
|
416
|
-
init(loader: WiregasmLoader, overrides?: WiregasmLibOverrides, beforeInit?: BeforeInitCallback): Promise<void>;
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
477
|
+
init(loader: WiregasmLoader, overrides?: WiregasmLibOverrides, beforeInit?: BeforeInitCallback | null): Promise<void>;
|
|
478
|
+
listModules(): Vector<PrefModule>;
|
|
479
|
+
listPrefs(module: string): Vector<Pref>;
|
|
480
|
+
applyPrefs(): void;
|
|
481
|
+
setPref(module: string, key: string, value: string): void;
|
|
482
|
+
getPref(module: string, key: string): Pref;
|
|
422
483
|
/**
|
|
423
484
|
* Check the validity of a filter expression.
|
|
424
485
|
*
|
|
425
486
|
* @param filter A display filter expression
|
|
426
487
|
*/
|
|
427
|
-
|
|
428
|
-
|
|
488
|
+
testFilter(filter: string): CheckFilterResponse;
|
|
489
|
+
completeFilter(filter: string): {
|
|
429
490
|
fields: CompleteField[];
|
|
430
491
|
};
|
|
431
492
|
tap(taps: MapInput): {
|
|
@@ -439,8 +500,8 @@ export class Wiregasm {
|
|
|
439
500
|
}[];
|
|
440
501
|
error: string;
|
|
441
502
|
};
|
|
442
|
-
|
|
443
|
-
|
|
503
|
+
reloadLuaPlugins(): void;
|
|
504
|
+
addPlugin(name: string, data: string | ArrayBufferView, opts?: object): void;
|
|
444
505
|
/**
|
|
445
506
|
* Load a packet trace file for analysis.
|
|
446
507
|
*
|
|
@@ -467,8 +528,44 @@ export class Wiregasm {
|
|
|
467
528
|
* Returns the column headers
|
|
468
529
|
*/
|
|
469
530
|
columns(): string[];
|
|
470
|
-
|
|
471
|
-
|
|
531
|
+
isEoTap(tap: any): tap is TapExportObjectResponse;
|
|
532
|
+
isConvTap(tap: any): tap is TapConvResponse;
|
|
533
|
+
/**
|
|
534
|
+
* List all registered protocols
|
|
535
|
+
*
|
|
536
|
+
* @returns Array of all protocols with their enabled state
|
|
537
|
+
*/
|
|
538
|
+
listProtocols(): ProtocolInfo[];
|
|
539
|
+
/**
|
|
540
|
+
* Enable or disable a protocol by its ID
|
|
541
|
+
*
|
|
542
|
+
* @param protoId Protocol ID
|
|
543
|
+
* @param enabled Whether to enable or disable the protocol
|
|
544
|
+
* @returns true if successful, false otherwise
|
|
545
|
+
*/
|
|
546
|
+
setProtocolEnabled(protoId: number, enabled: boolean): boolean;
|
|
547
|
+
/**
|
|
548
|
+
* Enable or disable a protocol by its filter name
|
|
549
|
+
*
|
|
550
|
+
* @param protoName Protocol filter name (e.g., "tcp", "udp")
|
|
551
|
+
* @param enabled Whether to enable or disable the protocol
|
|
552
|
+
* @returns true if successful, false otherwise
|
|
553
|
+
*/
|
|
554
|
+
setProtocolEnabledByName(protoName: string, enabled: boolean): boolean;
|
|
555
|
+
/**
|
|
556
|
+
* List all registered heuristic dissectors
|
|
557
|
+
*
|
|
558
|
+
* @returns Array of all heuristic dissectors with their enabled state
|
|
559
|
+
*/
|
|
560
|
+
listHeuristicDissectors(): HeuristicInfo[];
|
|
561
|
+
/**
|
|
562
|
+
* Enable or disable a heuristic dissector by its unique short name
|
|
563
|
+
*
|
|
564
|
+
* @param shortName Unique short name of the heuristic dissector (e.g., "mac_nr_udp")
|
|
565
|
+
* @param enabled Whether to enable or disable the heuristic
|
|
566
|
+
* @returns true if successful, false otherwise
|
|
567
|
+
*/
|
|
568
|
+
setHeuristicEnabled(shortName: string, enabled: boolean): boolean;
|
|
472
569
|
}
|
|
473
570
|
|
|
474
571
|
//# sourceMappingURL=types.d.ts.map
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":"AAAA;IACE,SAAS,CACP,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,GAAG,eAAe,EAC9B,IAAI,CAAC,EAAE;QAAE,KAAK,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;KAAE,GACpC,IAAI,CAAC;IACR,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IAChC,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,IA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kBAAkB;IAIlB,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,eAAe,EAAE,IAAI,GAAE,MAAW;IAK1E;;;;OAIG;IACH,IAAI,CACF,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,GAAG,eAAe,EAC9B,IAAI,GAAE,MAAW,GAChB,YAAY;IAaf;;;;;;OAMG;IACH,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,SAAI,EAAE,KAAK,SAAI,GAAG,cAAc;IAI3D;;;;OAIG;IACH,KAAK,CAAC,GAAG,EAAE,MAAM,GAAG,KAAK;IAIzB,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM;IAI9C,OAAO;IAYP;;OAEG;IACH,OAAO,IAAI,MAAM,EAAE;IAOnB,SAAS,CAAC,GAAG,EAAE,GAAG,GAAG,GAAG,IAAI,uBAAuB;IAInD,WAAW,CAAC,GAAG,EAAE,GAAG,GAAG,GAAG,IAAI,eAAe;CAG9C","sources":["src/src/types.ts","src/src/utils.ts","src/src/index.ts","src/index.ts"],"sourcesContent":[null,null,null,"import {\n BeforeInitCallback,\n CheckFilterResponse,\n CompleteField,\n DissectSession,\n DownloadResponse,\n Follow,\n Frame,\n FramesResponse,\n LoadResponse,\n MapInput,\n Pref,\n PrefModule,\n PrefSetResult,\n TapConvResponse,\n TapExportObjectResponse,\n TapResponse,\n Vector,\n WiregasmLib,\n WiregasmLibOverrides,\n WiregasmLoader,\n} from \"./types\";\nimport { preferenceSetCodeToError, vectorToArray } from \"./utils\";\n\nconst ALLOWED_TAP_KEYS = new Set([\n ...Array.from({ length: 15 }, (_, i) => `tap${i}`),\n ...Array.from({ length: 15 }, (_, i) => `filter${i}`),\n]);\n\nconst ALLOWED_GRAPH_KEYS = new Set([\n \"filter\",\n \"interval\",\n ...Array.from({ length: 9 }, (_, i) => `graph${i}`),\n ...Array.from({ length: 9 }, (_, i) => `filter${i}`),\n]);\n\n/**\n * Wraps the WiregasmLib lib functionality and manages a single DissectSession\n */\nexport class Wiregasm {\n lib: WiregasmLib;\n initialized: boolean;\n session: DissectSession | null;\n uploadDir: string;\n pluginsDir: string;\n\n constructor() {\n this.initialized = false;\n this.session = null;\n }\n\n /**\n * Initialize the wrapper and the Wiregasm module\n *\n * @param loader Loader function for the Emscripten module\n * @param overrides Overrides\n */\n async init(\n loader: WiregasmLoader,\n overrides: WiregasmLibOverrides = {},\n beforeInit: BeforeInitCallback = null\n ) {\n if (this.initialized) {\n return;\n }\n\n this.lib = await loader(overrides);\n\n if (beforeInit !== null) {\n await beforeInit(this.lib);\n }\n\n if (!this.lib.init()) {\n throw new Error(\"Failed to initialize Wiregasm\");\n }\n\n this.uploadDir = this.lib.getUploadDirectory();\n this.pluginsDir = this.lib.getPluginsDirectory();\n this.initialized = true;\n }\n\n list_modules(): Vector<PrefModule> {\n return this.lib.listModules();\n }\n\n list_prefs(module: string): Vector<Pref> {\n return this.lib.listPreferences(module);\n }\n\n apply_prefs() {\n this.lib.applyPreferences();\n }\n\n set_pref(module: string, key: string, value: string) {\n const ret = this.lib.setPref(module, key, value);\n\n if (ret.code != PrefSetResult.PREFS_SET_OK) {\n const message =\n ret.error != \"\" ? ret.error : preferenceSetCodeToError(ret.code);\n throw new Error(\n `Failed to set preference (${module}.${key}): ${message}`\n );\n }\n }\n\n get_pref(module: string, key: string): Pref {\n const response = this.lib.getPref(module, key);\n if (response.code != 0) {\n throw new Error(`Failed to get preference (${module}.${key})`);\n }\n return response.data;\n }\n\n /**\n * Check the validity of a filter expression.\n *\n * @param filter A display filter expression\n */\n test_filter(filter: string): CheckFilterResponse {\n return this.lib.checkFilter(filter);\n }\n\n complete_filter(filter: string): { fields: CompleteField[] } {\n const out = this.lib.completeFilter(filter);\n return {\n fields: vectorToArray(out.fields),\n };\n }\n\n tap(taps: MapInput) {\n // Validate keys.\n if (!(\"tap0\" in taps)) {\n throw new Error(\"tap0 is mandatory.\");\n }\n if (!Object.keys(taps).every((k) => ALLOWED_TAP_KEYS.has(k))) {\n throw new Error(\n `Invalid arguments. Allowed keys are: ${Array.from(\n ALLOWED_GRAPH_KEYS\n ).join(\", \")}.`\n );\n }\n\n const args = new this.lib.MapInput();\n Object.entries(taps).forEach(([k, v]) => args.set(k, v));\n\n const response = this.session.tap(args);\n return {\n error: response.error,\n taps: vectorToArray(response.taps).map((tap) => {\n let res;\n if (this.is_conv_tap(tap)) {\n res = {\n proto: tap.proto,\n tap: tap.tap,\n type: tap.type,\n geoip: tap.geoip,\n convs: vectorToArray(tap.convs),\n hosts: vectorToArray(tap.hosts),\n };\n } else if (this.is_eo_tap(tap)) {\n res = {\n proto: tap.proto,\n tap: tap.tap,\n type: tap.type,\n objects: vectorToArray(tap.objects),\n };\n } else {\n (tap as { delete: () => void }).delete();\n throw new Error(\"Unknown tap result\");\n }\n (tap as TapResponse & { delete: () => void }).delete();\n return res;\n }),\n };\n }\n\n download(token: string): DownloadResponse {\n return this.session.download(token);\n }\n\n iograph(input: MapInput) {\n // Validate keys.\n if (!(\"graph0\" in input)) {\n throw new Error(\"graph0 is mandatory.\");\n }\n if (!Object.keys(input).every((k) => ALLOWED_GRAPH_KEYS.has(k))) {\n throw new Error(\n `Invalid arguments. Allowed keys are: ${Array.from(\n ALLOWED_GRAPH_KEYS\n ).join(\", \")}.`\n );\n }\n\n const args = new this.lib.MapInput();\n Object.entries(input).forEach(([k, v]) => args.set(k, v));\n\n const out = this.session.iograph(args);\n return {\n ...out,\n iograph: vectorToArray(out.iograph).map((t) => ({\n items: vectorToArray(t.items),\n })),\n };\n }\n\n reload_lua_plugins() {\n this.lib.reloadLuaPlugins();\n }\n\n add_plugin(name: string, data: string | ArrayBufferView, opts: object = {}) {\n const path = this.pluginsDir + \"/\" + name;\n this.lib.FS.writeFile(path, data, opts);\n }\n\n /**\n * Load a packet trace file for analysis.\n *\n * @returns Response containing the status and summary\n */\n load(\n name: string,\n data: string | ArrayBufferView,\n opts: object = {}\n ): LoadResponse {\n if (this.session != null) {\n this.session.delete();\n }\n\n const path = this.uploadDir + \"/\" + name;\n this.lib.FS.writeFile(path, data, opts);\n\n this.session = new this.lib.DissectSession(path);\n\n return this.session.load();\n }\n\n /**\n * Get Packet List information for a range of packets.\n *\n * @param filter Output those frames that pass this filter expression\n * @param skip Skip N frames\n * @param limit Limit the output to N frames\n */\n frames(filter: string, skip = 0, limit = 0): FramesResponse {\n return this.session.getFrames(filter, skip, limit);\n }\n\n /**\n * Get full information about a frame including the protocol tree.\n *\n * @param number Frame number\n */\n frame(num: number): Frame {\n return this.session.getFrame(num);\n }\n\n follow(follow: string, filter: string): Follow {\n return this.session.follow(follow, filter);\n }\n\n destroy() {\n if (this.initialized) {\n if (this.session !== null) {\n this.session.delete();\n this.session = null;\n }\n\n this.lib.destroy();\n this.initialized = false;\n }\n }\n\n /**\n * Returns the column headers\n */\n columns(): string[] {\n const vec = this.lib.getColumns();\n\n // convert it from a vector to array\n return vectorToArray(vec);\n }\n\n is_eo_tap(tap: any): tap is TapExportObjectResponse {\n return tap instanceof this.lib.TapExportObject;\n }\n\n is_conv_tap(tap: any): tap is TapConvResponse {\n return tap instanceof this.lib.TapConvResponse;\n }\n}\n\nexport * from \"./types\";\nexport * from \"./utils\";\n"],"names":[],"version":3,"file":"types.d.ts.map"}
|
|
1
|
+
{"mappings":"AACA;IACE,SAAS,CACP,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,GAAG,eAAe,EAC9B,IAAI,CAAC,EAAE;QAAE,KAAK,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;KAAE,GACpC,IAAI,CAAC;IACR,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IAChC,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7C,KAAK,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,GAAG,IAAI,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;;;OAIG;IACH,KAAK,CAAC,GAAG,EAAE,MAAM,GAAG,KAAK;IAIzB,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM;IAW9C,OAAO;IAYP;;OAEG;IACH,OAAO,IAAI,MAAM,EAAE;IAOnB,OAAO,CAAC,GAAG,EAAE,GAAG,GAAG,GAAG,IAAI,uBAAuB;IAIjD,SAAS,CAAC,GAAG,EAAE,GAAG,GAAG,GAAG,IAAI,eAAe;IAM3C;;;;OAIG;IACH,aAAa,IAAI,YAAY,EAAE;IAI/B;;;;;;OAMG;IACH,kBAAkB,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,GAAG,OAAO;IAI9D;;;;;;OAMG;IACH,wBAAwB,CAAC,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,GAAG,OAAO;IAMtE;;;;OAIG;IACH,uBAAuB,IAAI,aAAa,EAAE;IAI1C;;;;;;OAMG;IACH,mBAAmB,CAAC,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,GAAG,OAAO;CAGlE","sources":["src/src/types.ts","src/src/utils.ts","src/src/index.ts","src/index.ts"],"sourcesContent":[null,null,null,"// SPDX-License-Identifier: GPL-2.0-or-later\nimport {\n type BeforeInitCallback,\n type CheckFilterResponse,\n type CompleteField,\n type DissectSession,\n type DownloadResponse,\n type Follow,\n type Frame,\n type FramesResponse,\n type IoGraphResult,\n type HeuristicInfo,\n type LoadResponse,\n type MapInput,\n type Pref,\n type PrefModule,\n PrefSetResult,\n type ProtocolInfo,\n type TapConvResponse,\n type TapExportObjectResponse,\n type TapResponse,\n type Vector,\n type WiregasmLib,\n type WiregasmLibOverrides,\n type WiregasmLoader,\n} from \"./types\";\nimport { free, preferenceSetCodeToError, vectorToArray } from \"./utils\";\n\nconst ALLOWED_TAP_KEYS = new Set([\n ...Array.from({ length: 15 }, (_, i) => `tap${i}`),\n ...Array.from({ length: 15 }, (_, i) => `filter${i}`),\n]);\n\nconst ALLOWED_GRAPH_KEYS = new Set([\n \"filter\",\n \"interval\",\n ...Array.from({ length: 9 }, (_, i) => `graph${i}`),\n ...Array.from({ length: 9 }, (_, i) => `filter${i}`),\n]);\n\n/**\n * Wraps the WiregasmLib lib functionality and manages a single DissectSession\n */\nexport class Wiregasm {\n // Set by init(); using the wrapper before init() is a programming error.\n lib!: WiregasmLib;\n initialized: boolean;\n session: DissectSession | null;\n uploadDir!: string;\n pluginsDir!: string;\n\n constructor() {\n this.initialized = false;\n this.session = null;\n }\n\n /**\n * Initialize the wrapper and the Wiregasm module\n *\n * @param loader Loader function for the Emscripten module\n * @param overrides Overrides\n */\n async init(\n loader: WiregasmLoader,\n overrides: WiregasmLibOverrides = {},\n beforeInit: BeforeInitCallback | null = null\n ) {\n if (this.initialized) {\n return;\n }\n\n this.lib = await loader(overrides);\n\n if (beforeInit !== null) {\n await beforeInit(this.lib);\n }\n\n if (!this.lib.init()) {\n throw new Error(\"Failed to initialize Wiregasm\");\n }\n\n this.uploadDir = this.lib.getUploadDirectory();\n this.pluginsDir = this.lib.getPluginsDirectory();\n this.initialized = true;\n }\n\n listModules(): Vector<PrefModule> {\n return this.lib.listModules();\n }\n\n listPrefs(module: string): Vector<Pref> {\n return this.lib.listPreferences(module);\n }\n\n applyPrefs() {\n this.lib.applyPreferences();\n }\n\n setPref(module: string, key: string, value: string) {\n const ret = this.lib.setPref(module, key, value);\n\n if (ret.code !== PrefSetResult.PREFS_SET_OK) {\n const message =\n ret.error !== \"\" ? ret.error : preferenceSetCodeToError(ret.code);\n throw new Error(\n `Failed to set preference (${module}.${key}): ${message}`\n );\n }\n }\n\n getPref(module: string, key: string): Pref {\n const response = this.lib.getPref(module, key);\n if (response.code !== 0) {\n throw new Error(`Failed to get preference (${module}.${key})`);\n }\n return response.data;\n }\n\n /**\n * Check the validity of a filter expression.\n *\n * @param filter A display filter expression\n */\n testFilter(filter: string): CheckFilterResponse {\n return this.lib.checkFilter(filter);\n }\n\n completeFilter(filter: string): { fields: CompleteField[] } {\n const out = this.lib.completeFilter(filter);\n return {\n fields: vectorToArray(out.fields),\n };\n }\n\n tap(taps: MapInput) {\n // Validate keys.\n if (!(\"tap0\" in taps)) {\n throw new Error(\"tap0 is mandatory.\");\n }\n if (!Object.keys(taps).every((k) => ALLOWED_TAP_KEYS.has(k))) {\n throw new Error(\n `Invalid arguments. Allowed keys are: ${Array.from(\n ALLOWED_TAP_KEYS\n ).join(\", \")}.`\n );\n }\n\n const session = this.loadedSession();\n const args = new this.lib.MapInput();\n for (const [k, v] of Object.entries(taps)) {\n args.set(k, v);\n }\n\n let response: ReturnType<DissectSession[\"tap\"]>;\n try {\n response = session.tap(args);\n } finally {\n free(args);\n }\n return {\n error: response.error,\n taps: vectorToArray(response.taps).map((tap) => {\n // biome-ignore lint/suspicious/noExplicitAny: keeps the public return type of tap() unchanged\n let res: any;\n if (this.isConvTap(tap)) {\n res = {\n proto: tap.proto,\n tap: tap.tap,\n type: tap.type,\n geoip: tap.geoip,\n convs: vectorToArray(tap.convs),\n hosts: vectorToArray(tap.hosts),\n };\n } else if (this.isEoTap(tap)) {\n res = {\n proto: tap.proto,\n tap: tap.tap,\n type: tap.type,\n objects: vectorToArray(tap.objects),\n };\n } else {\n free(tap);\n throw new Error(\"Unknown tap result\");\n }\n free(tap);\n return res;\n }),\n };\n }\n\n download(token: string): DownloadResponse {\n return this.loadedSession().download(token);\n }\n\n iograph(input: MapInput) {\n // Validate keys.\n if (!(\"graph0\" in input)) {\n throw new Error(\"graph0 is mandatory.\");\n }\n if (!Object.keys(input).every((k) => ALLOWED_GRAPH_KEYS.has(k))) {\n throw new Error(\n `Invalid arguments. Allowed keys are: ${Array.from(\n ALLOWED_GRAPH_KEYS\n ).join(\", \")}.`\n );\n }\n\n const session = this.loadedSession();\n const args = new this.lib.MapInput();\n for (const [k, v] of Object.entries(input)) {\n args.set(k, v);\n }\n\n let out: IoGraphResult;\n try {\n out = session.iograph(args);\n } finally {\n free(args);\n }\n return {\n ...out,\n iograph: vectorToArray(out.iograph).map((t) => ({\n items: vectorToArray(t.items),\n })),\n };\n }\n\n reloadLuaPlugins() {\n this.lib.reloadLuaPlugins();\n }\n\n addPlugin(name: string, data: string | ArrayBufferView, opts: object = {}) {\n const path = `${this.pluginsDir}/${name}`;\n this.lib.FS.writeFile(path, data, opts);\n }\n\n /**\n * Load a packet trace file for analysis.\n *\n * @returns Response containing the status and summary\n */\n load(\n name: string,\n data: string | ArrayBufferView,\n opts: object = {}\n ): LoadResponse {\n if (this.session != null) {\n this.session.delete();\n }\n\n const path = `${this.uploadDir}/${name}`;\n this.lib.FS.writeFile(path, data, opts);\n\n this.session = new this.lib.DissectSession(path);\n\n const response = this.session.load();\n if (response.code !== 0) {\n // Don't keep a session for a file that failed to open.\n this.session.delete();\n this.session = null;\n }\n return response;\n }\n\n /**\n * Get Packet List information for a range of packets.\n *\n * @param filter Output those frames that pass this filter expression\n * @param skip Skip N frames\n * @param limit Limit the output to N frames\n */\n frames(filter: string, skip = 0, limit = 0): FramesResponse {\n return this.loadedSession().getFrames(filter, skip, limit);\n }\n\n /**\n * Get full information about a frame including the protocol tree.\n *\n * @param number Frame number\n */\n frame(num: number): Frame {\n return this.loadedSession().getFrame(num);\n }\n\n follow(follow: string, filter: string): Follow {\n return this.loadedSession().follow(follow, filter);\n }\n\n private loadedSession(): DissectSession {\n if (this.session === null) {\n throw new Error(\"No capture file loaded, call load() first.\");\n }\n return this.session;\n }\n\n destroy() {\n if (this.initialized) {\n if (this.session !== null) {\n this.session.delete();\n this.session = null;\n }\n\n this.lib.destroy();\n this.initialized = false;\n }\n }\n\n /**\n * Returns the column headers\n */\n columns(): string[] {\n const vec = this.lib.getColumns();\n\n // convert it from a vector to array\n return vectorToArray(vec);\n }\n\n isEoTap(tap: any): tap is TapExportObjectResponse {\n return tap instanceof this.lib.TapExportObject;\n }\n\n isConvTap(tap: any): tap is TapConvResponse {\n return tap instanceof this.lib.TapConvResponse;\n }\n\n // Protocol enable/disable methods\n\n /**\n * List all registered protocols\n *\n * @returns Array of all protocols with their enabled state\n */\n listProtocols(): ProtocolInfo[] {\n return vectorToArray(this.lib.listProtocols());\n }\n\n /**\n * Enable or disable a protocol by its ID\n *\n * @param protoId Protocol ID\n * @param enabled Whether to enable or disable the protocol\n * @returns true if successful, false otherwise\n */\n setProtocolEnabled(protoId: number, enabled: boolean): boolean {\n return this.lib.setProtocolEnabled(protoId, enabled);\n }\n\n /**\n * Enable or disable a protocol by its filter name\n *\n * @param protoName Protocol filter name (e.g., \"tcp\", \"udp\")\n * @param enabled Whether to enable or disable the protocol\n * @returns true if successful, false otherwise\n */\n setProtocolEnabledByName(protoName: string, enabled: boolean): boolean {\n return this.lib.setProtocolEnabledByName(protoName, enabled);\n }\n\n // Heuristic dissector enable/disable methods\n\n /**\n * List all registered heuristic dissectors\n *\n * @returns Array of all heuristic dissectors with their enabled state\n */\n listHeuristicDissectors(): HeuristicInfo[] {\n return vectorToArray(this.lib.listHeuristicDissectors());\n }\n\n /**\n * Enable or disable a heuristic dissector by its unique short name\n *\n * @param shortName Unique short name of the heuristic dissector (e.g., \"mac_nr_udp\")\n * @param enabled Whether to enable or disable the heuristic\n * @returns true if successful, false otherwise\n */\n setHeuristicEnabled(shortName: string, enabled: boolean): boolean {\n return this.lib.setHeuristicEnabled(shortName, enabled);\n }\n}\n\nexport * from \"./types\";\nexport * from \"./utils\";\n"],"names":[],"version":3,"file":"types.d.ts.map","sourceRoot":"../"}
|