Skip to content
This repository was archived by the owner on Aug 20, 2025. It is now read-only.

METRON-1671: Initial PCAP UI#1103

Closed
tiborm wants to merge 20 commits intoapache:feature/METRON-1554-pcap-query-panelfrom
tiborm:feature/METRON-1554-pcap-query-panel
Closed

METRON-1671: Initial PCAP UI#1103
tiborm wants to merge 20 commits intoapache:feature/METRON-1554-pcap-query-panelfrom
tiborm:feature/METRON-1554-pcap-query-panel

Conversation

@tiborm
Copy link
Contributor

@tiborm tiborm commented Jul 13, 2018

Contributor Comments

This PR contains the initial cut of PCAP UI.

screen shot 2018-07-16 at 9 29 49 am

The user is able to submit a PCAP process job by the search button (magnifier icon) at the top of the page. In the same filter bar User is able to narrow the result set by filtering to the following fields:

  • IP Source Address
  • IP Source Port
  • IP Dest Address
  • IP Dest Port
  • Protocol
  • Include Reverse Traffic
  • Free text filtering

While the PCAP job is in progress a progress bar shows up below the filter bar. (Sorry, having no screenshot about it.)

screen shot 2018-07-16 at 9 30 43 am

The result of the PCAP processing is visualized in a grid. User able to open each record to get access to the details of the packet.

Running tests

If you like to run the unit tests run:
npm install
npm test

For addition info please check the readme.md in metron-alerts.

Testing

This has been tested in full dev. In order to test:

  1. Spin up full dev.
  2. Put pcap data inside of /apps/metron/pcap/input in your VM.
  3. Start metron-alerts.
  4. Sign in and click on the PCAP tab in the upper left hand corner of the screen.
  5. Submit a pcap search which will return a set of results from your loaded pcap data, preferably on that will match at least a few dozen results.

For test scenarios please check https://issues.apache.org/jira/browse/METRON-1671

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:

  • Is there a JIRA ticket associated with this PR? If not one needs to be created at Metron Jira.
  • Does your PR title start with METRON-XXXX where XXXX is the JIRA number you are trying to resolve? Pay particular attention to the hyphen "-" character.
  • Has your PR been rebased against the latest commit within the target branch (typically master)?

For code changes:

  • Have you included steps to reproduce the behavior or problem that is being changed or addressed?

  • Have you included steps or a guide to how the change may be verified and tested manually?

  • Have you ensured that the full suite of tests and checks have been executed in the root metron folder via:

    mvn -q clean integration-test install && dev-utilities/build-utils/verify_licenses.sh 
    
  • Have you written or updated unit tests and or integration tests to verify your changes?

  • If adding new dependencies to the code, are these dependencies licensed in a way that is compatible for inclusion under ASF 2.0?

  • Have you verified the basic functionality of the build by building and running locally with Vagrant full-dev environment or the equivalent?

For documentation related changes:

  • Have you ensured that format looks appropriate for the output in which it is rendered by building and verifying the site-book? If not then run the following commands and the verify changes via site-book/target/site/index.html:

    cd site-book
    mvn site
    

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.

 into pcaprest

Conflicts:
	metron-interface/metron-alerts/src/app/app.module.ts
 Conflicts:
	metron-interface/metron-rest/src/main/java/org/apache/metron/rest/MetronRestApplication.java
	metron-interface/metron-rest/src/main/java/org/apache/metron/rest/controller/PcapQueryController.java
	metron-interface/metron-rest/src/main/java/org/apache/metron/rest/util/pcapQueryThread.java
@mmiklavc
Copy link
Contributor

@tiborm Thanks for the contribution! A few comments for starters:

  • Can you provide a test script for reviewers?
  • What's this 10k+ line spec file? Are these working AngularJS unit tests, and if so, are they now part of the build? Please comment, and if they are not part of the automated build, please provide instructions for running them even if it's simply pointing to an existing doc.
  • When you have run through the items in the PR checklist from above, please mark them as such.

@mmiklavc
Copy link
Contributor

Some screenshots of your UI changes with accompanying explanation would also be useful so reviewers know what we're looking at.

@tiborm tiborm changed the title Feature/metron 1554 pcap query panel METRON-1554: Initial PCAP UI Jul 16, 2018
@tiborm tiborm closed this Jul 16, 2018
@tiborm tiborm reopened this Jul 16, 2018
@ottobackwards
Copy link
Contributor

I think we should rename from alert ui to investigate or something

@tiborm tiborm changed the title METRON-1554: Initial PCAP UI METRON-1671: Initial PCAP UI Jul 16, 2018
@tiborm
Copy link
Contributor Author

tiborm commented Jul 17, 2018

@mmiklavc The 10k+ line spec file is a working unit test which contains mock data as well.
I also cerry-picked a commit which fixes all the failing unit tests.

@justinleet managed to make UI unit tests part of our Travis build. He opens a PR for that soon.

@james-sirota
Copy link

I reviewed the UI. Everything comes up fine and looks good. One assumption I am making is that protocol is numeric because the protocol field will not allow me to enter a character. +1

@tiborm tiborm closed this Jul 19, 2018
@tiborm tiborm reopened this Jul 19, 2018
@mmiklavc
Copy link
Contributor

@tiborm @sardell Can one of you list out the UI PR's and indicate the order in which they should be tested and subsequently merged into the feature branch? Since this is the initial major ticket, you can probably add that as a comment here. In addition, each PR should clearly indicate which PR's it depends on and those that are depending on it.

Copy link
Member

@cestella cestella left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we have any idea why or how these .ts files are able to make their way through the RAT checks on license headers?

@@ -0,0 +1,29 @@
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some of these .ts files don't have license headers, how is this passing the rat check? Do we have a rat exclusion that is too broad?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, we added license headers.

@@ -0,0 +1,24 @@
import { Component, OnInit, Input, Output, EventEmitter } from '@angular/core';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we need a license header here

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, we added license headers.

@@ -0,0 +1,53 @@
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we need a license header here

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, we added license headers.

@@ -0,0 +1,22 @@
import { Component, OnInit, Input } from '@angular/core';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we need a license header here

@@ -0,0 +1,38 @@
import { Component, OnInit, Input } from '@angular/core';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we need a license header here

@@ -0,0 +1,22 @@
import { Component, OnInit, Input } from '@angular/core';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we need a license header here

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, we added license headers.

@@ -0,0 +1,51 @@
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we need a license header here

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, we added license headers.

@@ -0,0 +1,65 @@
import { Component, OnInit, Input } from '@angular/core';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we need a license header here

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, we added license headers.

@@ -0,0 +1,1735 @@
import { TestBed, async, inject } from '@angular/core/testing';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we need a license header here

@@ -0,0 +1,10186 @@
import {Injectable, NgZone} from '@angular/core';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we need a license header here

@justinleet
Copy link
Contributor

There's a bug report that rat treats .ts files as binary and ignores them.
https://issues.apache.org/jira/browse/RAT-234

@cestella
Copy link
Member

I have submitted a PR to up the rat plugin version and have fixed it in master #1126, let's make sure to add license headers here for new files added in this branch though.

@merrimanr
Copy link
Contributor

I tested this in full dev and the fixed query request is incorrect. Here's what is being sent:

{
  "startTime": 0,
  "endTime": 150000000000000000,
  "srcIp": "",
  "srcPort": 22,
  "dstIp": "",
  "dstPort": "",
  "protocol": "",
  "packetFilter": "",
  "includeReverseTraffic": false
}

when it should look like:

{
  "startTimeMs": 0,
  "endTimeMs": 150000000000000000,
  "ipSrcAddr": "",
  "ipSrcPort": 22,
  "ipDstAddr": "",
  "ipDstPort": "",
  "protocol": "",
  "packetFilter": "",
  "includeReverse": false
}

I've submitted a PR that fixes the issue. The UI works as expected with those changes. Let me know if there is anything missing in that.

@mmiklavc
Copy link
Contributor

Have you included steps to reproduce the behavior or problem that is being changed or addressed?

Have you included steps or a guide to how the change may be verified and tested manually?

Can you submit or link to the test script/instructions for this?

@justinleet
Copy link
Contributor

I have a couple comments after spinning up #1122 (which should have all these changes, I believe).

  • Better input validation would be nice. I can currently enter negative ports (which don't match anything) or ports beyond max int (which match everything!). Ideally this would also happen in the REST layer, because it kicks off jobs that have nonsense parameters.
  • The UI doesn't appear to allow users to kill jobs (although the REST API exists for it). Is it correct that this isn't supported?
  • The parameters differ if you've never entered a field vs. entered then deleted it. For example, for ports (and possibly just the two port fields), it'll be empty string if never entered and null if entered then deleted. This appears to be benign, although surprising.
  • Kicking off a job, then navigating to the alerts view, then navigating back allows a user to kick off a second job. I'm not sure what happens when as these jobs finish in potentially either order (or any order if you repeat this and kick off many jobs).
  • The UI polls for job status infinitely if the REST UI dies.
  • It's odd that the port fields have increment / decrement buttons. I would expect a user to manually enter that every time.
  • I get an NPE if there are no pcaps within the date range provided by the query. This is a backend query thing, so it might be worth creating a separate ticket for it?

@mmiklavc
Copy link
Contributor

mmiklavc commented Jul 24, 2018

I'm not sure the Hadoop Job object is asynchronous anyways.

@merrimanr If I'm right on the context of the Q and A here, the PcapJob around the underlying MR job handles it async or sync. For REST, we expose it asynchronously via the job manager.

@merrimanr
Copy link
Contributor

@mmiklavc The job manager is asynchronous in that it accepts a Finalizer. We have the polling loop in place but we would need to refactor the job manager to expose a callback function for getStatus.

@justinleet I get where you're coming from, async communication would be ideal. For this use case though, I don't see much of a benefit. There is no reason we can't send status for all user jobs in response to a single polling request (a trivial change since there is already a getJobs method on the job manager). Also, we are reporting percentage done so there would likely be multiple aysnc calls anyways as the job progresses.

This is definitely something we should add to our platform and I would be happy to work on it with you. Sounds like you're ok with this being a follow on. I'm sure we'll need this construct at some point in the near future.

@mmiklavc
Copy link
Contributor

@tiborm - I see a lot of recent changes to dependency versions in the package lock file - is that intentional? Just a short comment about what it's for would be helpful.

@justinleet
Copy link
Contributor

In the screenshots you provide, the timestamp field contains both the epoch timestamp and the date. I'd have to dig in, but based on PDML files I've seen, it's displaying both the "show" and the "value". Seems like we should either be splitting that display field, or just choosing one.

OR CONDITIONS OF ANY KIND, either express or implied. See the License for
the specific language governing permissions and limitations under the License.
-->
<td class="timestamp">{{ip.timestamp.value}} <span class="date">{{ip.timestamp.show}}</span></td>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks like the culprit for the double timestamp/data showing

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@justinleet I created a ticket to get some feedback on whether we should be displaying both field values as separate fields in the UI or if we should just choose one. I'm going to hold off on making changes to this code until we get some feedback from the community.

…che/metron into feature/METRON-1554-pcap-query-panel
@tiborm
Copy link
Contributor Author

tiborm commented Jul 25, 2018

@mmiklavc We had to update a package-lock.json file because of the original one contained a package collision. npm ci command just failed on that.

@sardell sardell mentioned this pull request Jul 26, 2018
10 tasks
@tiborm
Copy link
Contributor Author

tiborm commented Jul 26, 2018

@cestella We added the license headers for all new files.

@tiborm
Copy link
Contributor Author

tiborm commented Jul 26, 2018

@mmiklavc The list of the sequential PR's in order are the following:

METRON-1671: Initial PCAP UI
#1103

METRON-1662: Adding download button
#1118

METRON-1676: Adding date range selector to PCAP filter bar
#1119

METRON-1675: Add Pagination to PCAP
#1121

METRON-1683: Fix the download progress bar in PCAP UI
#1122

@tiborm
Copy link
Contributor Author

tiborm commented Jul 27, 2018

@mmiklavc Thanks for the comment! I extended the JIRA ticket with user story like test scenarios.
Also added a short description of to the PR description about how to spin up a full dev with pcap.

@tiborm
Copy link
Contributor Author

tiborm commented Jul 27, 2018

As part of the latest commits I removed commented code blocks, and fixed the variable naming issues in pcap-packet-line.component.ts.
This PR and the followup ones are updated by the latest changes from the base branch.

@sardell
Copy link
Contributor

sardell commented Jul 27, 2018

@justinleet In response to your UI-related questions:

Better input validation would be nice. I can currently enter negative ports (which don't match anything) or ports beyond max int (which match everything!). Ideally this would also happen in the REST layer, because it kicks off jobs that have nonsense parameters.

It looks like @ruffle1986 added some validation in this branch. Are you fine with this being a follow up PR?

The UI doesn't appear to allow users to kill jobs (although the REST API exists for it). Is it correct that this isn't supported?

In the current iteration of the UI, a button to kill jobs is not available. I agree that we should add this to the UI, but if it's okay with you I think this could be a follow on PR.

The parameters differ if you've never entered a field vs. entered then deleted it. For example, for ports (and possibly just the two port fields), it'll be empty string if never entered and null if entered then deleted. This appears to be benign, although surprising.

Nice catch. I think we should open a ticket to investigate this further.

Kicking off a job, then navigating to the alerts view, then navigating back allows a user to kick off a second job. I'm not sure what happens when as these jobs finish in potentially either order (or any order if you repeat this and kick off many jobs).

If a job is now running, an error is returned from the API. The UI work to handle this is in this commit.

It's odd that the port fields have increment / decrement buttons. I would expect a user to manually enter that every time.

It looks like this was resolved by @ruffle1986 in this branch by removing the type attribute on the input.

@merrimanr
Copy link
Contributor

Given that unit tests will be addressed in a forthcoming PR, this is good enough for me as an initial UI. +1 pending other commenters are satisfied.

@merrimanr
Copy link
Contributor

Several people have given feedback on this PR. What do you think @mmiklavc, @justinleet and @cestella? Is this good enough for a first pass at the UI?

@justinleet
Copy link
Contributor

@sardell I'm fine with this stuff being follow on. Can we make sure we have tickets linked to https://issues.apache.org/jira/browse/METRON-1554?

I believe the follow-ons are

  • Input validation
  • Kill button for in progress jobs
  • Testing the backend for the null vs blank discrepancy. I don't care that the front end gives either, I care about making sure there are tests such that we're sure being provided either works as expected.

Is there anything else that tickets need to be created for (assuming I didn't just miss them)?

Once we get the tickets made (and linked here, so it's easy for anyone following the discussion to find them), I'm good with this being the basis for the rest of the UI work.

@sardell
Copy link
Contributor

sardell commented Aug 1, 2018

@justinleet Here are the tickets for the follow-on items:

I believe that's all the tickets that need to be created stemming from the discussion above.

@justinleet
Copy link
Contributor

@sardell Thanks for adding the tickets.

+1, @tiborm Thanks for your patience during the whole review process. I'm looking forward to getting the ball rolling on the rest of the contributions!

@mmiklavc
Copy link
Contributor

mmiklavc commented Aug 1, 2018

Looks like all comments have been addressed, reviewers have been able to test successfully, and any remaining follow-on work has been added to the feature branch Jira/Epic. I'm +1 by inspection. Nice work gentlemen.

@merrimanr
Copy link
Contributor

This has been merged into the feature branch. Can you close it @tiborm?

@tiborm
Copy link
Contributor Author

tiborm commented Aug 1, 2018

Thanks to everyone for the feedback and comments!

@tiborm tiborm closed this Aug 1, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants