Commit Graph

566 Commits

Author SHA1 Message Date
Brian Sipos ce0592514c BPv7: Add Bundle Protocol version 7 and BPSec dissectors from dtn-wireshark 2021-10-10 13:27:17 +00:00
João Valverde 9d87c4712e dfilter: Fix parsing of value strings
If we have a STRING value in an expression and a numeric comparison
we must also check if it matches a value string before throwing
a type error.

Add appropriate tests to the test suite.

Fixes 4d2f469212.
2021-10-08 18:53:15 +01:00
João Valverde 4a2b18a9c0 dfilter: Skip equality test and add explanation
Also fix a byte typo in the 'eth' filter expression.
2021-10-07 13:21:32 +00:00
João Valverde 39036a0a30 dfilter: Add some more syntax tests 2021-10-05 19:19:36 +01:00
João Valverde d45ba348fd dfilter: Strengthen sanity check for range
Allow an entity in the grammar as range body. Perform a stronger
sanity check during semantic analysis everywhere a range is used.
This is both safer (unless we want to allow FIELD bodies only, but
functions are allowed too) and also provides better error messages.

Previously a range of range only compiled on the RHS. Now it can
appear on both sides of a relation.

This fixes a crash with STRING entities similar to #10690 for
UNPARSED.

This also adds back support for slicing functions that was removed
in f3f833ccec (by accident presumably).

Ping #10690
2021-10-05 16:39:41 +01:00
Gerald Combs ce22d958a8 Test: Add external tests.
Add test/suite_external.py, which can dynamically generate tests from a
configuration file. This is intended to make happy-shark useful, but it
should make it easy to add simple TShark tests elsewhere.

The configuration file format must currently be JSON as described in the
Developer's Guide.
2021-10-01 23:40:17 +00:00
João Valverde d6836d103d dfilter: Add test for "deprecated" tokens
Tokens that are (so-called) deprecated produce a warning/hint to
the user in the UI.
2021-09-30 17:26:19 +01:00
Brian Sipos abd0f1183f COSE dissector from dtn-wireshark project 2021-09-29 08:51:13 +00:00
João Valverde 481d0716e5 MSYS2: Test commands in pipes need quoting
At least using MSYS2 python (that uses system() that uses CMD.EXE)
we must quote every command in a pipe, otherwise the "'C:' is not
recognized as an internal or external program" error occurs.
2021-09-27 16:45:58 +00:00
João Valverde ef06593c13 MSYS2: Fix detection of test suite binaries
Fix hack to find test binaries. We must only search in run/<config>
if using Visual Studio.
2021-09-27 16:45:58 +00:00
Nardi Ivan 3cb302f05b HTTP2, QUIC: fix "Follow Stream"
"Follow Stream" functionality assumes that all data in a single packet
belongs to the same stream. That is not true for HTTP2 and QUIC, where
we end up having data from unrelated streams.

Filter out the unwanted data directly in the protocol dissector code with
a custom `tap_handler` (as TCP already does).

Close #16093
2021-09-13 15:13:10 +00:00
David Perry 5076aee044 [#17517] capinfos: machine-readable filetype/encap 2021-09-10 04:25:13 +00:00
Joey Salazar 28dbab369d git: Add test cases
Add git dissection test cases to existing testing suite for: finding git
packets, finding the Git Protocol version, finding the right amount of
Flush and Delimiter packets, not finding Malformed packets.

Part of #17093
2021-08-30 06:34:52 +00:00
David Perry dc7089e831 Carry drop count/packet ID/queue ID as options on packet block 2021-07-19 21:25:40 +00:00
David Perry 06ed6930dc Carry EPB flags as an option on the packet block
As requested by [this comment][1] on !2859, move `pack_flags` from a
dedicated field in `wtap_rec` to a block option on the packet block in
`wtap_rec.block`.

[1]: https://gitlab.com/wireshark/wireshark/-/merge_requests/2859#note_615984624
2021-07-12 12:41:57 -04:00
João Valverde 89acb935bc wsutil: Start adding a test suite 2021-07-11 14:39:13 +00:00
David Perry 73087d6fb4 Use wtap_blocks for packet comments
Mostly functioning proof of concept for #14329. This work is intended to
allow Wireshark to support multiple packet comments per packet.

Uses and expands upon the `wtap_block` API in `wiretap/wtap_opttypes.h`.
It attaches a `wtap_block` structure to `wtap_rec` in place of its
current `opt_comment` and `packet_verdict` members to hold OPT_COMMENT
and OPT_PKT_VERDICT option values.
2021-07-07 18:40:24 +00:00
Thomas Dreibholz 1c40f936e2 Using col_append_sep_fstr() instead of prepending "NetPerfMeter" label. 2021-06-28 14:39:04 +00:00
Thomas Dreibholz f4c48c5350 NetPerfMeter display improvement:
Prepend protocol name "NetPerfMeter" with col_prepend_fence_fstr(), instead of
overwriting the underlying Transport Layer protocol name.
2021-06-28 14:39:04 +00:00
Vasil Velichkov 6783ca027e Skip two protobuf dissector tests when LUA is not available
Both tests are using LUA scripts and both fails when it is not avialble.
2021-06-25 12:29:14 +00:00
Chuck Craft 54baebad48 Lua: reconcile expert info groups; add PI_ASSUMPTION 2021-06-21 15:27:51 +00:00
Paul Offord 6472051771 solved code conflicts pre rebase 2021-06-21 12:49:47 +00:00
João Valverde c0a734bdf4 tests: Remove duplicate test 2021-06-20 20:51:00 +01:00
João Valverde b20c8a6029 wslog: Update test suite 2021-06-14 13:13:12 +01:00
Thomas Dreibholz d346ab21d6 Updated unit test with relative sequence numbers. 2021-06-09 05:08:11 +00:00
Guy Harris eaa4a7022b file-pcapng: redo the way we dissect the data in blocks.
Create a tvbuff that covers the data portion of a block, and use that to
dissect all data in the block, including but not limited to the options.

Catch ReportedBoundsError exceptions and treat them as an indication
that the block length was too short - add an expert info to the block
length item indicating that.

Have separate routines for each block type that dissects the data in
that block type.

While we're at it, check whether the trailing block length is equal to
the  header block length and, if not, report an error in the trailing
block length.

Fix the tests to match.
2021-06-04 16:46:40 -07:00
Thomas Dreibholz 6e5081474e SCTP: Display basic TSN information with packets 2021-06-04 08:04:31 +00:00
Daniel Dulaney 62af671bf3 Lua: add DissectorTable.try_heuristics() function
Add DissectorTable.try_heuristics(name, tvb, pinfo, tree). Previously,
there was no way for a Lua plugin to run an existing heuristic
dissector.

Based on Gerrit change 18718. Closes #17220.
2021-03-26 07:15:16 +00:00
Dario Lombardo e6df130762 test: add missing raw string regex identifier. 2021-03-25 08:16:10 +00:00
Guy Harris b61fd6d76a dfilter, ftypes: get rid of FT_PCRE.
It's not a valid field type, it's only a hack to support regular
expression matching in packet-matching expressions.

Instead, in the packet-matching code, have a separate syntax tree type
for Perl-compatible regular expressions, and a separate instruction to
load one into a register, and have the "matching" operator for field
types take a GRegex * as the second argument.
2021-03-21 03:27:44 -07:00
Mikael Kanstrup d3235c685b ieee80211: Support decrypting Fast BSS Transition with roaming
Support decrypting captures with Fast BSS Transition roaming present
by now also scanning (re)association frames for relevant information
elements and feeding it into the dot11decrypt engine.

Both (re)association request and response frames are scanned to allow
for potentially missing one frame and still be able to derive PTKs
needed for successful decryption.

Closes #17145

Change-Id: I08436582e4f83695dc606ddb92ff442d6258ef9b
2021-03-16 14:36:26 +00:00
Chuck Craft 63b484c91a Qt: Copy->Value - don't zero pad hex values
Closes #17276
Update test scripts and datafiles for corrected output format.
2021-03-11 07:17:58 +00:00
João Valverde e240ec3d2d NetPerfMeter: Drop "protocol" from the name 2021-03-07 18:09:10 +00:00
Thomas Dreibholz e60bdb8d9a Replaced large NetPerfMeter captures by one small capture.
Changes:
* Replaced large netperfmeter-dccp.pcapng.gz and netperfmeter.pcap.gz captures
by one common small netperfmeter.pcapng.gz for the suites follow_dccp and
netperfmeter.
* Updated test suites "follow_dccp" and "netperfmeter".
2021-03-04 20:27:24 +01:00
João Valverde e20ca8e9e8 tests: skip plugin count test if feature is disabled 2021-02-26 15:57:10 +00:00
Thomas Dreibholz 2e7f2ffb7a
Added "Follow DCCP stream" feature.
This pull request includes:
* The "Follow DCCP stream" feature.
* Updated docbook documentation for the "Follow DCCP stream" feature.
* Test for the feature.
* Corresponding packet trace for the test.
2021-02-22 12:48:46 +01:00
Thomas Dreibholz dc3e92f638
Added NetPerfMeter test suite. 2021-02-21 18:23:48 +01:00
Thomas Dreibholz 6737430111 Added NetPerfMeter test trace. 2021-02-21 13:57:04 +00:00
John Thacker ddd8f0ab61 tests: Look for softhsm2 in more places
Fedora and RHEL/CentOS put libsofthsm2.so in a different location
than Debian/Ubuntu, so look there too. This causes test_tls_pkcs11
to pass instead of being skipped (if softhsm2 and the other
prerequisites are installed.)
2021-02-20 15:07:49 +00:00
João Valverde ba23c3b316 tests: Add argument to trim output to a reasonable size
The output of the "values" tshark glossary has over 1.3M lines. Writing
this to stdout with some test failures is problematic in a number of ways.
Also it's not helpful because stderr is written after stdout (not interleaved)
so there is no output context to the error message. The error/warning
message (from stderr, that triggered the test failure) needs to be
sufficient to provide a good understaning of the test failure.

The output is trimmed to first+last N lines. Some lines are kept as
informational and because it may be useful if the program aborts.

Fixes #17203.
2021-02-04 17:00:36 +00:00
Mikael Kanstrup fbb9056d20 dot11decrypt: Add partial FT-EAP decryption support
Add partial support for decrypting captures with connections
established using FT-EAP. To support deriving keys for FT-EAP
the MSK is needed. This change adds MSK as a valid IEEE 802.11
protocol input key type preference as well.

Note that FT-EAP support comes with the following imitations:

- Keys can only be derived from the FT 4-way handshake messages.
- Roaming is not supported.
2021-01-20 16:10:12 +00:00
Mikael Kanstrup 2306cbddb9 dot11decrypt: Support decrypting FT initial mobility domain
Add partial support for decrypting captures with connections
established using FT BSS Transition (IEEE 802.11r).

FT BSS Transition decryption comes with the following limitations:

- Only FT-PSK is supported.
- Keys can only be derived from the FT 4-way handshake messages.
- Roaming is not supported.
2021-01-20 16:10:12 +00:00
Huang Qiangxiong cd2d35c1d2 Protobuf: fix bugs that parsing complex syntax .proto files
Some .proto files contain complex syntax that does not be described in protobuf official site
(https://developers.google.com/protocol-buffers/docs/reference/proto3-spec).

1. Update 'epan/protobuf_lang_parser.lemon' to:
1) Support complex option names format (EBNF):
    optionName = ( ident | "(" fullIdent ")" ) { "." ( ident | "(" fullIdent ")" ) }
for example, "option (complex_opt2).(grault) = 654;".
2) Make enum body support 'reserved' section (EBNF):
    enumBody = "{" { reserved | option | enumField | emptyStatement } "}"
3) Allow the value of field or enumValue option to be "{ ... }" other than constant:
    enumValueOption = optionName  "=" ( constant | customOptionValue ) ";"
    fieldOption = optionName  "=" ( constant | customOptionValue ) ";"
4) Allow 'group' section missing 'label' (for example, in 'oneof' section).
5) Make 'oneof' section support 'option' and 'group' sections (BNF):
    oneof = "oneof" oneofName "{" { oneofField | option | group | emptyStatement } "}"
6) Ignore unused 'extend' section.
7) Fix the bug of one string being splitted into multi-lines.

2. Update 'epan/protobuf_lang_tree.c' to:
8) Fix the bug of parsing repeated option.

3. Update 'test/suite_dissection.py' to add test case for parsing complex syntax .proto files:
  test/protobuf_lang_files/complex_proto_files/unittest_custom_options.proto
  test/protobuf_lang_files/complex_proto_files/complex_syntax.proto
and dependency files:
  test/protobuf_lang_files/well_know_types/google/protobuf/any.proto
  test/protobuf_lang_files/well_know_types/google/protobuf/descriptor.proto

Refer to issue #17046
2020-12-27 11:32:10 +00:00
Stig Bjørlykke 9cafd342ac Lua: Add get_preference() and set_preference() utility functions.
Support uint, bool, enum, string, range, filename and directory preferences.
Added apply_preferences() to write to file and apply changes.
2020-12-08 22:56:50 +00:00
David Perry 27c00ca0e9 Lua: make TvbRange:raw() return a subset #12046 v2
My initial fix caused several double-offset errors in TvbRange_raw()
because I was adjusting for the TvbRange's offset too early in the
process. The proper fix is to only adjust for it in the final call to
get the data.

I also simplified some of the bounds checks to be based on the values in
the TvbRange instead of calling `tvb_captured_length()` and the like,
because its bounds are already checked against the backing Tvb when it's
first taken.

Massively expanded the lua test suite to account for every combination
of passing offsets and lengths to a Tvb or TvbRange and to the
subsequent `:raw()` call.
2020-12-02 20:09:55 +00:00
Huang Qiangxiong dcf6bdda84 Protobuf/gRPC: add test cases for Protobuf and gRPC
Add case_dissect_protobuf and case_dissect_grpc in test/suite_dissection.py.
Add *.proto into the sub directories of test/protobuf_lang_files/.
Run command like 'pytest --program-path .\run\Debug\ -k "grpc or protobuf"'
in build directory (in windows) to test these cases only.
2020-12-01 12:06:43 +00:00
Jaap Keuter 68313f4972 Avoid python deprecation warning
Fixes ad69ec2e11
2020-11-21 18:58:21 +00:00
John Thacker 7654bb260d QT+epan: Set FI_BITS_OFFSET and FI_BITS_SIZE flags on [u]ints and bitmasks
Set the FI_BITS_OFFSET and FI_BITS_SIZE flags appropriately on [u]int[64]
(and thus chars and booleans) where the bitmask is passed in on the
header_field_info. Also set the flags on bitmask items by ORing the bitmasks
from the constituent fields. These flags are only used right now in the
packet diagram.

This makes the packet diagram display those types of fields correctly without
having to use proto_item_set_bits_offset_len(), so long as the bitmask is
correct and the field width of the type matches the octet length. (If it
doesn't match, that's a dissector bug.)

split bit items are a more complicated case and still not handled correctly.
2020-11-19 12:00:46 +00:00
Gerald Combs 30c392f166 Tools+test: Call python3 explicitly.
PEP 394[1] says,

"In cases where the script is expected to be executed outside virtual
 environments, developers will need to be aware of the following
 discrepancies across platforms and installation methods:

  * Older Linux distributions will provide a python command that refers
    to Python 2, and will likely not provide a python2 command.

  * Some newer Linux distributions will provide a python command that
    refers to Python 3.

  * Some Linux distributions will not provide a python command at all by
    default, but will provide a python3 command by default."

Debian has forced the issue by choosing the third option[2]:

"NOTE: Debian testing (bullseye) has removed the "python" package and
 the '/usr/bin/python' symlink due to the deprecation of Python 2."

Switch our shebang from "#!/usr/bin/env python" to "#!/usr/bin/env
python3" in some places. Remove some 2/3 version checks if we know we're
running under Python 3. Remove the "coding: utf-8" in a bunch of places
since that's the default in Python 3.

[1]https://www.python.org/dev/peps/pep-0394/#for-python-script-publishers
[2]https://wiki.debian.org/Python
2020-11-05 06:46:35 +00:00
Mikael Kanstrup ad69ec2e11 dot11decrypt: Fix WEP decryption
For WPA security association (SA) entries are created on sucessful
PTK derivation from 4-way handshake frames. WEP though don't use
4-way handshake frames for key derivation and therefore no SA entry
is created. Still WEP decryption implementaton expects to find
an SA otherwise the decryption is skipped.

Fix broken WEP decryption by removing the check for an existing SA
entry and instead form the SA on first successful decryption.

Add also a test for WEP decryption.

Fixes: v3.3.0rc0-1263-g099d241046 ("dot11decrypt: Avoid allocating SA on packet decryption")
2020-10-21 11:03:44 +00:00