Giter Club home page Giter Club logo

malicious_detection's Introduction

Malicious IPv4 or Domain Detection

Docker Image CI GitHub issues GitHub stars GitHub license GitHub license

Twitter

Update API Keys in config.json File

Get Api keys from Virustotal and Urlscan to set up the connection. urlscanApiKey and virustotalApiKey update in the config file or set and export environment variables with the above names.

Setting Virtual Environment

Create a virtual environment and install the required packages. pip install -r requirements.txt

Run FastAPI app

python main.py

Run tests

Tests for this project are defined in the tests/ folder.

This project uses pytest to define tests because it allows you to use the assert keyword with good formatting for failed assertations.

To run all the tests of a project, simply run the pytest command:

└─ $ ▶ pytest -p no:warnings tests -v --color=yes --exitfirst --showlocals --durations=5  -vv
========================================================================== test session starts ==========================================================================
platform linux -- Python 3.9.5, pytest-6.2.4, py-1.10.0, pluggy-0.13.1 -- /home/raahool/anaconda3/envs/HSBC/bin/python
cachedir: .pytest_cache
rootdir: /application/coding_test/malicious_detection
plugins: anyio-3.3.0, asyncio-0.15.1
collected 14 items                                                                                                                                                      

tests/test_main.py::test_conifguration_file_is_configured_and_loaded PASSED                                                                                       [  7%]
tests/test_main.py::test_application_response_for_200 PASSED                                                                                                      [ 14%]
tests/test_main.py::test_domain_name_validation PASSED                                                                                                            [ 21%]
tests/test_main.py::test_ip_address_validation PASSED                                                                                                             [ 28%]
tests/test_main.py::test_get_resolve_ip_address PASSED                                                                                                            [ 35%]
tests/test_main.py::test_get_resolve_damain_name PASSED                                                                                                           [ 42%]
tests/test_main.py::test_post_data_from_urlscan PASSED                                                                                                            [ 50%]
tests/test_main.py::test_get_summary_with_ip_as_path_parameter PASSED                                                                                             [ 57%]
tests/test_main.py::test_get_summary_with_domain_name_as_path_parameter PASSED                                                                                    [ 64%]
tests/test_main.py::test_get_summary_with_ip_in_query_parameter PASSED                                                                                            [ 71%]
tests/test_main.py::test_get_summary_with_domain_in_query_parameter PASSED                                                                                        [ 78%]
tests/test_main.py::test_determnation_of_malicious_result PASSED                                                                                                  [ 85%]
tests/test_main.py::test_determnation_of_malicious_result_with_domain PASSED                                                                                      [ 92%]
tests/test_main.py::test_determination_of_malicious_application_banner PASSED                                                                                     [100%]

========================================================================== slowest 5 durations ==========================================================================
38.67s call     tests/test_main.py::test_get_summary_with_ip_as_path_parameter
37.46s call     tests/test_main.py::test_get_summary_with_domain_in_query_parameter
36.53s call     tests/test_main.py::test_get_summary_with_ip_in_query_parameter
35.98s call     tests/test_main.py::test_get_summary_with_domain_name_as_path_parameter
34.86s call     tests/test_main.py::test_determnation_of_malicious_result
==================================================================== 14 passed in 219.63s (0:03:39) =====================================================================

Dockerise version

Build the Docker Image

Go to the project directory (in where your Dockerfile is, containing your app directory).

  • Build your FastAPI image:

docker build -t malicious .

Start the Docker Container

  • Run a container based on your image: docker run -d --name malicious_detection -p 80:80 malicious

Check it

You should be able to check it in your Docker container's URL, for example, http://192.168.99.100/ or http://127.0.0.1/ (or equivalent, using your Docker host).

Interactive API docs

Now you can go to http://192.168.99.100/docs or http://127.0.0.1/docs (or equivalent, using your Docker host).

Alternative API docs¶

You can also go to http://192.168.99.100/redoc or http://127.0.0.1/redoc (or equivalent, using your Docker host).

malicious_detection's People

Contributors

dependabot[bot] avatar raahoolkumeriya avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar

malicious_detection's Issues

Internal Server error

Error: Internal Server Error occurs on query parameter endpoint

Endpoint:
/?type=ip&data=ipv4_address
/?type=domain&data=domain_name

Resolve domain return valueError

Resolve domain value returning dictionary
ValueError: [ValueError('dictionary update sequence element #0 has length 24; 2 is required'), TypeError('vars() argument must have dict attribute')]

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.