Commit graph

6667 commits

Author SHA1 Message Date
Jon Siwek
655c142d01 Merge branch 'patch-2' of https://github.com/The-Alchemist/zeek
* 'patch-2' of https://github.com/The-Alchemist/zeek:
  fix another minor typo
2019-09-03 10:36:16 -07:00
Jan Grashoefer
b216e9cbc9 Improve dpd_late_match event generation. 2019-08-30 20:19:24 +02:00
The Alchemist
a4e20bb58a
fix another minor typo 2019-08-29 16:10:26 -04:00
The Alchemist
a5e4720204
fix minor typo 2019-08-29 16:09:27 -04:00
Jon Siwek
39161e2192 CID 1404734: fix NetSessions::MemoryAllocation() 2019-08-29 13:06:09 -07:00
Johanna Amann
bb98559c0d Merge remote-tracking branch 'origin/topic/jsiwek/gh-545-weird-addl'
* origin/topic/jsiwek/gh-545-weird-addl:
  GH-545: add "addl" parameter to flow_weird and net_weird events
2019-08-28 14:27:53 -07:00
Johanna Amann
1dd0b2e292 Merge remote-tracking branch 'origin/topic/jsiwek/gh-554-file-signature-optimizations'
* origin/topic/jsiwek/gh-554-file-signature-optimizations:
  GH-554: don't init PIA endpoint matchers if there's only file-magic
  GH-554: remove use of file magic in protocol-based signature logic
2019-08-28 11:39:13 -07:00
Johanna Amann
ec57894a85 Merge remote-tracking branch 'origin/topic/jsiwek/gh-541-ntlm-fix'
* origin/topic/jsiwek/gh-541-ntlm-fix:
  GH-541: add test cases for NTLM AV Pair sequence handling
  GH-541: fix handling of NTLM AV Pair sequences
2019-08-28 11:33:49 -07:00
Johanna Amann
81dea943d3 Merge remote-tracking branch 'origin/topic/jsiwek/simplify-tag-error-check'
* origin/topic/jsiwek/simplify-tag-error-check:
  Make Tag::Error values constant
  Simplify operator bool()'s used for Tag error checks
2019-08-28 10:58:54 -07:00
Johanna Amann
33958fa3da Merge remote-tracking branch 'origin/topic/jsiwek/unspecified-ip-constants'
* origin/topic/jsiwek/unspecified-ip-constants:
  Add/use unspecified IPAddr constants
2019-08-28 09:17:44 -07:00
Jon Siwek
316e8bb671 GH-554: don't init PIA endpoint matchers if there's only file-magic
The logic for initializing PIA endpoint matchers was previously
skipped if "there's no global rule matcher", and that's only true
when no signature files get loaded.

But when using `zeek -b`, some file-magic signatures still get loaded
by default, so the PIA endpoint matchers still get initialized even
though they don't need to be -- file-magic patterns play no part
in PIA.

For typical use-cases (not using the `-b` flag), this change won't
help any, but we do at least use `-b` often within the test suite.
2019-08-27 16:32:30 -07:00
Jon Siwek
8c9b3bd3ae GH-554: remove use of file magic in protocol-based signature logic
This can be a significant performance/memory improvement since
otherwise the protocol-based rule matching logic ends up superfluously
creating file-matching state per file-matcher per connection/endpoint.
2019-08-27 16:16:39 -07:00
Jon Siwek
289a1e2e8e Merge branch '555-smb3-negotiate-context-fix' of https://github.com/mad/zeek
- Fixed the context list padding to only be used for dialect 0x0311.
  The new test case includes an example where parsing the optional
  padding would fail for another dialect.

* '555-smb3-negotiate-context-fix' of https://github.com/mad/zeek:
  Fix for smb3 negotiate context
2019-08-27 10:08:42 -07:00
Pavel Ershov
de4a83206d Fix for smb3 negotiate context 2019-08-27 12:21:03 +03:00
Tim Wojtulewicz
fa62e5b48c main: Properly close down SSL/sqlite at shutdown if net_run never started up 2019-08-26 10:31:17 -07:00
Tim Wojtulewicz
7edebe179f main: Finish processing program arguments before setting up SSL/sqlite 2019-08-26 10:29:43 -07:00
Jon Siwek
13af91febb Make Tag::Error values constant 2019-08-23 16:31:45 -07:00
Jon Siwek
b41e102a7c Simplify operator bool()'s used for Tag error checks 2019-08-23 11:31:18 -04:00
Jon Siwek
ba929ce2c4 Add/use unspecified IPAddr constants
The analyzer-scheduling code was otherwise frequently converting the
unspecified v4/v6 addresses from strings.
2019-08-23 11:15:02 -04:00
Jon Siwek
a9f14bf503 GH-541: fix handling of NTLM AV Pair sequences
Empty AV Pair sequences or AV Pair sequences that lack a terminator
could cause accesses past the end of the parsed vector.
2019-08-23 07:22:18 -04:00
Jon Siwek
e7a2ee6edc Merge remote-tracking branch 'origin/topic/timw/mapping'
- Minor whitespace and comment adjustments

* origin/topic/timw/mapping:
  Fix unit tests for new ordering from NetSessions::Drain
  Change FragReassembler to use a tuple as a key and use std::map for fragments in Sessions
  Rework Session/Connection tracking to use a std::map instead of PDict
2019-08-23 06:28:44 -04:00
Seth Hall
1a07df196e Zeekify thread naming.
I copied the same style that caf uses ("zk" with single dot and no space).
This gives some consistency with caf and avoids us wasting more
space beyond "bro: ".  OSs only give 16 characters for thread names
so anything we can gain here is nice.
2019-08-22 22:10:27 -04:00
Jan Grashoefer
5901b6d33c Allow to handle late DPD matches.
If dpd_match_only_beginning is disabled, matches of protocol signatures
can be handeld using protocol_late_match. To prevent further matching in
this case, dpd_late_match_stop may be activated.
2019-08-22 19:00:11 +02:00
Tim Wojtulewicz
a4b8aa1f30 Change FragReassembler to use a tuple as a key and use std::map for fragments in Sessions 2019-08-21 09:24:02 -04:00
Tim Wojtulewicz
57f29f3e7c Rework Session/Connection tracking to use a std::map instead of PDict 2019-08-21 09:24:02 -04:00
Jon Siwek
2d7c926291 GH-545: add "addl" parameter to flow_weird and net_weird events 2019-08-20 22:45:22 -04:00
Robin Sommer
8ab0650c1e Merge remote-tracking branch 'origin/topic/jsiwek/gh-532-improve-disable-analyzer'
Includes fix for potential iterator invalidation during iteration.

* origin/topic/jsiwek/gh-532-improve-disable-analyzer:
  GH-532: improve disable_analyzer BIF
2019-08-16 18:46:35 +00:00
Jon Siwek
6255ab6584 Fix misc. Coverity warnings 2019-08-14 16:19:56 -07:00
Jon Siwek
47235b57a6 Merge remote-tracking branch 'origin/topic/timw/deprecate-int-types'
* origin/topic/timw/deprecate-int-types:
  Deprecate the internal int/uint types in favor of the cstdint types they were based on

Merge adjustments:
  * A bpf type mistakenly got replaced (inside an unlikely #ifdef)
  * Did a few substitutions that got missed (likely due to
    pre-processing out of DEBUG macros)
2019-08-14 15:49:24 -07:00
Jon Siwek
03c50fe520 Change file_analysis::Manager::ignored to use std::set 2019-08-14 13:48:39 -07:00
Jon Siwek
396c1cb066 Update documentation for string_to_pattern BIF 2019-08-14 13:22:02 -07:00
Jon Siwek
94c380297e Merge remote-tracking branch 'origin/topic/timw/easy-pdict-replacements'
* origin/topic/timw/easy-pdict-replacements:
  Cleanups related to PDict -> std::map replacements
  Remove other simple uses of PDict
  Protocols: Remove uses of PDict
  g_dbgfilemaps: Remove uses of PDict
  Scope: remove uses of PDict
  DFA: remove uses of PDict
  EventRegistry: remove uses of PDict
2019-08-13 20:16:02 -07:00
Jon Siwek
87f85ecca1 Cleanups related to PDict -> std::map replacements 2019-08-13 19:57:42 -07:00
Tim Wojtulewicz
e6558d1f19 Remove other simple uses of PDict 2019-08-13 19:57:42 -07:00
Tim Wojtulewicz
8beb710a5e Protocols: Remove uses of PDict 2019-08-13 19:57:42 -07:00
Tim Wojtulewicz
d0e8af9343 g_dbgfilemaps: Remove uses of PDict 2019-08-13 19:57:42 -07:00
Tim Wojtulewicz
a3deb0446c Scope: remove uses of PDict 2019-08-13 19:57:42 -07:00
Robin Sommer
00987c4411 Merge remote-tracking branch 'origin/topic/timw/clang-tidy'
* origin/topic/timw/clang-tidy:
  Change over to whitelisting clang-tidy options instead of blacklisting
  Use FindClangTidy in the cmake submodule to make things easier
2019-08-13 23:45:16 +00:00
Robin Sommer
ecd6139d09 Merge remote-tracking branch 'origin/topic/jsiwek/replace-pcap-lookupdev'
* origin/topic/jsiwek/replace-pcap-lookupdev:
  Replace use of deprecated pcap_lookupdev()
2019-08-13 23:02:43 +00:00
Robin Sommer
8167320bb7 Merge remote-tracking branch 'origin/topic/jsiwek/fatal-error-exit-behavior'
* origin/topic/jsiwek/fatal-error-exit-behavior:
  Use _exit() in Reporter::FatalError
2019-08-13 22:40:06 +00:00
Jon Siwek
9ccf3549fd Merge remote-tracking branch 'origin/topic/timw/360-log-gzip'
* origin/topic/timw/360-log-gzip:
  Add new LogAscii::gzip_file_extension option.

Adjusted documentation during merge.
2019-08-13 13:49:45 -07:00
Jon Siwek
6e48bdeb38 Merge remote-tracking branch 'origin/topic/jazoff/memory-reduction-contentline'
* origin/topic/jazoff/memory-reduction-contentline:
  Remove redundant buffering in contentline

Adjusted NVT analyzer during merge for cases where it may have been
assuming the buffer was already resized before DoDeliver().
2019-08-13 12:04:15 -07:00
Jon Siwek
c91b12863e Add tests for {http,mime}_all_headers events
And remove unnecessary check for mime_all_headers in HTTP entities
(they ony raise the http_all_headers event, never mime_all_headers).
2019-08-13 11:28:00 -07:00
Jon Siwek
7fc664b545 Merge remote-tracking branch 'origin/topic/jazoff/memory-reduction-mime'
* origin/topic/jazoff/memory-reduction-mime:
  Avoid buffering all http headers

Adjusted during merge:
  * whitespace
  * logic for HTTP needs to consider whether either mime_all_headers
    or http_all_headers events are being used
2019-08-12 19:34:42 -07:00
Jon Siwek
41882263db Use _exit() in Reporter::FatalError
Using exit() here may generally not work well since:

* That will result in calling global destructors

* We have global state that we potentially modify at run-time and
  are in the middle of modiying at the time the FatalError occurs.
  E.g. out-of-memory is one situation where it's likely we could
  call the dtor of an object in which operation on it's internal
  state is no longer consistent/safe.
2019-08-12 14:13:46 -07:00
Tim Wojtulewicz
b42e726a8e Use FindClangTidy in the cmake submodule to make things easier 2019-08-12 13:59:17 -07:00
Tim Wojtulewicz
54752ef9a1 Deprecate the internal int/uint types in favor of the cstdint types they were based on 2019-08-12 13:50:07 -07:00
Jon Siwek
a1c5eddb95 GH-532: improve disable_analyzer BIF
- Add an extra "prevent" parameter (default value of false), which
  helps prevent the same analyzer type from being attached in the
  future.  It's useful in situations where you want to disable early
  on, but a DPD signature may still trigger later and re-attach
  the same analyzer.  E.g. when not using this flag, but calling
  disable_analyzer() inside an http_request event, will remove the
  HTTP analyzer that was attached due to well-known-port, but a later
  DPD signature match from upon seeing the HTTP reply will end up
  attaching another HTTP analyzer.  More surprising is that upon
  re-attaching that analyzer, you'll get the same http_request as
  before since the DPD buffer will get replayed into the new analyzer.

- Fixes disable_analyzer() to work when called even earlier, like
  within the protocol_confirmation event.  At that time, the
  Analyzer tree may have not properly added the new analyzer into
  Analyzer::children yet, but rather the temporary waiting list,
  Analyzer::new_children.  Analyzer::RemoveChildAnalyzer previously
  did not inspect the later list.

- Fixes disable_analyzer() when called on an analyzer added to the
  tree via TCP_Analyzer::AddChildPacketAnalyzer.  TCP_Analyzer
  keeps track of such children in its own list,
  TCP_Analyzer::packet_children, which the previous
  Analyzer::RemoveChildAnalyzer implementation didn't inspect.
2019-08-09 20:03:26 -07:00
Jon Siwek
6af1bf18ac Replace use of deprecated pcap_lookupdev()
libpcap 1.9.0 has started deprecating this function in favor
of pcap_findalldevs()
2019-08-07 09:46:41 -07:00
Jon Siwek
dc5aca6854 GH-527: fix parsing of MQTT Remaining Length field
Packet length is encoded in up to four bytes, with MSB (0x80)
indicating if there's more bytes in the representation still to follow.
The comparison/bitwise-mask wasn't correctly testing the MSB.

Coverity CID 1403964
2019-08-06 14:47:03 -07:00