mirror of
https://github.com/zeek/zeek.git
synced 2025-10-02 06:38:20 +00:00
Add btests for new Site::local_nets behavior
This commit is contained in:
parent
c3cde56a0a
commit
b2319ba5d9
10 changed files with 152 additions and 0 deletions
|
@ -0,0 +1,7 @@
|
||||||
|
### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63.
|
||||||
|
10.0.0.1 is private: F
|
||||||
|
10.0.0.1 is local: F
|
||||||
|
no local subnet
|
||||||
|
1.2.3.4 is private: F
|
||||||
|
1.2.3.4 is local: F
|
||||||
|
no local subnet
|
|
@ -0,0 +1,7 @@
|
||||||
|
### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63.
|
||||||
|
10.0.0.1 is private: F
|
||||||
|
10.0.0.1 is local: F
|
||||||
|
no local subnet
|
||||||
|
1.2.3.4 is private: T
|
||||||
|
1.2.3.4 is local: T
|
||||||
|
local subnet is 1.0.0.0/8
|
|
@ -0,0 +1,7 @@
|
||||||
|
### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63.
|
||||||
|
10.0.0.1 is private: T
|
||||||
|
10.0.0.1 is local: T
|
||||||
|
local subnet is 10.0.0.0/8
|
||||||
|
1.2.3.4 is private: F
|
||||||
|
1.2.3.4 is local: T
|
||||||
|
local subnet is 1.0.0.0/8
|
|
@ -0,0 +1,7 @@
|
||||||
|
### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63.
|
||||||
|
10.0.0.1 is private: T
|
||||||
|
10.0.0.1 is local: T
|
||||||
|
local subnet is 10.0.0.0/8
|
||||||
|
1.2.3.4 is private: F
|
||||||
|
1.2.3.4 is local: T
|
||||||
|
local subnet is 1.0.0.0/8
|
|
@ -0,0 +1,7 @@
|
||||||
|
### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63.
|
||||||
|
10.0.0.1 is private: F
|
||||||
|
10.0.0.1 is local: F
|
||||||
|
no local subnet
|
||||||
|
1.2.3.4 is private: T
|
||||||
|
1.2.3.4 is local: T
|
||||||
|
local subnet is 1.0.0.0/8
|
|
@ -0,0 +1,7 @@
|
||||||
|
### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63.
|
||||||
|
10.0.0.1 is private: T
|
||||||
|
10.0.0.1 is local: T
|
||||||
|
local subnet is 10.0.0.0/8
|
||||||
|
1.2.3.4 is private: F
|
||||||
|
1.2.3.4 is local: T
|
||||||
|
local subnet is 1.0.0.0/8
|
|
@ -0,0 +1,7 @@
|
||||||
|
### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63.
|
||||||
|
10.0.0.1 is private: T
|
||||||
|
10.0.0.1 is local: F
|
||||||
|
no local subnet
|
||||||
|
1.2.3.4 is private: F
|
||||||
|
1.2.3.4 is local: F
|
||||||
|
no local subnet
|
|
@ -0,0 +1,7 @@
|
||||||
|
### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63.
|
||||||
|
10.0.0.1 is private: F
|
||||||
|
10.0.0.1 is local: T
|
||||||
|
local subnet is 10.0.0.0/8
|
||||||
|
1.2.3.4 is private: T
|
||||||
|
1.2.3.4 is local: F
|
||||||
|
no local subnet
|
|
@ -0,0 +1,7 @@
|
||||||
|
### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63.
|
||||||
|
10.0.0.1 is private: T
|
||||||
|
10.0.0.1 is local: T
|
||||||
|
local subnet is 10.0.0.0/8
|
||||||
|
1.2.3.4 is private: F
|
||||||
|
1.2.3.4 is local: F
|
||||||
|
no local subnet
|
89
testing/btest/scripts/base/utils/site-defaults.test
Normal file
89
testing/btest/scripts/base/utils/site-defaults.test
Normal file
|
@ -0,0 +1,89 @@
|
||||||
|
# This tests the relationship of Site::local_nets and Site::private_address_space.
|
||||||
|
# The former defaults to the same values as the latter and both are config options.
|
||||||
|
# Therefore both redefs and runtime updates only affect the respective variable,
|
||||||
|
# not the other.
|
||||||
|
#
|
||||||
|
# @TEST-EXEC: zeek -b %INPUT > output
|
||||||
|
# @TEST-EXEC: btest-diff output
|
||||||
|
|
||||||
|
@TEST-START-FILE common.zeek
|
||||||
|
function check_addr(ip: addr)
|
||||||
|
{
|
||||||
|
print fmt("%s is private: %s", ip, Site::is_private_addr(ip));
|
||||||
|
print fmt("%s is local: %s", ip, Site::is_local_addr(ip));
|
||||||
|
|
||||||
|
if ( ip in Site::local_nets_table )
|
||||||
|
print fmt("local subnet is %s", Site::local_nets_table[ip]);
|
||||||
|
else
|
||||||
|
print fmt("no local subnet");
|
||||||
|
}
|
||||||
|
|
||||||
|
event zeek_init()
|
||||||
|
{
|
||||||
|
check_addr(10.0.0.1);
|
||||||
|
check_addr(1.2.3.4);
|
||||||
|
}
|
||||||
|
@TEST-END-FILE
|
||||||
|
|
||||||
|
# (1) The common case: 10/8 is private, implying local, and 1/8 is not.
|
||||||
|
@load ./common
|
||||||
|
|
||||||
|
@TEST-START-NEXT
|
||||||
|
|
||||||
|
# (2) Removing 10/8 from private space implies we remove it from local, too.
|
||||||
|
@load ./common
|
||||||
|
redef Site::private_address_space -= { 10.0.0.0/8 };
|
||||||
|
|
||||||
|
@TEST-START-NEXT
|
||||||
|
|
||||||
|
# (3) Adding 1/8 to private space implies we add it to local, too.
|
||||||
|
@load ./common
|
||||||
|
redef Site::private_address_space = { 1.0.0.0/8 };
|
||||||
|
|
||||||
|
@TEST-START-NEXT
|
||||||
|
|
||||||
|
# (4) Adding 1/8 to local space doesn't change the private one.
|
||||||
|
@load ./common
|
||||||
|
redef Site::local_nets += { 1.0.0.0/8 };
|
||||||
|
|
||||||
|
@TEST-START-NEXT
|
||||||
|
|
||||||
|
# (5) Resetting the local space to 1/8 does not lose the private space.
|
||||||
|
@load ./common
|
||||||
|
redef Site::local_nets = { 1.0.0.0/8 };
|
||||||
|
|
||||||
|
@TEST-START-NEXT
|
||||||
|
|
||||||
|
# (6) Resetting the private space dynamically does propagate into local space.
|
||||||
|
@load ./common
|
||||||
|
|
||||||
|
event zeek_init() &priority=5
|
||||||
|
{
|
||||||
|
Config::set_value("Site::private_address_space", set(1.0.0.0/8));
|
||||||
|
}
|
||||||
|
|
||||||
|
@TEST-START-NEXT
|
||||||
|
|
||||||
|
# (7) Resetting local space dynamically does not lose the private space.
|
||||||
|
@load ./common
|
||||||
|
|
||||||
|
event zeek_init() &priority=5
|
||||||
|
{
|
||||||
|
Config::set_value("Site::local_nets", set(1.0.0.0/8));
|
||||||
|
}
|
||||||
|
|
||||||
|
@TEST-START-NEXT
|
||||||
|
|
||||||
|
# (8) Disable the private-means-local implication and verify defaults.
|
||||||
|
@load ./common
|
||||||
|
|
||||||
|
redef Site::private_address_space_is_local = F;
|
||||||
|
|
||||||
|
@TEST-START-NEXT
|
||||||
|
|
||||||
|
# (9) Disable the private-means-local implication and alter both.
|
||||||
|
@load ./common
|
||||||
|
|
||||||
|
redef Site::private_address_space_is_local = F;
|
||||||
|
redef Site::private_address_space = { 1.0.0.0/8 };
|
||||||
|
redef Site::local_nets = { 10.0.0.0/8 };
|
Loading…
Add table
Add a link
Reference in a new issue