Commit graph

6667 commits

Author SHA1 Message Date
Max Kellermann
4b8b6ec559 iosource/Manager: eliminate two std::string copies 2020-02-13 09:16:00 +01:00
Max Kellermann
5215f4756b digest: eliminate the "Reporter.h" include 2020-02-13 09:13:59 +01:00
Max Kellermann
c78fa4bcf9 Val: eliminate the "RE.h" include 2020-02-13 09:13:59 +01:00
Max Kellermann
e98cf0a4a0 Val: eliminate the "BroString.h" include 2020-02-13 09:13:59 +01:00
Max Kellermann
728184ea93 Val: eliminate the "CompHash.h" include 2020-02-13 09:13:59 +01:00
Tim Wojtulewicz
12230ceb83 Check for failure when registering event manager with iosource manager (Coverity 1419398) 2020-02-12 16:39:00 -08:00
Max Kellermann
4aac78cf29 Val: forward-declare class PDict, reduce includes 2020-02-12 10:10:26 +01:00
Max Kellermann
dfac4572e7 Val: eliminate the "Scope.h" include 2020-02-12 10:10:26 +01:00
Jon Siwek
05d7f26b85 Merge branch 'ssh_kex' of https://github.com/MaxKellermann/zeek
* 'ssh_kex' of https://github.com/MaxKellermann/zeek:
  analyzer/protocol/ssh: fix crash vulnerability after duplicate KEX packet
2020-02-12 00:04:40 -08:00
Tim Wojtulewicz
1e499b0831 Reset the number of entries in a dict when calling Clear() 2020-02-11 20:29:06 -05:00
Tim Wojtulewicz
a69463ac46 Code cleanup in Dict.h 2020-02-11 20:28:49 -05:00
Tim Wojtulewicz
817eb2fd87 Add unit testing for the public Dictionary API 2020-02-11 20:16:42 -05:00
Tim Wojtulewicz
d69d0da62e fixup! Use string_view for a couple of Dbg methods 2020-02-11 14:11:22 -08:00
Tim Wojtulewicz
da7749fc43 Add a couple of missing #includes that clang-tidy complains about (clang-diagnostic-error) 2020-02-11 14:11:22 -08:00
Tim Wojtulewicz
9bfe162cad Fix missing namespace that was causing a build error 2020-02-11 14:11:22 -08:00
Tim Wojtulewicz
66c4a93383 Remove unnecessary const from return value (readability-const-return-type) 2020-02-11 14:11:22 -08:00
Tim Wojtulewicz
c5748e4494 Give real variable names to SegmentProfiler objects when defining them (bugprone-unused-raii)
The reason behind this one is that without a real variable name, the profile objects are immediately desctructed and the profiling only happens for the small window when they were valid. If the intention is to profile the method where they were defined, this doesn't actually happen.
2020-02-11 14:11:22 -08:00
Tim Wojtulewicz
3572e38ec2 Mark a few clang-tidy findings as false-positive 2020-02-11 14:11:22 -08:00
Tim Wojtulewicz
d23b15c08f Use std::move in a few places instead of copying a pass-by-value argument (performance-unnecessary-value-param) 2020-02-11 14:11:22 -08:00
Tim Wojtulewicz
5a237d3a3f Use const-references in lots of places (preformance-unnecessary-value-param) 2020-02-11 14:11:18 -08:00
Tim Wojtulewicz
92afe64525 Use string_view for a couple of Dbg methods 2020-02-11 11:02:08 -08:00
Tim Wojtulewicz
eda1b4a23e Use const references over copying variables (performance-unnecessary-copy-initialization, performance-for-range-copy) 2020-02-11 11:02:08 -08:00
Tim Wojtulewicz
c32566420a Use single-character version of string find() (performance-faster-string-find) 2020-02-11 11:02:08 -08:00
Tim Wojtulewicz
95d2af4501 Move constructors/operators should be marked noexcept to avoid the compiler picking the copy constructor instead (performance-noexcept-move-constructor) 2020-02-11 11:02:08 -08:00
Max Kellermann
98c50531bc analyzer/protocol/ssh: fix crash vulnerability after duplicate KEX packet
An attacker can make Zeek crash by posting the KEX packet twice, which
will result in an assertion failure in binpac::datastring::init():

 #0  __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:50
 #1  0x00007ffff5196535 in __GI_abort () at abort.c:79
 #2  0x00007ffff519640f in __assert_fail_base (fmt=0x7ffff52f86e0 "%s%s%s:%u: %s%sAssertion `%s' failed.\n%n", assertion=0x1d33530 "!data_",
     file=0x1d33537 "aux/binpac/lib/binpac_bytestring.h", line=108, function=<optimized out>) at assert.c:92
 #3  0x00007ffff51a3b92 in __GI___assert_fail (assertion=0x1d33530 "!data_", file=0x1d33537 "aux/binpac/lib/binpac_bytestring.h",
     line=108, function=0x1d3356c "void binpac::datastring<unsigned char>::init(const T *, int) [T = unsigned char]") at assert.c:101
 #4  0x0000000000c1e970 in binpac::datastring<unsigned char>::init (this=0x608000d609d0, begin=0x603001bdd1d0 "diffie-hellman-group16-sha512", length=29)
     at aux/binpac/lib/binpac_bytestring.h:108
 #5  0x0000000000e9ab60 in binpac::SSH::SSH_Conn::update_kex (this=0x608000d609a0, algs=..., orig=true) at src/analyzer/protocol/ssh/ssh_pac.cc:205
 #6  0x0000000000ea0d06 in binpac::SSH::SSH2_KEXINIT::Parse (this=0x60b000734680,
     t_begin_of_data=0x621000004753 "\200\275\a%\223\023Y8\204t\235\363!\031I.", t_end_of_data=0x621000004b85 "ޭ\276", <incomplete sequence \357>,
     t_context=0x603001bdcc90, t_byteorder=0) at src/analyzer/protocol/ssh/ssh_pac.cc:1598
 #7  0x0000000000e9f8f4 in binpac::SSH::SSH2_Message::Parse (this=0x608000d60ea0,
     t_begin_of_data=0x621000004753 "\200\275\a%\223\023Y8\204t\235\363!\031I.", t_end_of_data=0x621000004b85 "ޭ\276", <incomplete sequence \357>,
     t_context=0x603001bdcc90, t_byteorder=0) at src/analyzer/protocol/ssh/ssh_pac.cc:1326
 #8  0x0000000000e9d7e1 in binpac::SSH::SSH2_Key_Exchange::Parse (this=0x604001779850,
     t_begin_of_data=0x621000004751 "\006\024\200\275\a%\223\023Y8\204t\235\363!\031I.", t_end_of_data=0x621000004b85 "ޭ\276", <incomplete sequence \357>,
     t_context=0x603001bdcc90, t_byteorder=0) at src/analyzer/protocol/ssh/ssh_pac.cc:1210
 #9  0x0000000000e9c981 in binpac::SSH::SSH_Key_Exchange::ParseBuffer (this=0x603001bdccc0, t_flow_buffer=0x608000d60a20, t_context=0x603001bdcc90,
     t_byteorder=0) at src/analyzer/protocol/ssh/ssh_pac.cc:628
 #10 0x0000000000e9c26c in binpac::SSH::SSH_PDU::ParseBuffer (this=0x604001779810, t_flow_buffer=0x608000d60a20, t_context=0x603001bdcc90)
     at src/analyzer/protocol/ssh/ssh_pac.cc:446
 #11 0x0000000000ea6f04 in binpac::SSH::SSH_Flow::NewData (this=0x604001774690, t_begin_of_data=0x62100000474d "",
     t_end_of_data=0x621000004b85 "ޭ\276", <incomplete sequence \357>) at src/analyzer/protocol/ssh/ssh_pac.cc:3071
 #12 0x0000000000e9a38f in binpac::SSH::SSH_Conn::NewData (this=0x608000d609a0, is_orig=true, begin=0x62100000474d "",
     end=0x621000004b85 "ޭ\276", <incomplete sequence \357>) at src/analyzer/protocol/ssh/ssh_pac.cc:63
 #13 0x0000000000e98335 in analyzer::SSH::SSH_Analyzer::DeliverStream (this=0x7fffffffdd40, len=1080, data=0x62100000474d "", orig=true)
     at src/analyzer/protocol/ssh/SSH.cc:68

With assertions turned off, this would "only" be a memory leak.

This commit fixes the vulnerability by freeing and clearing the
`binpac::datastring` before assigning a new value.
2020-02-11 11:27:17 +01:00
Jon Siwek
0c771ea123 Fix broken links in documentation 2020-02-08 15:48:11 -08:00
Jon Siwek
b268b57194 Update embedded CAF to 0.17.4 2020-02-08 09:40:48 -08:00
Tim Wojtulewicz
9754c2c09f Merge remote-tracking branch 'max/optimize'
* max/optimize:
  plugin/Manager: migrate to std::string_view
  util: optimize the normal_path() common case
  util: pass string_view to without_bropath_component()
  module_util: make GLOBAL_MODULE_NAME constexpr
  Scope: convert Scope::Lookup() and others to template
  Scope: Vars() returns const reference
  Anon: remove unnecessary {map,vector}::clear() calls
  Dict: make the destructor non-virtual
  Obj: make the Location constructors `constexpr`
  Obj: remove unused fields Location::{timestamp,text}
  Obj: remove Location::delete_data, nobody ever sets it
  Obj: make the Location destructor non-virtual
2020-02-07 15:26:30 -07:00
Johanna Amann
febfc30c70 Merge remote-tracking branch 'origin/topic/jsiwek/krb-addrs-and-leak'
* origin/topic/jsiwek/krb-addrs-and-leak:
  Improve kerberos analyzer address and event handling
2020-02-07 14:15:44 -08:00
Johanna Amann
56dda98512 Merge remote-tracking branch 'origin/topic/jsiwek/stabilize-ci'
* origin/topic/jsiwek/stabilize-ci:
  Add environment variable to disable supervisor SIGKILL
  Fix a btest's race condition by handling Pcap::file_done
  Add Pcap::file_done event
  Improve btest timeouts
2020-02-07 09:52:57 -08:00
Johanna Amann
49a21d73d0 Merge remote-tracking branch 'origin/topic/jsiwek/gh-780-indefinite-log-buffer'
* origin/topic/jsiwek/gh-780-indefinite-log-buffer:
  GH-780: Prevent log batches from indefinite buffering
2020-02-07 09:35:29 -08:00
Max Kellermann
298fd125ae plugin/Manager: migrate to std::string_view 2020-02-07 10:56:14 +01:00
Max Kellermann
95e646fca7 util: optimize the normal_path() common case
Speeds up Zeek startup by 2%.
2020-02-07 10:56:14 +01:00
Max Kellermann
98241bbc60 util: pass string_view to without_bropath_component() 2020-02-07 10:56:14 +01:00
Max Kellermann
0548e1255f module_util: make GLOBAL_MODULE_NAME constexpr
This allows the compiler to hard-code pointers to the string without
looking up a global variable at runtime.
2020-02-07 10:56:14 +01:00
Max Kellermann
f1908b6212 Scope: convert Scope::Lookup() and others to template
Allows passing rvalue references which eliminates unnecessary
std::string copies.

This speeds up Zeek startup by 1-2%.
2020-02-07 10:56:14 +01:00
Max Kellermann
f8e9cc0fc5 Scope: Vars() returns const reference
No caller wants to modify the container.
2020-02-07 10:56:14 +01:00
Max Kellermann
acdfd5706e Anon: remove unnecessary {map,vector}::clear() calls
The destructor will do this automatically.
2020-02-07 10:56:14 +01:00
Max Kellermann
05f692995d Dict: make the destructor non-virtual 2020-02-07 10:56:14 +01:00
Max Kellermann
b4966858ce Obj: make the Location constructors constexpr 2020-02-07 10:56:14 +01:00
Max Kellermann
ba445d36f9 Obj: remove unused fields Location::{timestamp,text} 2020-02-07 10:56:14 +01:00
Max Kellermann
91e0860cd4 Obj: remove Location::delete_data, nobody ever sets it
This allows removing the destructor completely, making the class
trivially-destructible.
2020-02-07 10:56:14 +01:00
Max Kellermann
2041921fcb Obj: make the Location destructor non-virtual
Nobody ever derives from this class.  This removes an indirect call
and allows inlining the destructor.

This speeds up Zeek startup by 1-2%.
2020-02-07 10:56:14 +01:00
Jon Siwek
a2b0abe283 Add environment variable to disable supervisor SIGKILL
For use in btests since SIGKILL can otherwise bypass the usual
btest-bg-wait timeout mechanism and make reason for test failures less
obvious.
2020-02-06 17:50:17 -08:00
Jon Siwek
7c124881cd Add Pcap::file_done event
It signals when a pcap file is done being processed.
2020-02-06 17:50:17 -08:00
Johanna Amann
391164c9bc Merge remote-tracking branch 'origin/topic/johanna/table-on-change'
* origin/topic/johanna/table-on-change:
  &on_change: Address feedback of Jon.
  &on_change: incooperate feedback of Jon.
  &on_change wrapup: documentation, tests, whitespacing
  Table expiry now raises &on_change handlers
  Prevent recursion of &on_change handlers.
  Make bro_broker::val_to_data take a const Val* instead of a Val
  &on_change: add insertion/change notifications.
  &on_change working for removals from tables.
  Change signature of &on_change handler
  Beginning implementation of &on_change for tables.
2020-02-06 15:01:03 -08:00
Johanna Amann
b69a059b1a &on_change: Address feedback of Jon.
Forgot to commit a file *sigh*
2020-02-06 14:42:03 -08:00
Johanna Amann
d6d2bbe878 &on_change: incooperate feedback of Jon. 2020-02-06 14:40:38 -08:00
Tim Wojtulewicz
23e82b8121 Restore accidentally reverted change to fix FreeBSD 11 build 2020-02-06 10:25:21 -07:00
Jon Siwek
3ee5f5fcaf Update CAF to current 0.17.4 release branch 2020-02-05 21:47:28 -08:00