You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@metron.apache.org by "ASF GitHub Bot (JIRA)" <ji...@apache.org> on 2018/07/19 16:55:00 UTC

[jira] [Commented] (METRON-1638) Retrieve Pcap results in pdml format

    [ https://issues.apache.org/jira/browse/METRON-1638?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16549543#comment-16549543 ] 

ASF GitHub Bot commented on METRON-1638:
----------------------------------------

GitHub user merrimanr opened a pull request:

    https://github.com/apache/metron/pull/1120

    METRON-1638: Retrieve Pcap results in pdml format

    ## Contributor Comments
    This PR adds a REST endpoint that returns pcap query results for the specified page in [PDML](https://wiki.wireshark.org/PDML) format (serialized as json instead of xml).  This will allow us to display pcap information in the Alerts UI.
    
    A new getPdml method was added to the PcapService.  This function gets a HDFS input stream given a path that's looked up by username, job id and page number.  A Java Process object calls out to a `pcap_to_pdml.sh` script that wraps a simple tshark command.  The HDFS inputs stream is connected to standard in of the script and PDML results are read from the process output stream.  Jackson is then used to convert the output xml to json and returned.
    
    ### Changes Included
    
    - A new PDML endpoint that accepts a job id and page number and returns PDML json for that page
    - A new PcapService getPath method that returns an HDFS path given a username, job id and page number
    - A new PcapService method described above
    - Annotated Jackson Javabean classes for transforming PDML xml to json
    - A `pcap_to_pdml.sh` script that wraps a simple tshark command and can be extended as needed
    - A new script path Spring property that can be changed to point to a different script location
    - Unit and integration tests
    
    ### Testing
    
    This has been tested in full dev.  Testing instructions are as follows:
    
    1. Spin up full dev
    2. Create the HDFS directories specified in application.yml
      - /apps/metron/pcap/input
      - /apps/metron/pcap/interim
      - /apps/metron/pcap/output
    3. Put pcap data in `/apps/metron/pcap/input`
    4. Run a fixed pcap query to generate results:
    ```
    curl -X POST --header 'Content-Type: application/json' --header 'Accept: application/json' -d '{
      "endTimeMs": 1458240269424,
      "startTimeMs": 1458240269419
    }' 'http://node1:8082/api/v1/pcap/fixed'
    ```
    5. Monitor the job with the get status endpoint until the job has SUCCEEDED and returns a pageTotal:
    ```
    {
      "jobId": "job_1532012905403_0001",
      "jobStatus": "SUCCEEDED",
      "description": "map: 20.0%, reduce: 0.0%",
      "percentComplete": 100,
      "pageTotal": 2
    }
    ```
    6. Attempt to get PDML results using the job id and page number:
    ```
    curl -X GET --header 'Accept: application/json' 'http://node1:8082/api/v1/pcap/job_1532012905403_0001/pdml?page=1'
    ```
    You should get an error message that clearly states wireshark is missing:
    ```
    {
      "responseCode": 500,
      "message": "/usr/metron/0.5.1/bin/pcap_to_pdml.sh: line 19: tshark: command not found\n",
      "fullMessage": "RestException: /usr/metron/0.5.1/bin/pcap_to_pdml.sh: line 19: tshark: command not found\n"
    }
    ```
    7.  Install wireshark in full dev with `yum -y install wireshark`.  This time PDML should be returned:
    ```
    {
      "version": "0",
      "creator": "wireshark/1.8.10",
      "time": "Thu Jul 19 16:47:41 2018",
      "captureFile": "",
      "packets": [
        {
          "protos": [
            {
              "name": "geninfo",
              "pos": "0",
              "showname": "General information",
              "size": "130",
              "hide": null,
              "fields": [
                {
                  "name": "num",
    ...
    }
    ```
    8.  Attempting to get PDML results for pages that don't exist (outside of the pageTotal) should return a 404.
    
    I'm still working on adding some documentation to the script and endpoint and adding dependencies to our `dependencies_with_url.csv` file.  Otherwise this PR is ready for review.  Expect another doc commit shortly.
    
    ## Pull Request Checklist
    
    Thank you for submitting a contribution to Apache Metron.  
    Please refer to our [Development Guidelines](https://cwiki.apache.org/confluence/pages/viewpage.action?pageId=61332235) for the complete guide to follow for contributions.  
    Please refer also to our [Build Verification Guidelines](https://cwiki.apache.org/confluence/display/METRON/Verifying+Builds?show-miniview) 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:
    - [x] Is there a JIRA ticket associated with this PR? If not one needs to be created at [Metron Jira](https://issues.apache.org/jira/browse/METRON/?selectedTab=com.atlassian.jira.jira-projects-plugin:summary-panel).
    - [x] 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.
    - [x] Has your PR been rebased against the latest commit within the target branch (typically master)?
    
    
    ### For code changes:
    - [x] Have you included steps to reproduce the behavior or problem that is being changed or addressed?
    - [x] Have you included steps or a guide to how the change may be verified and tested manually?
    - [x] 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 
      ```
    
    - [x] 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](http://www.apache.org/legal/resolved.html#category-a)?
    - [x] 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](https://travis-ci.org) is set up for your personal repository such that your branches are built there before submitting a pull request.


You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/merrimanr/incubator-metron METRON-1638

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/metron/pull/1120.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #1120
    
----
commit 41ecf36cd7c2da0399d03a37fee5916a9bfa87e7
Author: Michael Miklavcic <mi...@...>
Date:   2018-06-13T01:48:41Z

    Add metron-job project. Update pcap to be Statusable.

commit a83b472778e8e40cd81132f86402873ab4b8b2b1
Author: Michael Miklavcic <mi...@...>
Date:   2018-06-16T23:10:49Z

    Save progress on Pageable implementation

commit 976e1bcdf9619cc0672de4bcd7dd0d865a01cc1b
Author: Michael Miklavcic <mi...@...>
Date:   2018-06-25T19:00:03Z

    Rev metron-job to 0.5.1 after merge with master

commit f9fc106f4a33f323dc06260d861fc543726e2518
Author: Michael Miklavcic <mi...@...>
Date:   2018-06-26T22:03:21Z

    Move result writing code to pcapjob. Get pcapclitest working again.

commit 8b4ef9cdc37235c333f3cbd294f20ae15a7438aa
Author: Michael Miklavcic <mi...@...>
Date:   2018-06-27T05:31:21Z

    Add Pageable results.

commit cd302a989320a6a8970b18a94df8fbf4f11576b1
Author: Michael Miklavcic <mi...@...>
Date:   2018-06-27T15:12:42Z

    change pom change with spaces to tabs

commit 7c1d4a0bedb23e86e323b0daec21c73113065360
Author: Michael Miklavcic <mi...@...>
Date:   2018-06-27T23:20:16Z

    Address review comments. Fix local FS write path problem.

commit a00e300d8bd812589fd09970ce4db1f25dc29165
Author: Michael Miklavcic <mi...@...>
Date:   2018-06-28T03:31:02Z

    Let's try this again.

commit ba6cf9030f45b6b1a3cf270a376e4b1f5e67d6fb
Author: Michael Miklavcic <mi...@...>
Date:   2018-06-29T12:14:44Z

    Job manager and job service implementations

commit e0c40b16ea638873da394b9af7a7e99f52088ba9
Author: merrimanr <me...@...>
Date:   2018-06-29T18:57:52Z

    initial commit

commit b00884b5607e8fca93020d72198df6d665b202d3
Author: merrimanr <me...@...>
Date:   2018-07-03T18:52:17Z

    add pcap_to_pdml.sh script to RPM spec

commit a92d87347ee36aba90636e49a6bce2e391b0fd62
Author: merrimanr <me...@...>
Date:   2018-07-03T18:52:34Z

    fixed pcap_to_pdml.sh script

commit 74d12eb3d30582f0edf0e189c7aa830dc7f5b1e2
Author: merrimanr <me...@...>
Date:   2018-07-03T21:10:58Z

    pdml script now reads from standard in

commit 157aa1e3715d77373089a5c3eacfcc1dcd8d0a08
Author: Michael Miklavcic <mi...@...>
Date:   2018-07-05T17:58:55Z

    Refactor jobs to have a finalize step

commit 9fb3a81c144cab23f81de94007e85e33552fe10c
Author: Michael Miklavcic <mi...@...>
Date:   2018-07-10T16:57:05Z

    Prototyping rest api bits

commit 2bca32ed87dac15538263bdfe15ceba3d3ec3b79
Author: Michael Miklavcic <mi...@...>
Date:   2018-07-11T02:22:01Z

    merge with feature branch

commit 36456d637d9cd13a13ef34735f74d06d350772cf
Author: Michael Miklavcic <mi...@...>
Date:   2018-07-12T11:52:42Z

    Redo the pcap asychronicity  to use a Timer for checking status. Pass in config as Map

commit 6e0b64ce1c9b1c3ca1b7a6e2b58ba74c188d702a
Author: cstella <ce...@...>
Date:   2018-07-12T17:18:09Z

    Refactoring the config options to translate between object and map.

commit 0aa8e6eb967c6163c88b02c42074ced96243a7c3
Author: cstella <ce...@...>
Date:   2018-07-12T18:10:09Z

    Redoing some stuff

commit 9c6eaea48b7dc5b2cf1d6e7b7373258afbcda965
Author: cstella <ce...@...>
Date:   2018-07-12T18:15:38Z

    Removed some duplication

commit e52c5f00b9a720d7895180d36bca7285c0d0d335
Author: cstella <ce...@...>
Date:   2018-07-12T18:17:20Z

    forgot licenses

commit d4faf56078cca6b259d836b852979f6b38447399
Author: Michael Miklavcic <mi...@...>
Date:   2018-07-12T18:20:35Z

    Merge pull request #24 from cestella/pcap-job-manager-generics
    
    Pcap job manager generics from cestella

commit 7971ecba71b811b23187e70d8f41e9ec89c8da18
Author: merrimanr <me...@...>
Date:   2018-07-12T21:51:24Z

    initial commit

commit 720dab608ffcf3cb40cabc79ec69e98541b709ee
Author: Michael Miklavcic <mi...@...>
Date:   2018-07-13T19:10:49Z

    Move pcap config to metron-pcap module. Remove metron-api module completely

commit 69cb9640fab4cb645e62923565f71c37f083da9d
Author: Michael Miklavcic <mi...@...>
Date:   2018-07-13T19:21:21Z

    Move pcapoptions to config package

commit 0615ae60f7542a182f8dbd31cc07ede6b038be43
Author: Michael Miklavcic <mi...@...>
Date:   2018-07-13T23:12:23Z

    Revert PcapServiceImpl

commit 433d0a37501ae0bdc8b3e5a7b0fc3ceb9c125ebf
Author: Michael Miklavcic <mi...@...>
Date:   2018-07-14T04:02:03Z

    Get job manager working. Fix pcap cli tests. Make pcap pageable better for synchronicity. Kill remnants of the job service.

commit 935dfc84f9f8556c5fbde029561dec258c82c577
Author: merrimanr <me...@...>
Date:   2018-07-16T14:42:05Z

    Merge branch 'pcap-job-manager' of https://github.com/mmiklavc/metron into pcap-job-manager

commit 71f387160dad1d9ad53b94462ea437d29ee11323
Author: merrimanr <me...@...>
Date:   2018-07-16T14:49:25Z

    updated pcap integration test

commit 3e05b7aaca37eabbf52ada6b9fc97f98ee4342ce
Author: Michael Miklavcic <mi...@...>
Date:   2018-07-16T16:09:55Z

    Merge pull request #25 from merrimanr/pcap-job-manager
    
    Get PcapTopologyIntegrationTest working

----


> Retrieve Pcap results in pdml format
> ------------------------------------
>
>                 Key: METRON-1638
>                 URL: https://issues.apache.org/jira/browse/METRON-1638
>             Project: Metron
>          Issue Type: Sub-task
>            Reporter: Ryan Merriman
>            Priority: Major
>
> There should be a REST endpoint that allows a user to retrieve pcap page results in pdml format.  Assuming tshark is installed, there should be a "GET /api/v1/pcap/pdml/<jobId>/<pageNumber>" endpoint that will return pcap results for the given page in pdml format ([https://wiki.wireshark.org/PDML]), converted to json for easier consumption by a UI. This endpoint will call out to the tskark utility for the raw to pdml conversion.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)