-
Notifications
You must be signed in to change notification settings - Fork 9
zeek/spicy: Built-in spicy modules cannot be replaced. #137
Comments
Replacement was originally meant for replacing Zeek's traditional analyzers, not Spicy analyzers, so not totally surprised. Do you have a short example showing the problem (specifically, where exactly are the "builtin-in Spicy modules" coming from / loaded from?) |
FTR, I tried to reproduce this, but there seems to be an issue setting up builtin Spicy analyzers with the default build, see zeek/zeek#2442. A proper reproducer would certainly help. |
Sorry, the original ticket is explained slightly wrong. It's intending to say that with a builtin spicy-plugin, spicy analyzers don't do the |
Unless I misunderstand what you are describing, I do not see this when installing a Spicy analyzer in the upstream image
I also looked into concrete logs. If I e.g., run https://github.com/zeek/spicy-pe/blob/main/tests/traces/ftp-pe.pcap through zeek I see the expected analyzers in Could you provide a reproducer that shows the problem? |
@jlucovsky shared his analyzer with me privately, and I can confirm the issue. To reproduce: $ zkg create --features spicy-analyzer --packagedir=teredo --user-var name=Teredo --user-var namespace=foo Adjust protocol analyzer spicy::Teredo over TCP:
parse with foo::Teredo,
replaces Teredo,
port 8080/tcp; Install the analyzer with I then see both the builtin Teredo analyzer and the just installed one enabled at the same time: $ zeek -NN | grep -i 'Teredo '
[Analyzer] spicy_Teredo (ANALYZER_SPICY_TEREDO, enabled)
Zeek::Teredo - Teredo packet analyzer (built-in)
[Packet Analyzer] Teredo (ANALYZER_TEREDO) I tried drilling down more where this came from and an important factors seem to be that replaced analyzer has a name after Since nothing in spicy-plugin cares about the order of registered analyzers and it instead calls Zeek APIs (see e.g., here or here I suspect this is an issue in Zeek proper. |
With above reproducer the smoking gun is in HILIT's $ HILTI_DEBUG=zeek zeek -N >/dev/null
[zeek] Registering TCP protocol analyzer spicy_Teredo with Zeek
[zeek] Scheduling analyzer for port 8080/tcp
[zeek] Done with post-script initialization If the analyzer actually replaced another analyzer we'd expect mention of that in the output, Lines 114 to 118 in ab743fb
The issue here seems to be that spicy-plugin uses It looks like one fix for this might be to initialize components eagerly, but it is unclear to me what other unintended side effects that can have. |
Another possible fix with probably would be to defer adding of spicy-plugin analyzers to a later point, e.g., in |
I'll move this to |
On closer inspection, I think the problem is a different one: that reproducer attempts to replace packet analyzer with a protocol analyzer. That can't work semantically, but the real problem is that packet analyzers currently do not support
I changed the reproducer to use
|
On the upside, Zeek just learned to disable packet analyzers, so I believe we should be able to implement this now. zeek/zeek#2443 |
Ok, I can now also reproduce the original problem: the key is to have both (1) spicy-plugin built into Zeek, and (2) load the HLTO through |
Replacing a Zeek-side analyzer didn't work if (a) the Spicy plugin was built into Zeek (like Zeek does by default now), (b) the plugin was initialized after that Zeek-side analyzer (which happened with names lexicographically sorting after "Spicy"), and (c) the HLTO was loaded from the module search path (instead of from the command line). For regression testing, this changes one of our existing replacement tests to load the HLTO through the search path. Closes #137.
Replacing a Zeek-side analyzer didn't work if (a) the Spicy plugin was built into Zeek (like Zeek does by default now), (b) the plugin was initialized after that Zeek-side analyzer (which happened with names lexicographically sorting after "Spicy"), and (c) the HLTO was loaded from the module search path (instead of from the command line). For regression testing, this changes one of our existing replacement tests to load the HLTO through the search path. Closes #137.
* origin/topic/robin/gh-137-replaces: Catch attempts to replace an analyzer with one of a different kind. Fix analyzer replacement.
When Zeek is built with built-in spicy modules and a custom spicy module is loaded that uses the
replaces
keyword for an existing spicy module, the existing spicy module is not replaced -- it's left loaded along with the custom spicy module which requested the replacement.The text was updated successfully, but these errors were encountered: