Commit Graph

1495 Commits

Author SHA1 Message Date
Gerald Combs f3e1d98434 Clang-Tidy: Fixup some suppressions
Use directory-level suppressions where needed.
2024-02-20 22:32:53 +00:00
John Thacker 70157523b7 wsutil: Only copy configuration files that are regular files
If someone manually puts a directory, or a FIFO, or something
else (block device?) in a configuration directory with the same
name as a preference file, don't try to copy it and just silently
ignore it.
2024-02-20 09:50:58 -05:00
Gerald Combs 5f0672d749 Add initial Clang-Tidy configuration files and a CI check
Add an initial Clang-Tidy configuration file which checks for recursion
and various clang analyzer issues.

Run Clang-Tidy in the "Clang + Code Checks" merge request job.

Add NOLINT suppressions where needed in wsutil, epan, and lemon.
2024-02-19 19:00:52 -08:00
Gerald Combs 4ec1ae4523 wsutil: Add null checks to wmem_map
Check for a valid wmem_map pointer in each of our lookup routines. This
keeps us from having to do so in various dissectors.

Fixes #19642
2024-02-08 09:50:34 -08:00
Darius Davis 89ce06c459 Fix a grab-bag of typos.
One of these modifies a field name ("hart_ip.pt.rsp.transducer_serail_number"
in packet-hartip.c), a few are in text displayed for fields (in packet-nvme.c)
or for unknown fields (in packet-oer.c and packet-per.c), one is in a
preprocessor macro (in packet-cip.[ch]), and the rest are all in comments.

   arry -> array
   authos -> authors
   compatability -> compatibility
   contigous -> contiguous
   dispaly -> display
   erorr -> error
   filed (where it was obviously incorrect) -> field or filled
   hueristic -> heuristic
   regsiter -> register
   serail -> serial
2024-02-05 11:58:31 +10:00
Gerald Combs 8a54995b1c wsutil+tools: Version info updates
Define VCS_NUM_COMMITS and VCS_COMMIT_ID in vcs_version.h. Use them to
return the Logray version in get_lr_vcs_version_info and use that where
appropriate. Rename VCSVERSION to VCS_VERSION.
2024-02-01 09:12:38 +00:00
Jaap Keuter 16fa05d719 Help: on macOS local pages are found in the DATA_DIR of the bundle 2024-01-12 13:35:03 +00:00
John Thacker caa9bfbe41 wsutil: Check GLib version for g_spawn Linux bug
The g_spawn Linux bug was fixed in GLib 2.58.2
(https://gitlab.gnome.org/GNOME/glib/-/merge_requests/490)
so if we have that version or later we don't have to use
the workaround from commit 5e304f7718
2024-01-12 09:45:58 +00:00
Stig Bjørlykke 322ae0f0d8 Happy New Year 2024 2024-01-01 12:25:09 +01:00
João Valverde 7f32c90ab9 plugins: Add a codecs API level
Add a minimum and maximum API level. Backward-compatible changes to
the API only bump the maximum API level. Backward incompatible
changes bump the maximum API level and the mininum, to the
new (maximum) level.

This may allow codec plugins to continue working without recompilation,
possibly with reduced functionality.

The API level is only defined for codecs because it is a small
and easy to define API, and very stable.

Maybe we could do the same for wiretap (file type) plugins. For the
various epan plugin types it seems pointless and futile. I cannot
see a scenario where a new Wireshark minor release does not increase
the minimum API level.
2023-12-14 16:18:35 +00:00
João Valverde b52d9173f8 Remove version component from plugin path
Remove the major.minor version from the plugin path, i.e:
    lib/plugins/X.Y/{epan,wiretap,codecs}
and use an unversioned path:
    lib/plugins/{epan,wiretap,codecs}

Introduce a new naming policy for plugins that requires
name.so.ABI_VERSION.

This is a simplified filesystem layoutfor plugins some
important benefits such as:

 * improves compatibility between Wireshark versions, because
a plugin that wasn't recompiled will be automatically picked
up, but only if it has a compatible ABI version in the file name.
 * does not clash with Apple guidelines
 * simpler for users to understand and apply
 * just overall simpler and easier to maintain, removes a lot
of complexity from CMake code

It does impose more requirements on the plugin naming scheme
but this should be handled completely transparently
by the build system.

It would also be possible to add support for unversioned *.so file
extensions at the same time, although in ths case it is not possible
to support multiple Wireshark ABI versions with only *.so, of course.
This wasn't done here but it may or may not be a useful enhancement
in the future.

Follow-up to 90b16b4092.
2023-12-14 14:28:30 +00:00
João Valverde 8486ba26c6 epan: Add plugin get_descriptions callback
Allow epan plugins to push descriptions for each individual
plugin or extension managed by the epan plugin interface.

For example a Lua or Python epan plugin can push
descriptions for each *.lua or *.py script it registers.
2023-12-12 14:43:37 +00:00
João Valverde 360cb3f40a plugins: Lower a log level
Avoid filling the fuzz test console with this message.
2023-12-10 22:51:27 +00:00
John Thacker 4db3e8f3f1 Capture: Check to see if the interface name is a Windows Named Pipe
Named pipes have special names on Windows
( https://learn.microsoft.com/en-us/windows/win32/ipc/pipe-names )
If we're on Windows, and the interface name given has such a name,
assume it is a pipe and don't bother retrieving the interface list.

Dumpcap and rawshark already have identical code for testing if an
interface name is a pipe. Move that into win32-utils and have
capture_opts, dumpcap, and rawshark all use the common function.

Fix #17721
2023-12-08 15:49:05 +00:00
João Valverde 0bcd2b6e6f wslua: Add a scope field to lua plugin description 2023-12-08 15:44:07 +00:00
João Valverde 5f6b5c40f4 plugins: Improve build with !HAVE_PLUGINS
Instead of not compiling plugins.c without HAVE_PLUGINS, we
should disable plugin support in a way that is functionally
the same as if the platform does not support it at runtime.

This reduces the number of ifdefs and allows sharing more utility
code for plugins.
2023-12-08 15:44:07 +00:00
João Valverde 47376298a5 plugins: Remove an assertion 2023-12-08 11:58:48 +00:00
João Valverde b1521550c6 plugins: Give higher priority to the personal folder
In general user customization should take higher priority
over system defaults. Do that here. This allows the user
to replace system plugins without much hassle.

We load the personal plugin folder first and lower the report
for a plugin found in multiple folders to a console log message
with log level "message" (so by default it will be displayed).
2023-12-08 11:47:19 +00:00
Haiyun Liu a23e4fa086 Plugins: Fix the issue of duplicate scanning of the same directory
If the global plugins dir is the same as the users plugins dir,
Wireshark will prompt the warning "The plugin 'xxx' was found in
multiple directories".
2023-12-08 01:22:00 +00:00
João Valverde a7827322fc plugins: Rename "dfilter" to "dfunction" 2023-12-08 00:45:36 +00:00
João Valverde c76a28fca4 Qt: Add Install Plugin to Tools menu
Add an option to the tools menu to copy a binary plugin file
(a .dll or .so) to the personal plugin folder.

This avoids the user having to create the paths manually and
knowning a lot of relatively unimportant details about where and
how Wireshark loads binary plugins.

It will also try to validate the plugin and do some sanity checks to
ensure the ABI is compatible.
2023-12-07 22:58:33 +00:00
João Valverde 51c6fa874d Qt: Replace plugin column "Path" with "Scope" in About dialog
Instead of using a Path field, that is really long and contains
a lot of redundant information, use a scope field that indicates
if the plugin is a personal plugin (loaded from the personal plugins
folder) or a global plugin (loaded from the global plugins folder).

Together with the plugin name this allows to construct the path
completely. By right-clicking on the row it is possible to open the file
browser in the correct plugin path and the personal/global plugin
folder path itself is displayed elsewhere.

Extcap and Lua scripts need to be enhanced to provide this
information too.
2023-12-07 02:07:51 +00:00
João Valverde 678a048549 plugins: Remove unused argument to scan_plugins_dir() 2023-12-07 02:07:51 +00:00
Guy Harris 85e0909553 Fix wsutil/ws_strptime.c to compile on FreeBSD.
Based on the FreeBSD port of Wireshark's changes, but generalized and
fixed so as not to upset people in locales that weren't on standard time
at 1970-01-01 00:00:00 UTC.  Read the comment for the painful details.
2023-12-06 00:25:37 -08:00
João Valverde 9c39c82cb1 Qt: Add plugin description/homepage fields to About dialog
Adds the description and homepage columns to the TableView in
the "About Wireshark" plugins tab.

Currently extcap and lua scripts lack this information, this
could be improved in the future.
2023-12-05 23:47:35 +00:00
João Valverde 869728143d Remove plugin license check
This removes the license check introduce with commit 90b16b4092.

After discussion and criticism received on the mailing list
I now think this license requirement is too permissive on
one hand about GPL compatibility and on the other it can be
a significant inconvenience for users who do not wish to distribute
the modified work, and so in its current form the change did
not advance the project's goals or GPL compliance.
2023-12-05 20:27:48 +00:00
João Valverde 0b2bb4fdb3 plugins: Remove unused "min_api_level" field
Remove currently unused minimum API level argument. Just pass
NULL to the module load function.
2023-12-04 15:53:08 +00:00
João Valverde 60f1972fa3 plugins: Fill in short description field
Fill-in the short description field for plugins that was left as
a FIXME in commit 3b59ce90c31df5d77ddd4d08ad13cb0f0e818117.

We should add a similar field for extcap extensions and Lua scripts
eventually.
2023-12-03 23:20:39 +00:00
João Valverde 90b16b4092 Refactor plugin registration and add ABI/license check
Remove the boilerplate and multiple symbols required
to write and load a plugin and use a simpler
interface that is also much more featureful and
extensible.

This removes the major.minor ABI check in favor of an
ABI version number that is simpler and more flexible.

In practice our 3 separate ABI versions still increase
with each major.minor version number but this may change
in the future, particularly for codecs that have a much
narrower and stable codec API.

There is a new license compatibility check. Plugins
must declare if the use GPLv2 or later, or alternatively
an FSF compliant GPLv2 compatible license. Otherwise
Wireshark refuses to load the plugin. The SPDX ID is
just an ancillary field and not enforced currently.

Adds more metadata fields during plugin registration.
These are only used for display and debugging.

There is an extra API level number in the registration API
that is reserved for future use.
2023-12-03 23:20:39 +00:00
Joakim Karlsson 1885540bc0 Glib-compat: adding g_array_binary_search 2023-11-29 05:28:51 +00:00
John Thacker 212cfe132c wsutil: Add wsjson function to get boolean
Add a json_get_boolean to parse booleans out of jsmn primitives
similar to the double parsing function.
2023-11-22 07:25:34 +00:00
Guy Harris 19f7e572a4 Work around macOS running applications in /.
If an application is launched from the Finder, it appears to get / as
its current directory.  This causes Wireshark open/save dialogs to open
up / if the user hasn't already opened a file in another directory, so
that there's no "last open directory" in the recent file.

Have get_persdatafile_dir(), on UN*X, cache the personal data directory
just as it does on Windows and, if nothing's been cached, have it fetch
the current directory and, if that succeeds *and* it's not the root
directory, use that.  Otherwise, use the user's home directory.

Fixes #9862.

In addition, separate the notion of "last open directory" and "open
dialog initial directory", where the latter is the last open directory
*if* a file has been opened in this session or the recent file has the
last open directory from a previous session, otherwise it's the user's
personal data directory.

Use the latter notion in file open/save dialogs; use the former notion
when reading from and writing to the recent file.

This means we don't need to set the "last open directory" at startup
time.  That way, running Wireshark without opening a file won't cause
the "last open directory" to be set, so that if a user runs it from a
directory, the "open dialog initial directory" won't be the last
directory from which Wireshark was run.
2023-11-12 06:53:36 +00:00
John Thacker 4ebb6e9893 tshark: Escape delimiter separated value in compliant ways
If the quote character appears in a field value, then escape
it by printing the character twice. When escaping whitespace
with the backslash character, also escape the backslash
character itself.

Add a ws_escape_csv function to wsutil and use it for tshark.
Adopt the existing static escape_string_len function so that
ws_escape_csv can use it while maintaining the same output
for the other ws_escape_ functions.

Fix #10284
2023-11-09 09:17:03 +00:00
João Valverde bc64efa538 dfilter: Replace macro UAT config file and update GUI
Remove the UAT macro usage. The UAT API is nifty for dissectors
but clunky for everything else.

This allows using a hash table to store macros, that is the natural
data structure for the use case (and faster).

It also allows using the existing filter GUI dialog, adapted for
display filter macros. The difference isn't huge but it's better
and less limited than the more generic UAT dialog, with room for
improvement. Changing the UAT dialog for filter specific
use cases is difficult.

The config file is renamed to "dmacros" and uses the same format
as "dfilter", that is more amenable and forgiving for hand-editing
than the UAT storage format.

There is some logic to convert the "dfilter_macros" UAT config
file to a "dmacros" filter config file, for backward-compatibility.
The conversion is only done if there is no existing "dmacros" file
in the profile folder.
2023-11-08 11:45:54 +00:00
João Valverde 177cc29ea6 wsutil: Make filter lists dynamic and on-demand
Do not read the capture filter list unless needed.

Do not use a static list because the capture filter list can change during program execution
and we want to be able to read multiple copies whenever.

Improve the public API function names.
2023-11-08 01:03:07 +00:00
João Valverde eed96b41fb Add support for comments in cfilters/dfilters 2023-11-07 16:15:42 +00:00
João Valverde 26785e7394 Remove support for deprecated "filters" configuration file
This "filters" file has not been used in a long time so no
release notes entry is warranted.
2023-11-07 16:15:42 +00:00
João Valverde 9765f8575c wsutil: Rename inet_netw.[ch]
inet_netw.c -> inet_cidr.c
inet_netw.h -> inet_cidr.h
2023-10-31 13:41:31 +00:00
João Valverde a178ec8a38 wsutil: Move and consolidate CIDR code
Consolidate code to handle CIDR network addresses in inet_netw.[ch].
2023-10-31 10:14:09 +00:00
João Valverde 0509398c4f wsutil: Consolidate IP address code
Consolidate code to handle IP addresses in inet_addr.[ch].
2023-10-31 10:14:09 +00:00
João Valverde 1c0f9cd3ae IPv6: Move IPv6 header definitions to epan/dissectors 2023-10-31 10:14:09 +00:00
João Valverde 49f39be301 dfilter: Add IP address plugin
Add a display filter plugin with functions to test IP addresses.

This extends the display filter features with some more specialized
functions and serves as an example on how to write a display
filter plugin.
2023-10-31 08:50:54 +00:00
John Thacker 8b631bf23f radiotap: Improve indication of 6 GHz band channels
Update the channel information string for the 6 GHz band.
Use "6 GHz"; replace "BG" and "A" with "2.4 GHz" and "5 GHz"
as the current labels are somewhat anachronistic now?

Add a comment about 802.11ax certified devices and control frames,
which are transmitted in legacy mode using the basic rate of
6 Mb/s (MCS 0); with no HE or EHT header, these are shown as
PHY_11A, which may be confusing to users.)

Fix #17393
2023-10-31 02:37:14 +00:00
Stig Bjørlykke c18aecc063 Exported PDU: Add new tag EXP_PDU_TAG_USER_DATA_PDU
Add a tag for configurable user data PDU.
2023-10-30 21:06:14 +00:00
João Valverde 8f28a0e9f3 plugins: Make flags unsigned 2023-10-30 09:37:29 +00:00
João Valverde ca392f6ddc wsutil/to_str: Deprecate ip_to_str() for endian-explicit versions
ip_to_str() forces the caller to cast the argument and it's not
obvious at all that the input should be in network-byte order
for IPv4 addresses.

Deprecated the function and add endian-explicit substitutes (number
vs address).
2023-10-29 15:17:31 +00:00
João Valverde 6fec850f62 dfilter: Install plugin headers
Install headers required to build display filter plugins.

Refactoring and optimizing system headers is an ongoing effort.
2023-10-27 18:46:35 +01:00
John Thacker 60a9e1124b Find: Matching multiple occurrences in Packet Bytes
Match multiple occurrence in Find Packet Bytes, both forwards
and backwards.

Also fix an issue highlighting wide strings properly reintroduced by
commit c0885fe390

For backwards searching in string and binary searches, use
the memrchr and backwards mempbrk implementations. For regex,
use PCRE2_ANCHORED to transform the user's regex expression into
one that is anchored at the start byte, and progressively search
backwards.

Fix #11269
2023-10-27 05:56:29 +00:00
John Thacker a6f3e61d70 wsutil: Add a reverse mempbrk function 2023-10-27 05:56:29 +00:00
John Thacker 0cec46bb25 wsutil: Add a memrchr implementation
Use the system memrchr if found, otherwise use a very basic
non optimized implementation
2023-10-27 05:56:29 +00:00