Lua Personal vs Global Plugin Failure
Summary
When I load the LUA plugins that relies on a function defined in another, I get an "attempt to call global 'function' (a nil value) error". When those same plugins are in the global LUA directory everything succeeds.
Steps to reproduce
I have two files: foo.lua and bar.lua. bar.lua contains one function:
function GetIPAddressString(ip)
local octet1 = bit.rshift(bit.band(0xFF000000, ip), 24)
local octet2 = bit.rshift(bit.band(0x00FF0000, ip), 16)
local octet3 = bit.rshift(bit.band(0x0000FF00, ip), 8)
local octet4 = bit.band(0x000000FF, ip)
return octet1 .. "." .. octet2 .. "." .. octet3 .. "." .. octet4
end
foo.lua consists of this code:
local foo_message = Proto("foo.test", "Foo Tester")
foo_message.fields =
{
}
local data_dis = Dissector.get("data")
function foo_message.dissector(tvbuf, pktinfo, root)
-- Set the protocol column to show this name
pktinfo.cols.protocol:set("FooMessage")
local pktlen = tvbuf:reported_length_remaining()
local tree = root:add(foo_message, tvbuf:range(0,pktlen))
GetIPAddressString(tvbuf:range(8,4):uint())
return pktlen
end
DissectorTable.get("udp.port"):add(2012, foo_message)
What is the current bug behavior?
When the two files are loaded in the global dissector directory, foo.lua has access to the function GetIPAddressString.
When the two files are loaded in the personal dissector directory, the dissector errors out (screenshot below)
What is the expected correct behavior?
Consistency. I'd think it wouldn't matter whether the parsers are installed for one user or all users. I would expect the personal foo.lua to be able to resolve the function within bar.lua.
Sample capture file
Relevant logs and/or screenshots
Build information
Version 4.0.1 (v4.0.1-0-ge9f3970b1527).
Compiled (64-bit) using Microsoft Visual Studio 2022 (VC++ 14.32, build 31332),
with GLib 2.72.3, with PCRE2, with zlib 1.2.12, with Qt 5.15.2, with libpcap,
with Lua 5.2.4, with GnuTLS 3.6.3 and PKCS #11 support, with Gcrypt 1.10.1, with
Kerberos (MIT), with MaxMind, with nghttp2 1.46.0, with brotli, with LZ4, with
Zstandard, with Snappy, with libxml2 2.9.14, with libsmi 0.4.8, with
QtMultimedia, with automatic updates using WinSparkle 0.5.7, with AirPcap, with
SpeexDSP (using bundled resampler), with Minizip, with binary plugins.
Running on 64-bit Windows 11 (21H2), build 22000, with 11th Gen Intel(R)
Core(TM) i7-11700K @ 3.60GHz (with SSE4.2), with 32524 MB of physical memory,
with GLib 2.72.3, with PCRE2 10.40 2022-04-14, with Qt 5.15.2, with Npcap
version 1.71, based on libpcap version 1.10.2-PRE-GIT, with c-ares 1.18.1, with
GnuTLS 3.6.3, with Gcrypt 1.10.1, with nghttp2 1.46.0, with brotli 1.0.9, with
LZ4 1.9.3, with Zstandard 1.5.2, without AirPcap, with light display mode, with
mixed DPI, with LC_TYPE=English_United States.utf8, binary plugins supported.
Observed in Windows and Ubuntu.