Commit Graph

15604 Commits (561b81dd9eed61c98089d4d931326b5f728c694a)
 

Author SHA1 Message Date
Victor Julien 561b81dd9e decode: don't clear computed csums twice
Already done in a generic way by PACKET_RESET_CHECKSUMS.
11 months ago
Victor Julien 40afbf5b09 decode/ipv4: remove unused field 11 months ago
Victor Julien 3077310ff1 output/eve: constify mac address logic 11 months ago
Victor Julien 1213936978 macset: constify addr parameters 11 months ago
Victor Julien 2236c1fcc6 decode/udp: no need to pack the structure 11 months ago
Victor Julien 7c90144d19 decode/tcp: no need to pack the structure 11 months ago
Victor Julien a1a9b41a71 decode/icmpv4: no need to pack the structure 11 months ago
Victor Julien ff50dc49ef configure: tabs to spaces; minor reformatting 11 months ago
Victor Julien e557ba0460 unittests: don't set ports for non-port proto 11 months ago
Victor Julien e651cf922a detect/http: fix compile warning in body tests
When --enable-unittests w/o --enable-debug is used.
11 months ago
Victor Julien f6c24aab57 detect/ipproto: clean up test 11 months ago
Victor Julien 4e1ae1c3bf detect/fragbits: remove unused IP header struct from tests 11 months ago
Victor Julien d3a429d919 defrag: test cleanups and fixes
Pass tv and dtv to make sure reassembled packet is decoded.
11 months ago
Victor Julien 7728047888 decode/icmpv6: minor test cleanup 11 months ago
Victor Julien 3d4626f656 detect/dsize: remove unused ip6h from test 11 months ago
Jason Ish 568b941d7e configure: .git can be a file as well
In worktree scenarios, .git is a file. Assuming its a directory causes
the release date to check the ChangeLog instead of the last commit,
while not a big issue, can be confusing.
11 months ago
Jason Ish 71f59e529c jsonbuilder: fix serialization of nan and inf
When outputting a float, check if its infinity, or not a number and
output a null instead.

Using a null was chosen as this is what serde_yaml, Firefox, Chrome,
Node, etc. do.

Ticket: #6921
11 months ago
Victor Julien b224209f45 host-info: remove pcre2_substring_list_free use
Function prototype has changed in a recent release. Rather than dealing
with detecting that, fall back to our regular pattern of using
pcre2_substring_copy_bynumber().

Bug: #6918.
11 months ago
dependabot[bot] d310d00eb0 github-actions: bump github/codeql-action from 3.24.6 to 3.24.9
Bumps [github/codeql-action](https://github.com/github/codeql-action) from 3.24.6 to 3.24.9.
- [Release notes](https://github.com/github/codeql-action/releases)
- [Commits](https://github.com/github/codeql-action/compare/v3.24.6...v3.24.9)

---
updated-dependencies:
- dependency-name: github/codeql-action
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
11 months ago
Jason Ish 6035a8a2b6 github-ci: set checkout directory as safe before running git commands
While the checkout job appears to do this, it is done with a different
version of git which seems to be the cause for it not having an effect
when doing manual git operations from within a job.

Also removes duplicate checkout statements in Windows builds.
11 months ago
Jason Ish b58dd5e585 configure: export release date for documentation
Sphinx embeds a date in the generated man pages, and to provide
reproducible builds this date needs to be provided to Sphinx,
otherwise it will use the current date.

If building from Git, extract the date from the most recent commit. In
a release, this commit would be the commit that sets the version so is
accurate.

If .git does not exist, use the most recent data found in the
ChangeLog.

The ChangeLog is not used when building from git, as the main/master
branch may not have recent enough timestamps.

This should provide a consistent date when re-building the
distribution from the same non-git archive, or from the same git
commit.

Ticket: #6911
11 months ago
Jason Ish 51bf1c3510 docs/userguide: use a consistent date for reproducible builds
By default, when Sphinx generates the man pages, the current date will
be embedded in them. This can be set to a specific date with the
"today" variable. Typically the date embedded in manpages in the
release date.

To achieve this, attempt to use the environment variable, RELEASE_DATE
to set the "today" variable, reverting back to the empty string if not
set. It is up to our build system to properly set this date.

Ticket: #6911
11 months ago
Jason Ish c00c2b116f configure: don't check ./revision, it never exists
Stop checking the ./revision file for the git revision info, its never
created.
11 months ago
Jason Ish 4c16032f63 docs/conf.py: fix python escape warning
/home/jason/oisf/dev/suricata/master/doc/userguide/conf.py:74: SyntaxWarning: invalid escape sequence '\('
  "AC_INIT\(\[suricata\],\s*\[(.*)?\]\)",
11 months ago
dependabot[bot] 23463b9814
github-actions: bump codecov/codecov-action from 4.1.0 to 4.1.1
Bumps [codecov/codecov-action](https://github.com/codecov/codecov-action) from 4.1.0 to 4.1.1.
- [Release notes](https://github.com/codecov/codecov-action/releases)
- [Changelog](https://github.com/codecov/codecov-action/blob/main/CHANGELOG.md)
- [Commits](54bcd8715e...c16abc29c9)

---
updated-dependencies:
- dependency-name: codecov/codecov-action
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
11 months ago
Philippe Antoine ee50fe4c30 sip: convert transaction list to vecdeque
Ticket: 6891

So as to avoid quadratic complexity on tx cleanup with SIP/TCP
that can create many transactions in one go.
11 months ago
Shivani Bhardwaj 4227e52c4b detect/port: handle range and upper boundary ports
So far, if a port was found to be single which was earlier a part of the
range, port + 1 was added to the list to honor the range that it was a
part of. But, this is incorrect in case the port is 65535 or if the port
was found to be of range when it was earlier a single port.

Bug 6896
11 months ago
Jason Ish 02b019d071 examples/capture: fix the slot
Use slot->slot_next, not the slot as passed in.
11 months ago
Jason Ish f104e9cecc suricata: expose and break out configuration loading
Expose LoadYamlConfig as SCLoadYamlConfig and remove it from
SuricataInit. This is required to allow the library user the ability
customize the loading of the configuration, for example doing some
programmatic configuration then loading a configuration file.
11 months ago
Jason Ish e38ec7d0a7 smtp: fix configuration node creation
A configuration sequence node needs to have name, which is just its
index in the sequence.

Discovered by calling ConfDump() after Suricata was fully initialized.
11 months ago
Jason Ish 2c71c7fe6a suricata: move SuricataMain into main()
Move the contents of SuricataMain into the `main()` function found in
main.c. This forces the Suricata application to bootstrap and run
Suricata through the same interfaces as a library user might do.

Required exposing StartInternalRunMode as SCStartInternalRunmode. Its
arguable whether those "actions" belong in the library or just the
application, but I think that is separation we can look at later.

For now the lib example and Suricata's own main are the same, however
the example will probably extend more into programmatically
configuring Suricata or dynamically registering a runmode, which
doesn't really belong the main Suricata application.
11 months ago
Jason Ish c476fcc85b suricata: expose FinalizeRunMode and ParseCommandLine
Expose the functions FinalizeRunMode and ParseCommandLine to library
users, renaming with the `SC` prefix in the process.

This involves moving "application" level details from SuricataInit
into SuricataMain, as parsing command line options should be opt-in
for a library user.
11 months ago
Jason Ish e18779c1b4 windows: remove argc, argv from SCServiceRemove
Not used.
11 months ago
Jason Ish 8dc5478d0a suricata: remove argv from FinalizeRunMode
FinalizeRunMode can get the program name from suri->progname.
11 months ago
Jason Ish 04bd026c5b suricata: remove instance from ParseCommandLine
We want to be able to call ParseCommandLine from library users, but
currently library users don't have access to the `suricata` instance
type. Since this var is used other places as a global, use the global
one in ParseCommandLine as well.

Not ideal, but isolating SCInstance to a non-global will be another
challenge on its own.
11 months ago
Jason Ish db44740fd8 suricata: move WindowsInitService to SuricataMain
Move WindowsInitService from SuricataInit() to SuricataMain(), as
initializing Suricata as a service is very specific to the application
and not something you'd want to happen in a library, and SuricataInit
is more common initialization for application and library usage.
11 months ago
Jason Ish 2dc39d31c6 examples/lib: replicate Suricata using the library
With more functions exposed via the library, a library user can now
replicate the Suricata "main" function.
11 months ago
Jason Ish cfd98e92a0 suricata: expose SuricataMainLoop and GlobalsDestroy
Expose SuricataMainLoop and GlobalsDestroy so that SuricataMain can be
replicated by a library user of Suricata.

These removes the `suricata` instance as a function argument to some
of these functions, as the way we use it now, it serves no
purpose. However, it is a reminder that it should probably be
refactored to not be a global, as at some point it might be desirable
for to have multiple instances active without data sharing.
11 months ago
Angelo Mirabella 67d23c7b61 libsuricata: reorganize SuricataMain code
Split SuricataMain code in smaller functions. This is a first step
towards running as a library.
11 months ago
Shivani Bhardwaj 7d937db5cb detect/port: fix grouping of ports w gaps
If a single port happens before a range port, the port groups created
were incorrect. Fix it to use smarter range check.

For example, given,
80:80 - SGH1
100:120 - SGH2

Range created should be
80:80 - SGH1
100:120 - SGH2

Bug 6881
12 months ago
Victor Julien 0be3ba802e eve/alert: fix validation check
Bug: #6875.
12 months ago
Philippe Antoine f7cde8f00e rust/smb: fix clippy nightly warning
error: unnecessary use of `to_vec`
    --> src/smb/smb.rs:1048:62
     |
1048 |         let (name, is_dcerpc) = match self.guid2name_map.get(&guid.to_vec()) {
     |                                                              ^^^^^^^^^^^^^^ help: replace it with: `guid`
     |
     = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_to_owned
     = note: `#[deny(clippy::unnecessary_to_owned)]` implied by `#[deny(warnings)]`

And also other uses of to_vec() on already Vec
12 months ago
Philippe Antoine 02f2fb8833 rust: fix clippy 1.77 warning
Ticket: 6883

error: field `0` is never read
  --> src/asn1/mod.rs:36:14
   |
36 |     BerError(Err<der_parser::error::BerError>),
   |     -------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   |     |
   |     field in this variant
   |
12 months ago
Victor Julien a2c817243f rust: add MSRV as rust-version
Update github-actions to use it for the MSRV check.
12 months ago
Jeff Lucovsky bf5cfd6ab7 profiling/rules: Improve dynamic rule handling
Issue: 6861

Without this commit, disabling rule profiling via suricatasc's command
'ruleset-profile-stop' may crash because profiling_rules_entered becomes
negative.

This can happen because
- There can be multiple rules evaluated for a single packet
- Each rule is profiled individually.
- Starting profiling is gated by a configuration setting and rule
  profiling being active
- Ending profiling is gated by the same configuration setting and
  whether the packet was marked as profiling.

The crash can occur when a rule is being profiled and rule profiling
is then disabled after one at least one rule was profiled for the packet
(which marks the packet as being profiled).

In this scenario, the value of profiling_rules_entered was
not incremented so the BUG_ON in the end profiling macro trips
because it is 0.

The changes to fix the problem are:
- In the profiling end macro, gate the actions taken there by the same
  configuration setting and use the profiling_rues_entered (instead of
  the per-packet profiling flag). Since the start and end macros are
  tightly coupled, this will permit profiling to "finish" if started.
- Modify SCProfileRuleStart to only check the sampling values if the
  packet hasn't been marked for profiling already. This change makes all
  rules for a packet (once selected) to be profiled (without this change
  sampling is applied to each *rule* that applies to the packet.
12 months ago
Philippe Antoine c4b8fb7aca ssh: limit length for banner logs
Ticket: 6770
12 months ago
Philippe Antoine 271ed2008b ssh: avoid quadratic complexity from long banner
Ticket: 6799

When we find an overlong banner, we get into the state just
waiting for end of line, and we just want to skip the bytes
until then.
Returning AppLayerResult::incomplete made TCP engine retain
the bytes and grow the buffer that we parsed again and again...
12 months ago
Philippe Antoine cc3b4b01ec detect: flush when setting no_inspection
Ticket: 6578

When a protocol such as SSH sets no_inspection, we still have to
flush the current streams and packets that contain clear-text
for detection.
12 months ago
Philippe Antoine 4c4f7ff1a2 detect: update packet action on protocol change
Ticket: #6305

When running FlowWorkerStreamTCPUpdate, one of the dequeued packet
may set the flow action to drop, without updating the not-pseudo
packet action, as is done usually with a previous call to
FlowHandlePacketUpdate
12 months ago
Victor Julien ff8597d50b membuffer: annotate printf style function 12 months ago