builtin-plugins/Zeek_JavaScript/__load__.zeek
- JavaScript
- Namespace:
JavaScript
Summary
Redefinable Options
Node.js default behavior is to exit a process on uncaught exceptions. |
|
Vector of filenames to compile/execute after the bootstrap file. |
|
Be very conservative. |
|
The Javascript code executed for bootstrapping. |
|
If set to T, installs a SIGUSR1 handler and thread to start the Node.js / V8 inspector. |
|
Allows to change process state (uid, title, cwd, …). |
|
Detailed Interface
Redefinable Options
- JavaScript::exit_on_uncaught_exceptions
-
Node.js default behavior is to exit a process on uncaught exceptions. Specifically exceptions in timer callbacks are problematic as a throwing timer callback may break subsequently scheduled timers.
Set this to F in order to just keep going when errors happen. Note, if you see any Uncaught errors, this likely means the Javascript state is corrupt.
- JavaScript::files
-
Vector of filenames to compile/execute after the bootstrap file.
- JavaScript::initial_heap_size_in_bytes
-
Be very conservative.
- JavaScript::main_script_source
- Type:
- Attributes:
- Default:
"const module_mod = require('module')\x0aconst publicRequire = module_mod.createRequire(process.cwd() + '/');\x0aglobalThis.require = publicRequire;\x0a\x0aglobalThis.zeek_javascript_init = async () => {\x0a const zeek = process._linkedBinding('zeekjs').zeek;\x0a // Helper for zeek record rendering.\x0a zeek.flatten = (obj, prefix, res) => {\x0a res = res || {}\x0a for (const k in obj) {\x0a const nk = prefix ? `${prefix}.${k}` : k\x0a const v = obj[k]\x0a\x0a // Recurse for objects, unless it's actually an array, or has a\x0a // custom toJSON() method (which is true for the port objects).\x0a if (v !== null && typeof(v) == 'object' && !Array.isArray(v) && !('toJSON' in v)) {\x0a zeek.flatten(v, nk, res)\x0a } else {\x0a res[nk] = v\x0a }\x0a }\x0a return res\x0a }\x0a\x0a const m = new module_mod();\x0a // Compile a new module that imports all .js files found using import().\x0a //\x0a // https://stackoverflow.com/a/17585470/9044112\x0a return m._compile('const ps = []; zeek.__zeek_javascript_files.forEach((fn) => { ps.push(import(fn)); }); return Promise.all(ps);', process.cwd() + '/');\x0a};\x0a// Add a global zeek object from the linked zeekjs binding\x0aglobalThis.zeek = process._linkedBinding('zeekjs').zeek;\x0a"
The Javascript code executed for bootstrapping. This comes fairly straight from the embedding guide to support using require() with filesystem paths in the process working directory.
- JavaScript::owns_node_inspector
-
If set to T, installs a SIGUSR1 handler and thread to start the Node.js / V8 inspector.
See Node.js EnvironmentFlags API documentation for details. https://github.com/nodejs/node/blob/v22.11.0/src/node.h#L631
- JavaScript::owns_process_state
-
Allows to change process state (uid, title, cwd, …).
See Node.js EnvironmentFlags API documentation for details. https://github.com/nodejs/node/blob/v22.11.0/src/node.h#L627