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

Conversation

@cestella
Copy link
Member

Contributor Comments

This is a documented use-case on how to use the following JIRAs (PRs) to detect typosquatting in-stream using bloom filters:

The code here is a merger of the PRs above to allow reviewers to test the entire feature together. The manual testing plan is to execute the typosquatting use-case instructions.

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 && 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.

@cestella cestella changed the title METRON-1380: Create a typosquatting use-case METRON-1380: Create a typosquatting use-case (commit after METRON-1379, METRON-1377, METRON-1378) Dec 22, 2017
@cestella cestella closed this Dec 23, 2017
@@ -0,0 +1,431 @@
# Problem Statement
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you please add the license header to this? #884 is close to going in and enforcing this, so I'm hoping to avoid impact to master.

<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements.  See the NOTICE file
distributed with this work for additional information
regarding copyright ownership.  The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License.  You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->

we have to adjust the mappings for the indices we just created to add the `alert` nested property. You can
do that via the following:
```
curl -XPUT "http://$ES_HOST/squid*/_mapping/squid_doc" -d '{
Copy link
Contributor

Choose a reason for hiding this comment

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

You should just be able to do:

curl -XPUT "http://$ES_HOST/squid*/_mapping/squid_doc" -d '
{
        "properties" : {
          "alert" : {
            "type" : "nested"
          }
        }
}
'

Adding a mapping should be able to be done without having the whole template, iirc.

Copy link
Contributor

Choose a reason for hiding this comment

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

Also, this whole segment is 2.x format right (e.g. string types)? If it is necessary in full, it'll have to migrate to 5.x.

Copy link
Member Author

Choose a reason for hiding this comment

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

Very good catch. I adjusted it and tried it and it worked. IF you still have vagrant up, would you mind updating and using the new mapping?

@justinleet
Copy link
Contributor

I ran through the instructions. The new data flowing automatically into the default ES mapping causes the problem that fielddata isn't true, so grouping queries don't match on the squid index and it doesn't show up in the UI.

{
  "responseCode": 500,
  "message": "Failed to execute search; error='IllegalArgumentException: Fielddata is disabled on text fields by default. Set fielddata=true on [source:type] in order to load fielddata in memory by uninverting the inverted index. Note that this can however use significant memory. Alternatively use a keyword field instead.', search='{\"query\":{\"bool\":{\"must\":[{\"query_string\":{\"query\":\"*\",\"fields\":[],\"use_dis_max\":true,\"tie_breaker\":0.0,\"default_operator\":\"or\",\"auto_generate_phrase_queries\":false,\"max_determinized_states\":10000,\"enable_position_increments\":true,\"fuzziness\":\"AUTO\",\"fuzzy_prefix_length\":0,\"fuzzy_max_expansions\":50,\"phrase_slop\":0,\"escape\":false,\"split_on_whitespace\":true,\"boost\":1.0}}],\"must_not\":[{\"exists\":{\"field\":\"metaalerts\",\"boost\":1.0}}],\"disable_coord\":false,\"adjust_pure_negative\":true,\"boost\":1.0}},\"aggregations\":{\"source:type_group\":{\"terms\":{\"field\":\"source:type\",\"size\":1000,\"min_doc_count\":1,\"shard_min_doc_count\":0,\"show_term_doc_count_error\":false,\"order\":{\"_term\":\"desc\"}},\"aggregations\":{\"threat:triage:score_score\":{\"sum\":{\"field\":\"threat:triage:score\",\"missing\":0}}}}}}'",
  "fullMessage": "IllegalArgumentException: Fielddata is disabled on text fields by default. Set fielddata=true on [source:type] in order to load fielddata in memory by uninverting the inverted index. Note that this can however use significant memory. Alternatively use a keyword field instead."
}

The data does show up as expected in ES via direct query,

curl -XGET 'localhost:9200/squid*/_search?pretty' -H 'Content-Type: application/json' -d'
{
    "query": {
        "match_all": {}
    }
}
'

while on full dev.

This seems primarily like a matter of updating the instructions appropriately.

@cestella
Copy link
Member Author

cestella commented Jan 8, 2018

@justinleet Instructions updated, good catch.

@justinleet
Copy link
Contributor

I ran this up and was able to complete the example and see the data flow through to the alerts UI. Everything worked really well, and the instructions were very clear.

I think once the PRs this depends on are in, this is good to go in my mind. I would like to see those merged (and this appropriately merged from master) before I'm +1.

@justinleet
Copy link
Contributor

+1, thanks for the hard work in getting everything cleaned up!

@asfgit asfgit closed this in 7aa08ae Jan 16, 2018
ottobackwards pushed a commit to ottobackwards/metron that referenced this pull request Jan 22, 2018
iraghumitra pushed a commit to iraghumitra/incubator-metron that referenced this pull request Feb 17, 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.

2 participants