Skip to content

Conversation

jjourdin
Copy link

@jjourdin jjourdin commented Feb 2, 2021

No description provided.

KGuillemot and others added 30 commits May 28, 2019 16:22
allows to set custom separator and assignator characters
when both are defined, the parser will simply try to match assignator and separator in turn
otherwise, legacy checks (key name validation, etc...) will occur
…TING

- new parameter 'separator': defines a custom character to look for between key/value pairs (replaces whitepsace when defined)
- new parameter 'assignator': defines a custom character to look for between key and value (replaces '=' when defined, but DISABLES key name validation)
- add support for (simple and double) quoting in values
- add support for escaped characters in values
…lue is not valid - to allow parsing rest of line
As of today, Checkpoint logs do not necessarily provide a semicolon
between the last key:value pair and the terminator.
This causes the parse to fail with current behavior.
FIX CHECKPOINT-LEA: ';' NOT NEEDED AFTER LAST VALUE
- Empty value at the end of the line results in failure of the parsing
-  \/ in values results in failure of the parsing
- Expected outcome:
When the last value is empty, the cursor should stop at the equal sign.

- Problem encountered:
When the last value is empty, the cursor increases (+2): i > npb->strlen

- Fix:
Initialized the length of the value to 0: lenValue = 0
If the cursor has not reached the end of the line, we parse the value.
Otherwise, we know that our value is empty, its length is thus 0.
Current behavior:
When extracting the headers, cefGetHdrField already skips the pipes.
But just after, the cursor is incremented by one again (++i).
This truncates the first later of the first variable name.

Fix:
Removed the increment of the cursor after the header's extraction.
Current behavior:
The escaped slash is not translated to a simple slash.

Expected behavior:
Sashes should be replaced by a slash.
This behavior matches how the escaped equal sign is replaced.

Fix:
Added a case to the switch which handles the escaped chars.
FIX CEF PARSER

Currently, the CEF parser fails for two reasons:

    When it encounters an escaped slash ( \/ ) in the middle of a value
    When the last value is empty

This is particularly problematic for us as we have a lot of data in this format to parse.
Behavior:

    Log

CEF:0|nxlog.org|nxlog|2.7.1243|Executable Code was Detected|Advanced exploit detected|100|path=Some\/Path spt=46117 dst=172.25.212.204 dpt=

    Rulebase

version=2
rule=%.:cef%

    Expected behavior

{
  "DeviceVendor": "nxlog.org",
  "DeviceProduct": "nxlog",
  "DeviceVersion": "2.7.1243",
  "SignatureID": "Executable Code was Detected",
  "Name": "Advanced exploit detected",
  "Severity": "100",
  "Extensions": {
    "path": "Some/Path",
    "spt": "46117",
    "dst": "172.25.212.204",
    "dpt": ""
  }
}

    Current behavior

{
  "originalmsg": "CEF:0|nxlog.org|nxlog|2.7.1243|Executable Code was Detected|Advanced exploit detected|100|path=Some\\/Path spt=46117 dst=172.25.212.204 dpt=",
  "unparsed-data": "CEF:0|nxlog.org|nxlog|2.7.1243|Executable Code was Detected|Advanced exploit detected|100|path=Some\\/Path spt=46117 dst=172.25.212.204 dpt="
}
@rgerhards
Copy link
Member

@jjourdin I think it would make sense to squash the commits into a few as many of them look like in-the-process-local-fixes and clutter the commit history

@rgerhards
Copy link
Member

I will also need to check if CI has some defects - may very well be! In any case, thx for the PR!

@rgerhards rgerhards self-assigned this Oct 12, 2021
@rgerhards rgerhards marked this pull request as draft October 12, 2021 07:43
@rgerhards rgerhards added this to the v2.0.6 milestone Oct 12, 2021
@rgerhards rgerhards marked this pull request as ready for review October 12, 2021 07:44
@rgerhards
Copy link
Member

sry, accidentally set PR to draft - have reverted

@frikilax
Copy link
Contributor

This PR concentrates 4 different features/bug fixes, that I opened in separate PRs (or were already open) :

I think it would be simpler for anyone to try and integrate each of these PRs instead of this monolithic one

@rgerhards
Copy link
Member

I think it would be simpler for anyone to try and integrate each of these PRs instead of this monolithic one

wouldn't it be possible to split them up in one commit per fix/feature?

@frikilax
Copy link
Contributor

I think it would be simpler for anyone to try and integrate each of these PRs instead of this monolithic one

wouldn't it be possible to split them up in one commit per fix/feature?

I think this PR is now obsolete in favor of the 4 others, I will check the squash in the oldest ones but I think every PR ought to be correctly squashed

@rgerhards
Copy link
Member

I think this PR is now obsolete in favor of the 4 others,

ah! sry, I hadn't notice all of them -- that of course makes sense. Feel free to close this one here whenever ready!

@rgerhards rgerhards removed this from the v2.0.6 milestone Oct 12, 2021
@rgerhards
Copy link
Member

mmmhhh - I only see two - am I lost? ;-)

@frikilax
Copy link
Contributor

mmmhhh - I only see two - am I lost? ;-)

The 2 new ones are #351 and #352.

In addition there are 2 currently open (but older) PRs also related to the changes present here : #325 and #335

KGuillemot and others added 3 commits November 8, 2021 10:01
### Fixed
 - [NAME-VALUE-LIST] Fix parsing of escaped caracters (double-quote, separator, backslash)
### Added
 - [NAME-VALUE-LIST] Add test for quoted values and escaped caracters
@frikilax
Copy link
Contributor

@jjourdin can we close this PR ? all related changes have been proposed as separate PRs (#351, #352, #325 and #335)

@jjourdin jjourdin closed this Nov 15, 2021
@jjourdin
Copy link
Author

Job's done, thank you

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants