-
Notifications
You must be signed in to change notification settings - Fork 506
METRON-508 Expand Elasticsearch templates to support the standard bro logs #586
Conversation
|
Still need to review, but this is a great addition Jon. What pairs nicely with this is to expand the unit tests for the Bro parser to test the other log types that you include in this PR. Right now only HTTP and DNS are tested there. We can tackle separately if you like. |
|
Didn't I do that? |
|
Looks like there are some good unit tests, though maybe not for every new type you mention, or that could come in. Seems like decent coverage though. I wonder, is it worth adding something in the integration tests as well, especially prior to 777 to avoid accidentally regressing this work when that lands? |
|
Actually, I meant the integration tests. The stuff under |
|
@simonellistonball Right, I'm not attempting to cover any type of log that can come in, based on the bro documentation, because bro logs are heavily extensible and therefore it is hard to detect what all could come in from a given bro install. There are also a lot of fields that exist in the bro documentation for a specific log type that are not on by default, but can be turned on. I plan to step towards support of those fields with various PRs, but not do it all with this first stab unless it's strongly encouraged. That said, I will do some more work on the unit and integration tests to get better coverage, as there most definitely may be some missing, optional fields which I didn't catch in the tests. @nickwallen Right, that makes sense. In a minute I'll push out my first pass at the integration tests, and I'll take another look at the tests this coming week and fill in any of the gaps. As an aside, I explicitly did not add these new logs to the bro sensor-stub, but I would consider doing so at some point in the future. Since there isn't a default dashboard that uses these logs, I didn't think it would be very useful. |
|
Fantastic! Good to see more integration tests in there and great to see additional data ingested. I'm +1 (non-binding) on this. |
|
I updated the instructions to reflect the repo name change; hopefully it should work but I won't have a chance to test it out for a couple of days. |
|
Per @simonellistonball 's comments in #531 I added initial support for the native way that Bro handles tracking DHCP's Client ID field and updated the above instructions appropriately. |
|
Bump |
|
|
||
| public void testUnwrappedBroMessage() throws ParseException { | ||
| String rawMessage = "{\"timestamp\":1449511228.474,\"uid\":\"CFgSLp4HgsGqXnNjZi\",\"source_ip\":\"104.130.172.191\",\"source_port\":33893,\"dest_ip\":\"69.20.0.164\",\"dest_port\":53,\"proto\":\"udp\",\"trans_id\":3514,\"rcode\":3,\"rcode_name\":\"NXDOMAIN\",\"AA\":false,\"TC\":false,\"RD\":false,\"RA\":false,\"Z\":0,\"rejected\":false,\"sensor\":\"cloudbro\",\"type\":\"dns\"}"; | ||
| String rawMessage = "{\"ts\":1449511228.474,\"uid\":\"CFgSLp4HgsGqXnNjZi\",\"id.orig_h\":\"104.130.172.191\",\"id.orig_p\":33893,\"id.resp_h\":\"69.20.0.164\",\"id.resp_p\":53,\"proto\":\"udp\",\"trans_id\":3514,\"rcode\":3,\"rcode_name\":\"NXDOMAIN\",\"AA\":false,\"TC\":false,\"RD\":false,\"RA\":false,\"Z\":0,\"rejected\":false,\"sensor\":\"cloudbro\",\"type\":\"dns\"}"; |
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.
I'd like to see these pulled out and using @Multiline for readability. Given that it's not currently in this format, I'm not opposed to just leaving it, but it does make it easier to understand at a glance. Given that these all get touched anyway right now, it seems like the perfect time to refactor it.
Example:
/**
* {
* "ts":1449511228.474,
* "uid":"CFgSLp4HgsGqXnNjZi",
* "id.orig_h":"104.130.172.191",
* "id.orig_p":33893,
* "id.resp_h":"69.20.0.164",
* "id.resp_p":53,
* "proto":"udp",
* "trans_id":3514,
* "rcode":3,
* "rcode_name":"NXDOMAIN",
* "AA":false,
* "TC":false,
* "RD":false,
* "RA":false,
* "Z":0,
* "rejected":false,
* "sensor":"cloudbro",
* "type":"dns"
* }
*/
@Multiline
public static String unwrappedBroMessage;
public void testUnwrappedBroMessage() throws ParseException {
JSONObject rawJson = (JSONObject)jsonParser.parse(unwrappedBroMessage);
JSONObject broJson = broParser.parse(unwrappedBroMessage.getBytes()).get(0);
String expectedBroTimestamp = "1449511228.474";
Assert.assertEquals(broJson.get("bro_timestamp"), expectedBroTimestamp);
String expectedTimestamp = "1449511228474";
Assert.assertEquals(broJson.get("timestamp").toString(), expectedTimestamp);
Assert.assertEquals(broJson.get("ip_src_addr").toString(), rawJson.get("id.orig_h").toString());
Assert.assertEquals(broJson.get("ip_dst_addr").toString(), rawJson.get("id.resp_h").toString());
Assert.assertEquals(broJson.get("ip_src_port"), rawJson.get("id.orig_p"));
Assert.assertEquals(broJson.get("ip_dst_port"), rawJson.get("id.resp_p"));
Assert.assertEquals(broJson.get("uid").toString(), rawJson.get("uid").toString());
Assert.assertEquals(broJson.get("trans_id").toString(), rawJson.get("trans_id").toString());
Assert.assertEquals(broJson.get("sensor").toString(), rawJson.get("sensor").toString());
Assert.assertEquals(broJson.get("type").toString(), rawJson.get("type").toString());
Assert.assertEquals(broJson.get("rcode").toString(), rawJson.get("rcode").toString());
Assert.assertEquals(broJson.get("rcode_name").toString(), rawJson.get("rcode_name").toString());
Assert.assertTrue(broJson.get("original_string").toString().startsWith("DNS"));
}
|
I did leave one comment about refactoring tests a bit, but I'm +1 regardless of if that change happens or not. Spun it up in full dev and was able to get all the types to show up in the histogram and things looked good all around. Thanks for the great contribution! |
|
Thanks. I haven't used org.adrianwalker.multilinestring.Multiline before, took a quick shot with two of them, I'll do the rest when I have more time. |
|
|
||
| @SuppressWarnings("rawtypes") | ||
| public void testProtocolKeyCleanedUp() throws ParseException { | ||
| String rawMessage = "{\"ht*tp\":{\"ts\":1402307733.473,\"uid\":\"CTo78A11g7CYbbOHvj\",\"id.orig_h\":\"192.249.113.37\",\"id.orig_p\":58808,\"id.resp_h\":\"72.163.4.161\",\"id.resp_p\":80,\"trans_depth\":1,\"method\":\"GET\",\"host\":\"www.cisco.com\",\"uri\":\"/\",\"user_agent\":\"curl/7.22.0 (x86_64-pc-linux-gnu) libcurl/7.22.0 OpenSSL/1.0.1 zlib/1.2.3.4 libidn/1.23 librtmp/2.3\",\"request_body_len\":0,\"response_body_len\":25523,\"status_code\":200,\"status_msg\":\"OK\",\"tags\":[],\"resp_fuids\":[\"FJDyMC15lxUn5ngPfd\"],\"resp_mime_types\":[\"text/html\"]}}"; |
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.
One more multiline
|
@JonZeolla Can you deconflict this? |
|
+1 still stands, pending Travis. |
|
@nickwallen @justinleet Can I get a quick review of my recent changes before I merge? Mostly focused on how I approached documenting the template, but feel free to comment on anything. I just spun this up in full-dev and verified that my above steps are still valid and this works as intended. At this point I'm iteratively crossing my fingers and retrying Travis until it gets the whole way through and gives me a result. Can't wait for #624 |
|
Last try before I merge in #624 and make it a dependancy. |
* Catching weird kafak issue. * removing extraneous imports. * reverted pom file change.
|
Out of sheer frustration I merged in #624 in its current state and got Travis to pass on the first try after over a dozen failures. Great work @justinleet @cestella and others. Obviously now this has a dependency of METRON-1004 so I've edited the title of this to include "[DO NOT MERGE UNTIL METRON-1004]". Still looking for a review - looking back I should have squash merged, but due to the simplicity of the changes in this PR, it's probably not worth going back and fixing it. |
|
@JonZeolla 1004 is in, but there's been a few changes in, so I'd ask that you double check that things still line up as expected. I'm going to look back through the changes this morning on here this morning, now that Travis actually works. |
|
Should be good to go now, pending Travis. |
|
+1. I'm good with the most recent changes, pending Travis. |
|
I spotted a duplicate in taking a scan of the template, so I ran |
Contributor Comments
This PR makes it easier for someone with an existing bro install to send some of their log files into Metron, based off of a combination of the bro documentation and a fresh install of bro 2.4. There are future plans to expand on this via METRON-518 and METRON-908. Specifically, this attempts to provide initial support the default-on fields of the following logs:
Testing
sensors,(to spin up the real sensors).Pull Request Checklist
Thank you for submitting a contribution to Apache Metron.
Please refer to our Development Guidelines for the complete guide to follow for contributions.
Please refer also to our Build Verification Guidelines for complete smoke testing guides.
In order to streamline the review of the contribution we ask you follow these guidelines and ask you to double check the following:
For all changes:
For code changes:
Note:
Please ensure that once the PR is submitted, you check travis-ci for build issues and submit an update to your PR as soon as possible.
It is also recommended that travis-ci is set up for your personal repository such that your branches are built there before submitting a pull request.