Commit Graph

5452 Commits (bd73553027a3a77815d09457a899791bbe8a76ff)

Author SHA1 Message Date
Jason Ish ae23144b67 --set - handle spaces on either side of '='
Discard spaces when provided as part of --set around the '='. For
example, "val=key", "val = key", "val= key" and "val =key" are
all equivalent now.
12 years ago
Jason Ish d9fe95bc8a conf - function declaration style
Use consistent style - function return type and declaration on
same line.
12 years ago
DIALLO David 0a4fd39f9c modbus: fix heap-buffer-overflow in Modbus parser
Modbus parser does not check length to extract/read data (read or write address,
quantity of data, etc.) that should be present.

In case of malformated data (invalid length in header), Modbus parser reads data
over the input data length.

Add check before extracting/reading data from input buffer to avoid head buffer
overflow.
12 years ago
Victor Julien 07efec550d counters: use ptr to name instead of copy
All counters have hardcoded names, so copies are not needed.
12 years ago
Victor Julien 7e66c70507 counters: don't run if no counters have been registered 12 years ago
Victor Julien cb5aa8f8d5 counters: work around unix-socket init issues 12 years ago
Victor Julien e48153c6b0 counters: make threads cleanup all memory 12 years ago
Victor Julien 81548ae3e8 counters: clean up global context 12 years ago
Victor Julien 84b8829cb4 counters: turn flow.memuse into a global counter 12 years ago
Victor Julien 0a262acdfb counters: make DNS counters globals 12 years ago
Victor Julien ac069c579a counters: make tcp.memuse a global counter 12 years ago
Victor Julien cddbb0f606 http: make http.memuse a global counter
http.memcap as well.
12 years ago
Victor Julien f05d0692ef counters: remove references to 'perf' counters 12 years ago
Victor Julien faef92f8da counters: remove last and now unused tm_name reference 12 years ago
Victor Julien 83f27ae2a5 counters: remove old unix socket json logic 12 years ago
Victor Julien 41ead6611a counters: minor internal API cleanups 12 years ago
Victor Julien d2a9ef2680 counters: rename unparsable SCPCAElem to StatsLocalCounter 12 years ago
Victor Julien 4c3ccda72e counters: minor header cleanup 12 years ago
Victor Julien 752f03e7a4 counters: remaining s/SCPerf/Stats/g 12 years ago
Victor Julien 4362d0a6e9 counters: s/SCPerfPrivateContext/StatsPrivateThreadContext/g 12 years ago
Victor Julien 628c3b1bc7 counters: s/SCPerfPublicContext/StatsPublicThreadContext/g 12 years ago
Victor Julien 7e70f136ec counters: various renames and cleanups 12 years ago
Victor Julien 30cce2bd29 counters: s/SCPerfCounterSetUI64/StatsSetUI64/g 12 years ago
Victor Julien 1c0b4ee0ae counters: s/SCPerfCounterIncr/StatsIncr/g 12 years ago
Victor Julien 8992275b0c counters: s/SCPerfCounterAddUI64/StatsAddUI64/g 12 years ago
Victor Julien 60d9eb6790 counters: clean up defines 12 years ago
Victor Julien 1ef786e7cb counters: rename register API calls
Also remove 'type' parameter which was always the same.
12 years ago
Victor Julien 3fab736539 log-stats: make global/threads logging configurable 12 years ago
Victor Julien 2c9a2c8327 stats: support per thread stats in json output
Default is only to output totals. Optionally per thread can be added.

Both can be enabled together.
12 years ago
Victor Julien 175831331c stats json: replace strndup
strndup is a banned function.
12 years ago
Victor Julien 6565c86f96 stats-json: fixes and improvements
Use proper LogFileCtx and MemBuffer handling so we can have multiple
loggers active at the same time.

Change 'date' field to timestamp, and use ISO notation to make it
the same as the other JSON outputs.
12 years ago
Tom DeCanio e4e07d0c3b eve-log: stats logging code cleanup. 12 years ago
Tom DeCanio 117eed0385 eve-log: add JSON stats logging
Support for counters in stats.log in eve output JSON stream.
12 years ago
Victor Julien 23f17950bc counters: pass per thread stats to output api
As well as the global (merged) stats.
12 years ago
Victor Julien de82b6d31e counters: rename widely used pctmi var to sts (stats thread store) 12 years ago
Victor Julien 60c5ad4649 counters: call global counters funcs 12 years ago
Victor Julien 33756abd87 counters: split API init
Split into early ctx initialization and post-config setup.
12 years ago
Victor Julien d05eed3735 counters: start using Stats prefix 12 years ago
Victor Julien f300ad253e counters: simplify and speedup counters sync 12 years ago
Victor Julien 0478407833 counters: remove threadvars arg from SCPerfAddToClubbedTMTable 12 years ago
Victor Julien 2346a88db7 counters: remove thread module name from counters API 12 years ago
Victor Julien b5bd3dee13 stream: make tcp.reassembly_memuse counter global
Fixes bugs #632 and #1178
12 years ago
Victor Julien 06461e37da counters: global counters registration 12 years ago
Victor Julien 9bbef55c4d Fix harmless typo in IPOnlyCIDRItemNew's SCReturnPtr use 12 years ago
Victor Julien b293a4b7d0 counters: remove unused description 12 years ago
Victor Julien 711cd7b59b counters: merge counters from threads for output
Merge counters so the table contains combined values from counters
from each thread.

Use global counter id's, track them in a hash.

Rename SCPCAElem members

Fix and improve average counters
12 years ago
Victor Julien 7da657dc3d counters: remove unused public API calls and make them private 12 years ago
Victor Julien ac6e24c06a counters: make SCPerfSetupPrivate a function 12 years ago
Victor Julien 66635f0741 counters: minor cleanups 12 years ago
Victor Julien 74ab84c194 counters: introduce SCPerfSetupPrivate for thread setup 12 years ago
Victor Julien 799640f906 counters: make threadvars::perf_private_ctx static
Update SCPerfGetAllCountersArray and add a UT workaround.
12 years ago
Victor Julien 55cfab89e4 counters: SCPerfGetLocalCounterValue cleanup
Return u64, update arguments.
12 years ago
Victor Julien b34c6dc93a counters: remove references to SCPerfCounterAddDouble
They were all in comments anyway.
12 years ago
Victor Julien e9b067c1eb counters: make increment call take threadvars
This hides the implementation from the caller.
12 years ago
Victor Julien 9a8bff7d96 counters: threadvars s/sc_perf_pca/perf_private_ctx/g 12 years ago
Victor Julien 50bb995458 counters: rename threadvars public counters 12 years ago
Victor Julien 6ffbc3a362 counters: s/SCPerfContext/SCPerfPublicContext/g 12 years ago
Victor Julien 0a5ae1b403 counters: s/SCPerfCounterArray/SCPerfPrivateContext/g
Goal is to make it's purpose clear.
12 years ago
Victor Julien 9f584483be counters: minor cleanups 12 years ago
Victor Julien 1e8142c699 logfile: rename ALERT_ types to LOGFILE_TYPE_ 12 years ago
Eric Leblond 4c6a7bea30 output-json: suppress global variable
It uses the new type field in the LogFileCtx instead.

This fixes the problem of not being able to use two eve-json
instance with different logging methods.
12 years ago
Eric Leblond 636e3d93c0 log file: add type flag
It will be used to store if the file is syslog or a real file.
12 years ago
Eric Leblond 39d667ff56 output-json: fix type of data parameter
The cast of data to AlertJsonThread was not correct as the real
type of the void pointer is a OutputJsonCtx. This was working by
luck because they both have a file_ctx as first element.
12 years ago
Alexander Gozman f11e237d77 Feature #1440: support wildcards in rule filenames 12 years ago
David Cannings 4f8f53d080 Fix rcode parsing, as noticed by Coverity.
Without support for OPT RR from RFC6891 (Extension mechanisms for DNS)
values of RCODE above 15 are not possible.  Remove dead code which will
never match.
12 years ago
Jason Ish 9fdae82815 conf - process includes even if not at root node. 12 years ago
Jason Ish 56f6e37304 radix-tree - prevent out of bounds array access
An IPv6 entry specified before an IPv4 entry on the host-os-policy
table can cause the stream byte array to be access one byte after
the end of the allocated memory at util-radix-tree.c:578.
12 years ago
Jason Ish 3e5b8f48b1 Bug 1281 - Add tests for rule content of lengths > 255. 12 years ago
Jason Ish e2b04635a7 Bug 1281 - Accept rule content with lengths greater than 255. 12 years ago
Victor Julien 0e22e95e47 alert-json: fix stream logging for IPS mode
Switch direction in IPS mode.
12 years ago
Victor Julien 5037ea93f3 threads: add untimed control cond call
The control conditions so far could only do timed waits, not normal
waits.
12 years ago
Victor Julien c7bc9ae6a8 detect: minor cleanups 12 years ago
Victor Julien bc2b53f10b parsing: s/strtok/strtok_r/g
Remove all strtok uses and replace them by strtok_r.

Do the same for Windows builds. Cygwin builds fine with strtok_r.

Add strtok to banned function list.
12 years ago
Victor Julien fb479902e4 threading: explain purpose of threadvars mucond 12 years ago
Victor Julien 478719ee9d flow: don't hold tv_root_lock longer than needed
Don't hold it longer than needed in shutting down.
12 years ago
Victor Julien c96805e839 threading: remove unused cmd thread create func 12 years ago
Victor Julien df5e9d44ca unix-manager: convert to thread module
Sync command thread for unix manager with other managers and make
it a full thread module.
12 years ago
Victor Julien cc01b5f6b6 reference/classification: call global init for unittests 12 years ago
Victor Julien 34f2ff067b reference: update pcre globals use
Don't update globals each time we parse, but instead do it once at
startup.
12 years ago
Victor Julien 46d401e3bb classification: update pcre globals use
Don't update globals each time we parse, but instead do it once at
startup.
12 years ago
Victor Julien b2da57c827 reference: remove global 12 years ago
Victor Julien 393689ce44 classification: remove global from parsing
Parsing code used a 'fd' global. Remove this.
12 years ago
Victor Julien 9764a35604 stream: fix --disable-detection reassembly issue
Due to an error at initialization, the stream engine would not disable
'raw' reassembly automatically when --disable-detection was used.

This lead to segments not getting cleared from the segment lists.
12 years ago
Victor Julien c1558f5ac4 stream: remove FLOW_NO_APPLAYER_INSPECTION flag
Instead, intruduce StreamTcpDisableAppLayer to disable app layer
tracking and reassembly. StreamTcpAppLayerIsDisabled can be used
to check it.

Replace all uses of FlowSetSessionNoApplayerInspectionFlag and
the FLOW_NO_APPLAYER_INSPECTION.
12 years ago
Victor Julien b6798495c5 stream: remove FLOW_NO_APPLAYER_INSPECTION use from tests 12 years ago
Victor Julien b2e1854e2a stream: improve 'no app layer' handling
When the session/flow was flagged as 'no applayer inspect', which
could happen as a result various reasons, packets would still be
considered by the app layer reassembly.

When ACK'd, they would be removed again. Depending also on the raw
reassembly.

In very long sessions however, this meganism could fail leading to
virtually endlessly growing segment lists.

This patch makes sure that segments that come in on a 'no app layer'
session are tagged properly or even not added at all.

Use a new ssn flag instead of flow flag for no app tracking.
12 years ago
Victor Julien 22a810813c app-layer: add DisableAppLayer
Move various app layer related flag setting calls into a utility
function "DisableAppLayer"
12 years ago
Victor Julien f536099a67 app-layer: de_state optimization
Add API to bypass expensive TX list walks. This API call is optional.

Implement it for HTTP and DNS.
12 years ago
Victor Julien 5f0678120d detect-state: update test to check state storing 12 years ago
Victor Julien 37f0bd57b6 detect-state: handle duplicate inspect/match
If for a packet we have a TX N that has detect state and a TX N+1 that
has no detect state, but does have 'progress', we have a corner case
in stateful detection.

ContinueDetection inspects TX N, but cannot flag the rule in the
de_state_sig_array as the next (TX N+1) has already started and needs
to be inspected. 'StartDetection' however, is then unaware of the fact
that ContinueDetection already inspected the rule. It uses the per
session 'inspect_id' that is only moved forward at the end of the
detection run.

This patch adds a workaround. It uses the DetectEngineThreadCtx::
de_state_sig_array to store an offset between the 'base' inspect_id
and the inspect_id that StartDetection should use. The data type is
limited, so if the offset would be too big, a search based fall back
is implemented as well.
12 years ago
Victor Julien bc6e4140be detect: add de_state duplication check
Add test to check if no duplicate destate is created.

Only enabled with DEBUG_VALIDATION.
12 years ago
Victor Julien 9d198e6662 detect-state: fix state storing
Fix storing state and bypassing detection. Previously we'd store
on a match only, meaning that StartDetection would rerun often.

Make sure StartDetection only stores if there is something to store.
12 years ago
Victor Julien 359e2d68f5 detect-http-header: improve buffer handling
Previously we could never be calling DetectEngineHHDGetBufferForTX
for TX N and then afterwards for TX N - 1. Due to changes in the
stateful detection code this is now possible.

This patch changes the buffer logic to take the 'inspect_id' as it's
base, instead of the first transaction that we are called with.
12 years ago
Victor Julien 62e937672d detect-events: set SIG_MASK_REQUIRE_*_STATE for events
Set SIG_MASK_REQUIRE_*_STATE for event rules to earlier discard
them.
12 years ago
Victor Julien 8d0b090150 engine-analysis: print fast_pattern summary
When using engine analysis for print fast_pattern stats, print a
short summary at the end containing per buffer:
- smallest fp
- biggest fp
- number of patterns
- avg fp len
12 years ago
Victor Julien 21f9328989 lua: fix error handling 12 years ago
Victor Julien 52195a4192 http: add event for leading spaces on request line
Libhtp will issue a warning in this case, so we can match on this.
This patch adds event, rule and unittest.
12 years ago
Victor Julien 2f85308afe threads: fix missing unlock in error handling
If TmThreadsUnregisterThread was called with out of range 'id', a lock
would not be cleared after returning from the function.

** CID 1264421:  Missing unlock  (LOCK)
/src/tm-threads.c: 2186 in TmThreadsUnregisterThread()
12 years ago
Eric Leblond 0303245761 af-packet: use max packet size as snaplen
If default_packet_size is set to 0, then we use the maximum packet
size as snaplen.
12 years ago
Eric Leblond 43f691fef8 util-device: fix LiveBuildDeviceListCustom
The code was assuming that the dictionnary containing the parameter
of a interface was ordered. But for YAML, the order is not assumed
so in case the configuration is generated we may not be able to
parse correctly the configuration file.

By iterating on child on main node and then iterating on subchild
and doing a match on the name, we are able to find the interface
list. In term of code, this algorithm was obtained by simply
removing the test on the name of the first child.
12 years ago