-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/topic/robin/gh-3443-skip'
* origin/topic/robin/gh-3443-skip: Spicy: Provide `zeek::skip_input()` to disable deliver to current analyzer.
- Loading branch information
Showing
10 changed files
with
146 additions
and
3 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
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 |
---|---|---|
@@ -1 +1 @@ | ||
6.2.0-dev.121 | ||
6.2.0-dev.123 |
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
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
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
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,4 @@ | ||
### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63. | ||
1, 12 | ||
2, 34 | ||
3, 56 |
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,7 @@ | ||
### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63. | ||
1, True, 28 | ||
event | ||
2, False, 256 | ||
event | ||
3, True, 28 | ||
event |
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,60 @@ | ||
# @TEST-REQUIRES: have-spicy | ||
# | ||
# @TEST-EXEC: spicyz -d -o test.hlto ssh.spicy ./ssh-cond.evt | ||
# @TEST-EXEC: zeek -r ${TRACES}/ssh/single-conn.trace test.hlto %INPUT Spicy::enable_print=T >output | ||
# @TEST-EXEC: btest-diff output | ||
# | ||
# @TEST-DOC: Validate that `skip_input` works for file analyzers. | ||
|
||
# @TEST-START-FILE ssh.spicy | ||
module SSH; | ||
|
||
import spicy; | ||
import zeek; | ||
|
||
public type Banner = unit { | ||
magic : /SSH-/; | ||
version : /[^-]*/; | ||
dash : /-/; | ||
software: /[^\r\n]*/; | ||
}; | ||
|
||
type Context = tuple<counter: uint64>; | ||
|
||
public type Data = unit { | ||
%context = Context; | ||
|
||
: (bytes &size=2)[] foreach { | ||
self.context().counter = self.context().counter + 1; | ||
|
||
print self.context().counter, $$; | ||
|
||
if ( self.context().counter == 3 ) | ||
zeek::skip_input(); | ||
} | ||
}; | ||
|
||
on Banner::%done { | ||
local fid1 = zeek::file_begin("foo/bar"); | ||
zeek::file_data_in(b"12", fid1); | ||
zeek::file_data_in(b"34", fid1); | ||
zeek::file_data_in(b"56", fid1); | ||
zeek::file_data_in(b"78", fid1); | ||
zeek::file_data_in(b"90", fid1); | ||
zeek::file_end(fid1); | ||
} | ||
# @TEST-END-FILE | ||
|
||
# @TEST-START-FILE ssh-cond.evt | ||
|
||
import zeek; | ||
|
||
protocol analyzer spicy::SSH over TCP: | ||
parse originator with SSH::Banner, | ||
port 22/tcp, | ||
replaces SSH; | ||
|
||
file analyzer spicy::Text: | ||
parse with SSH::Data, | ||
mime-type foo/bar; | ||
# @TEST-END-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,44 @@ | ||
# @TEST-REQUIRES: have-spicy | ||
# | ||
# @TEST-EXEC: spicyz -d -o test.hlto test.spicy test.evt | ||
# @TEST-EXEC: zeek -b -r ${TRACES}/dns/long-connection.pcap Zeek::Spicy test.hlto %INPUT "Spicy::enable_print = T;" >output | ||
# @TEST-EXEC: btest-diff output | ||
# | ||
# @TEST-DOC: Validate that `skip_input` works for protocol analyzers. | ||
|
||
redef likely_server_ports += { 53/udp }; # avoid flipping direction after termination | ||
redef udp_inactivity_timeout = 24hrs; # avoid long gaps to trigger removal | ||
|
||
event Test::foo() { print "event"; } | ||
|
||
# @TEST-START-FILE test.spicy | ||
module Test; | ||
|
||
import zeek; | ||
|
||
type Counter = tuple<counter: int64>; | ||
|
||
public type Foo = unit { | ||
%context = Counter; | ||
|
||
data: bytes &eod; | ||
|
||
on %done { | ||
self.context().counter = self.context().counter + 1; | ||
|
||
print self.context().counter, zeek::is_orig(), |self.data|; | ||
|
||
if ( self.context().counter == 3 ) | ||
zeek::skip_input(); | ||
} | ||
}; | ||
|
||
# @TEST-END-FILE | ||
|
||
# @TEST-START-FILE test.evt | ||
protocol analyzer spicy::Test over UDP: | ||
port 53/udp, | ||
parse with Test::Foo; | ||
|
||
on Test::Foo -> event Test::foo(); | ||
# @TEST-END-FILE |