-
Notifications
You must be signed in to change notification settings - Fork 296
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
New Parser for JSON data #1684
base: develop
Are you sure you want to change the base?
New Parser for JSON data #1684
Conversation
93c7b4c
to
35ff026
Compare
"json_data_format": true, | ||
"json_data_key": "data.ipdata" | ||
|
||
With above configuration, list of dict will be created from list present in json["data"]["ipdata"]. Each dict will then create atleast an event. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What if the data is in json["data.ipdata"]
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it will still work. if we have both json["data"]["ipdata"] and json["data.ipdata"], the one which is later defined, will override the other and its value will be assigned in key "data.ipdata" of flattened json.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If json_data_key
can only be used in conjunction with json_data_format
, why use two different parameters?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the contribution! That's definitely a long-awaited parser :)
I only had a look at the added documentation so far.
|
||
**Configuration parameters** | ||
|
||
* `"json_data_format"`: Boolean, if list of data is within key of json object, optional. Default: false. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please expand the explanation, examples are also helpful.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
json_data_format will be True if there is a single json and list of data is inside any of its child nodes. For below json, we find data inside key 'data'
{ "complete": false, "count": 9632240, "data": [ { "ip": "179.124.36.196", "classification": "malicious", "first_seen": "2020-01-13", "last_seen": "2020-12-14", "tags": [ "SSH Scanner", "SSH Worm" ], "cve": [] }, { "ip": "189.86.227.150", "classification": "malicious", "first_seen": "2019-01-17", "last_seen": "2020-12-14", "tags": [ "Eternalblue", "SMB Scanner" ], "cve": [ "CVE-2017-0144" ] } ], "message": "ok" }
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you please add that example to the docs?
"json_data_key": "data.ipdata" | ||
|
||
With above configuration, list of dict will be created from list present in json["data"]["ipdata"]. Each dict will then create atleast an event. | ||
* `"splitlines"`: Boolean, spit multiline data into list, optional. Default: `"false"`. Either `"json_data_format"` or `"splitlines"` can be used.` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please expand the explanation, examples are also helpful.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Again in above json, if we have config json_data_key
: data and json_data_format
: True, it will create two event with list of data present in json["data"] with proper harmonized field as per given in translate_field
parameter.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why are json_data_format
and splitlines
mutually exclusive?
Btw, I think there's no test that covers actual line splitting (the tests with splitlines=true
only have one line)
Hi, thanks a lot for your contribution! That looks like a very useful parser. Could you make your commit messages a bit more verbose? It would be great if the information you added in the pull request would be part of the commit message, i.e.
and for the documentation commit (if you want to keep that separate - you could also simply squash to one commit!)
Also there are a lot of unnecessary changes in the |
JSON Custom Parser allows can translate json key into harmonized key field and can create events from list of dict within key of JSON
Hi, all requested changes have been made in previous commit. |
with open(os.path.join(os.path.dirname(__file__), 'multiple_msg.json'), 'rb') as fh: | ||
RAW1 = base64.b64encode(fh.read()).decode() | ||
|
||
MULTILINE_REPORT = {"feed.name": "RSTThreats Domain Feed", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That bot is actually on the whishlist, so if you can contribute an entry to feeds.yaml
that would be nice :)
This parser can translate json key into harmonized key field and can create events from list of dict within key of JSON.