Victor Julien [Mon, 2 May 2016 09:59:47 +0000 (11:59 +0200)]
cppcheck: fix harmless warnings
[src/detect-engine-loader.c:272]: (error) Buffer is accessed out of bounds.
[src/flow-manager.c:742]: (error) Buffer is accessed out of bounds.
[src/flow-manager.c:906]: (error) Buffer is accessed out of bounds.
Zachary Rasmor [Thu, 5 Nov 2015 03:47:04 +0000 (22:47 -0500)]
Update threads to use global thread names.
Update FlowManager/Recycler to use global name.
Also add # into thread number.
Update af-packet to use global threadnames.
Update pcap to use global threadnames.
Update pfring to use global threadnames.
Update erf-dag to use global threadnames.
Update nflog to use global threadnames.
Update netmap to use global threadnames.
Update napatech to use global threadnames.
maxtors [Thu, 7 May 2015 12:09:04 +0000 (14:09 +0200)]
Changed naming of flowmanager/recycler.
- Changed FlowManagerThread to FM-
- Changed FlowRecyclerThread to FR-
- Changed use of strcasecmp to strncasecmp. This was used in the
killing and disabling of FM/FR Threads.
The shortening of the interfacenames is now dependent on the
size of the destination buffer, so that this can be easily
changed in the future. The process uses snprintf and strlcat.
Also changed the buffer sizes in the util-runmodes to 12
so that they can hold 11 chars + null terminator.
Fixed string copy and cat functions and made shortening safer.
Changed out strcpy, strncpy to strlcat and strlcpy. Also added
checks to see if the shortening did work or if it would fail in
advance. Fixed code in util-device and util-runmodes.
Added shortening of listening interface in util-runmodes
Added function LiveSafeDeviceName in util-device that shortens an
NIC device name if the name is over a given length and turns
it in to Ex: longi...eeth1
Victor Julien [Thu, 21 Apr 2016 11:17:33 +0000 (13:17 +0200)]
detect file: improve multi file handling
When multiple files were in a tx, the first one(s) closed/complete
and a new open one as well, a match in the former could lead to not
inspecting the latter.
This patch adds a workaround for this case, by allowing the file
inspection code to return a special code for 'match, but more files
available in tx'.
The stateful detection engine will then not make this match final for
the tx. It relies on the file pruning to kick in to make sure the
already complete files are removed from the tx before the next time
the detection engine is called on the tx.
Victor Julien [Wed, 20 Apr 2016 16:42:01 +0000 (18:42 +0200)]
http: flag destate about new files
The stateful detection engine needs some assistance when inspecting
transactions with multiple files. This patch flags the detect state
(if any) about the availability of new files in http. For http it
should only apply to multipart bodies although the flag is set for
all files.
Victor Julien [Wed, 20 Apr 2016 15:27:41 +0000 (17:27 +0200)]
smtp: flag detect state that new files are available
The stateful detection engine needs some assistance when inspecting
transactions with multiple files. This patch flags the detect state
(if any) about the availability of new files in smtp.
Victor Julien [Thu, 21 Apr 2016 12:37:43 +0000 (14:37 +0200)]
smtp: fix file logging and matching
When no rules with 'file content' keywords like filemd5 or filestore
were used, and non of the file outputs would force 'output' like
'force-md5' and 'force-magic', the file would not be tracked at all.
This meant that logging wouldn't work and neither would filename and
fileext inspection.
This patch removes the tracking bypass from the SMTP code and leaves
decisions to the file API.
Victor Julien [Thu, 14 Apr 2016 07:46:56 +0000 (09:46 +0200)]
dns: don't read uninitialized memory in name parsing
AFL+ASAN found that with certain input we used an uninitialized byte
in the length calculation. Probably harmless as the length was still
validated afterwards.
In the former case, the contents of the file are passed directly to
the HTTP parser as request data.
In the latter case, the data is devided between request and responses.
First 64 bytes are request, then next 64 are response, next 64 are
request, etc, etc.
Victor Julien [Tue, 8 Dec 2015 09:42:03 +0000 (10:42 +0100)]
afl: add --afl-parse-rules to return 0 on any rule
When fuzzing, AFL will create lots of malformed rules. We don't want
to error out on those. As we're fuzzing the parser any non-crash
should return 0. Crashes (ASAN or not) will return a non-0 code.
Jason Ish [Wed, 6 Apr 2016 22:50:08 +0000 (16:50 -0600)]
testing: new test macros, new testing documentation group.
Unit testing support macros for failing on expressions,
as well as passing tests on expressions.
If fatal unittests are enabled BUG_ON will be triggered for
an assertion providing the line number of the failure, otherwise
the test will simply fail.
Moved the fatal flag to a global var instead of a configuration
parameter for ease of access from a macro.
Eric Leblond [Thu, 31 Mar 2016 08:22:11 +0000 (10:22 +0200)]
prscript: update logic of sync with master test
Code now get master sha on github and check if it is in current
branch with a git command. It also sync first that the current
local branch is in sync with github corresponding branch.
Victor Julien [Wed, 16 Dec 2015 12:10:05 +0000 (13:10 +0100)]
tcp: reduce TCP options storage in packets
Until now, the TCP options would all be stored in the Packet structure.
The commonly used ones (wscale, ts, sack, sackok and mss*) then had a
pointer to the position in the option array. Overall this option array
was large. About 360 bytes on 64bit systems. Since no part of the engine
would every access this array other than through the common short cuts,
this was actually just wasteful.
This patch changes the approach. It stores just the common ones in the
packet. The rest is gone. This shrinks the packet structure with almost
300 bytes.
Victor Julien [Tue, 5 Apr 2016 11:14:03 +0000 (13:14 +0200)]
detect: fix error handling in mpm setup
*** CID 1358124: Null pointer dereferences (REVERSE_INULL)
/src/detect-engine-mpm.c: 940 in MpmStoreSetup()
934 PopulateMpmHelperAddPatternToPktCtx(ms->mpm_ctx,
935 cd, s, 0, (cd->flags & DETECT_CONTENT_FAST_PATTERN_CHOP));
936 }
937 }
938 }
939
>>> CID 1358124: Null pointer dereferences (REVERSE_INULL)
>>> Null-checking "ms->mpm_ctx" suggests that it may be null, but it has already been dereferenced on all paths leading to the check.
940 if (ms->mpm_ctx != NULL) {
941 if (ms->mpm_ctx->pattern_cnt == 0) {
942 MpmFactoryReClaimMpmCtx(de_ctx, ms->mpm_ctx);
943 ms->mpm_ctx = NULL;
944 } else {
945 if (ms->sgh_mpm_context == MPM_CTX_FACTORY_UNIQUE_CONTEXT) {
Victor Julien [Tue, 5 Apr 2016 10:59:54 +0000 (12:59 +0200)]
detect: don't set unused variable
detect.c:3801:13: warning: Value stored to 'tmplist2_tail' is never read
tmplist2_tail = joingr;
^ ~~~~~~
detect.c:3804:13: warning: Value stored to 'tmplist2_tail' is never read
tmplist2_tail = joingr;
^ ~~~~~~
2 warnings generated.
Victor Julien [Mon, 23 Nov 2015 18:03:47 +0000 (19:03 +0100)]
yaml: convert detect-engine to just detect
Instead of detect-engine which used a list for no good reason, use a
simple map now.
detect:
profile: medium
custom-values:
toclient-groups: 3
toserver-groups: 25
sgh-mpm-context: auto
inspection-recursion-limit: 3000
# If set to yes, the loading of signatures will be made after the capture
# is started. This will limit the downtime in IPS mode.
#delayed-detect: yes