forked from zeek/zeek
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
scan.l: Fix @load-plugin scripts loading
For a plugin loaded via @load-plugin, create a YY_BUFFER_STATE holding the required loads for the implicitly loaded files. In loaded scripts, this generated file will show up with a path of the shared object file of the plugin with the __preload__.zeek and __load__.zeek files loaded by it. Closes zeek#2311
- Loading branch information
Showing
8 changed files
with
157 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 11 additions & 0 deletions
11
testing/btest/Baseline/plugins.enum-bif-plugin/loaded_scripts.log.abs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63. | ||
<...>/enum-bif-plugin.zeek | ||
<...>/enum-before-load-plugin.zeek | ||
<...>/Demo-EnumBif.shared | ||
<...>/__preload__.zeek | ||
<...>/types.zeek | ||
<...>/__load__.zeek | ||
<...>/enumbif.bif.zeek | ||
<...>/__load__.zeek | ||
<...>/enum-after-load-plugin.zeek | ||
<...>/enum-after-load-plugin-end.zeek |
11 changes: 11 additions & 0 deletions
11
testing/btest/Baseline/plugins.enum-bif-plugin/loaded_scripts.log.rel
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63. | ||
<...>/enum-bif-plugin.zeek | ||
<...>/enum-before-load-plugin.zeek | ||
.<...>/Demo-EnumBif.shared | ||
<...>/__preload__.zeek | ||
<...>/types.zeek | ||
<...>/__load__.zeek | ||
<...>/enumbif.bif.zeek | ||
<...>/__load__.zeek | ||
<...>/enum-after-load-plugin.zeek | ||
<...>/enum-after-load-plugin-end.zeek |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63. | ||
EnumBif::MyEnumA | ||
{ | ||
EnumBif::MyEnumB, | ||
EnumBif::MyEnumA | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63. | ||
EnumBif::MyEnumA | ||
{ | ||
EnumBif::MyEnumB, | ||
EnumBif::MyEnumA | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
# @TEST-DOC: Ensure the enum from the .bif file is available right after @load-plugin in bare mode. | ||
# @TEST-EXEC: ${DIST}/auxil/zeek-aux/plugin-support/init-plugin -u . Demo EnumBif | ||
# @TEST-EXEC: cp -r %DIR/enum-bif-plugin/* . | ||
# | ||
# @TEST-EXEC: ./configure --zeek-dist=${DIST} && make | ||
# | ||
# @TEST-EXEC: ZEEK_PLUGIN_PATH=`pwd` zeek -b %INPUT >output.abs | ||
# @TEST-EXEC: grep '[Ee]num' loaded_scripts.log > loaded_scripts.log.abs | ||
# @TEST-EXEC: ZEEK_PLUGIN_PATH=./build zeek -b %INPUT >output.rel | ||
# @TEST-EXEC: grep '[Ee]num' loaded_scripts.log > loaded_scripts.log.rel | ||
# | ||
# @TEST-EXEC: TEST_DIFF_CANONIFIER= btest-diff output.abs | ||
# @TEST-EXEC: TEST_DIFF_CANONIFIER="sed -E 's/(Demo-EnumBif)\.(.*)$/\1.shared/' | $SCRIPTS/diff-remove-abspath" btest-diff loaded_scripts.log.abs | ||
# @TEST-EXEC: TEST_DIFF_CANONIFIER= btest-diff output.rel | ||
# @TEST-EXEC: TEST_DIFF_CANONIFIER="sed -E 's/(Demo-EnumBif)\.(.*)$/\1.shared/' | $SCRIPTS/diff-remove-abspath" btest-diff loaded_scripts.log.rel | ||
|
||
@load misc/loaded-scripts | ||
|
||
@load ./enum-before-load-plugin | ||
|
||
@load-plugin Demo::EnumBif | ||
|
||
@load ./enum-after-load-plugin | ||
|
||
event zeek_init() | ||
{ | ||
print(EnumBif::MyEnumA); | ||
print enum_names(EnumBif::MyEnum); | ||
} | ||
|
||
@load-plugin Demo::EnumBif | ||
|
||
@load ./enum-after-load-plugin-end | ||
|
||
@TEST-START-FILE enum-before-load-plugin.zeek | ||
# empty | ||
@TEST-END-FILE | ||
|
||
@TEST-START-FILE enum-after-load-plugin.zeek | ||
# empty | ||
@TEST-END-FILE | ||
|
||
@TEST-START-FILE enum-after-load-plugin-end.zeek | ||
# empty | ||
@TEST-END-FILE |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
module EnumBif; | ||
|
||
enum MyEnum %{ | ||
MyEnumA, | ||
MyEnumB, | ||
%} |