From 4ac756489a74ca8210e06895d1a29f486f9ebcfe Mon Sep 17 00:00:00 2001 From: oshynk <80475008+oshynk@users.noreply.github.com> Date: Fri, 14 May 2021 10:18:29 +0300 Subject: [PATCH 01/13] [CCTRI-2185] Add 404 error handling and warning to CTR_ENTITIES_LIMIT variable (#36) * [CCTRI-2185] Add 404 error handling and warning to CTR_ENTITIES_LIMIT variable * [CCTRI-2185] Fix for unit tests Co-authored-by: Lena Shynkarenko --- code/api/utils.py | 2 ++ code/requirements.txt | 1 + module_type.json.sample | 2 +- 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/code/api/utils.py b/code/api/utils.py index a263c17..71bf4f2 100644 --- a/code/api/utils.py +++ b/code/api/utils.py @@ -1,4 +1,5 @@ import json +from json.decoder import JSONDecodeError import jwt import requests @@ -36,6 +37,7 @@ def get_public_key(jwks_host, token): expected_errors = { ConnectionError: WRONG_JWKS_HOST, InvalidURL: WRONG_JWKS_HOST, + JSONDecodeError: WRONG_JWKS_HOST } try: diff --git a/code/requirements.txt b/code/requirements.txt index e6e03c7..7797ef3 100644 --- a/code/requirements.txt +++ b/code/requirements.txt @@ -6,3 +6,4 @@ pyjwt[crypto]==2.0.1 flake8==3.9.0 coverage==5.2.1 pytest==6.2.2 +Werkzeug==1.0.1 diff --git a/module_type.json.sample b/module_type.json.sample index 520645a..ff03eb1 100644 --- a/module_type.json.sample +++ b/module_type.json.sample @@ -48,7 +48,7 @@ "key": "custom_CTR_ENTITIES_LIMIT", "type": "integer", "label": "Entities Limit", - "tooltip": "Restricts the maximum number of `Sightings`", + "tooltip": "Restricts the maximum number of `Sightings`. Please note that the number over 100 might lead to data inconsistency.", "group": "Integration module configuration", "required": false } From 10537d85ba38db22ae37fa2c009a917c6aaf3f3e Mon Sep 17 00:00:00 2001 From: YevhenLysen Date: Thu, 17 Jun 2021 23:31:35 +0300 Subject: [PATCH 02/13] Added Jenkinsfile --- Jenkinsfile | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 Jenkinsfile diff --git a/Jenkinsfile b/Jenkinsfile new file mode 100644 index 0000000..e8ac0fd --- /dev/null +++ b/Jenkinsfile @@ -0,0 +1,3 @@ +@Library('softserve-jenkins-library@main') _ + +startPipeline() From 180482a308da92f11a927908d9c1903e2de6a6af Mon Sep 17 00:00:00 2001 From: Michelle Dougal <78505366+mdougal@users.noreply.github.com> Date: Fri, 9 Jul 2021 15:47:21 -0400 Subject: [PATCH 03/13] Updated tips --- module_type.json.sample | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/module_type.json.sample b/module_type.json.sample index ff03eb1..12a7845 100644 --- a/module_type.json.sample +++ b/module_type.json.sample @@ -3,7 +3,7 @@ "default_name": "Microsoft Graph Security API", "short_description": "The Microsoft Graph Security API is an intermediary service that provides a single programmatic interface to connect multiple Microsoft Graph Security providers. Requests to the Microsoft Graph Security API are federated to all applicable security providers.", "description": "Part of Microsoft Graph, the Microsoft Graph Security API integrates with security solutions from Microsoft and partners in a federated model; it can also be used in conjunction with other Microsoft Graph entities to gain additional context (for example, Office 365 and Azure AD). The API has multiple entities, including: \n- Alerts from multiple security solutions, each representing that potentially malicious activity has been detected within the organization. \n- Secure Score provides information about an organization’s security posture, including a numeric rating based on elements like the enabled security features in your environment and outstanding security risks. This score is available at the tenant level as well as at a specific control area, such as device, app, and identity, through Secure Score Control Profiles. Scores and profiles are available from each security provider that offers them—valuable information that can help guide vulnerability remediation actions based on the suggested actions available in each profile. By default, 90 days of data is retained. \n- Threat intelligence indicators refer to information about known threats, such as malicious IP addresses, domains, or URLs. Organizations can send their threat intelligence to targeted Microsoft services to enable custom detections.", - "tips": "When configuring this integration, you must create an app in [Azure](https://portal.azure.com/). \n\n1. Follow steps to [register an application with the Microsoft identity platform](https://docs.microsoft.com/en-us/graph/security-authorization#register-an-application-with-the-microsoft-identity-platform-endpoint)\n2. Complete the **Add New Microsoft Graph Security API Module** form:\n - **Module Name** - Leave the default name or enter a name that is meaningful to you\n - Enter the **Application ID**, **Tenant ID**, **Client Secret** from your Microsoft Graph Security API credentials\n - **Entities Limit** - Enter the limit that restricts the maximum number of CTIM entities of each type returned in a single response per each requested observable. Must be a positive integer. Defaults to 100 (if unset or incorrect).\n 4. Click **Save** to complete the Microsoft Graph Security API module configuration", + "tips": "When configuring Microsoft Graph Security API integration, you must create an app in the [Azure Portal](https://portal.azure.com/). After this is complete, you then add the Microsoft Graph Security API integration module in SecureX.\n\n1. Register an application with the Microsoft identity platform. For details, see [Register an application with the Microsoft identity platform endpoint](https://docs.microsoft.com/en-us/graph/security-authorization#register-an-application-with-the-microsoft-identity-platform-endpoint).\n2. In SecureX, complete the **Add New Microsoft Graph Security API Integration Module** form:\n - **Integration Module Name** - Leave the default name or enter a name that is meaningful to you.\n - **Application ID**, **Tenant ID**, and **Client Secret** - Enter the account information from your Microsoft Graph Security API credentials.\n - **Entities Limit** - Specify the maximum number of sightings in a single response, per requested observable (must be a positive value). We recommend that you enter a limit in the range of 50 to 1000. The default is 100 entities.\n\n 4. Click **Save** to complete the Microsoft Graph Security API integration module configuration.", "external_references": [ { "label": "Data Sheet", From 02ca505450b57838cf56e648a96926639d3b8917 Mon Sep 17 00:00:00 2001 From: mstoro <78480384+mstoro@users.noreply.github.com> Date: Mon, 12 Jul 2021 17:45:18 +0300 Subject: [PATCH 04/13] [CCTRI-2425] Add warning and 403 error handling (#39) --- code/api/utils.py | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/code/api/utils.py b/code/api/utils.py index 71bf4f2..e1f4a3d 100644 --- a/code/api/utils.py +++ b/code/api/utils.py @@ -5,7 +5,7 @@ import requests from flask import request, current_app, jsonify, g from jwt import InvalidSignatureError, DecodeError, InvalidAudienceError -from requests.exceptions import ConnectionError, InvalidURL +from requests.exceptions import ConnectionError, InvalidURL, HTTPError from api.errors import InvalidArgumentError, AuthorizationError @@ -34,14 +34,16 @@ def set_ctr_entities_limit(payload): def get_public_key(jwks_host, token): - expected_errors = { - ConnectionError: WRONG_JWKS_HOST, - InvalidURL: WRONG_JWKS_HOST, - JSONDecodeError: WRONG_JWKS_HOST - } + expected_errors = ( + ConnectionError, + InvalidURL, + JSONDecodeError, + HTTPError, + ) try: response = requests.get(f"https://{jwks_host}/.well-known/jwks") + response.raise_for_status() jwks = response.json() public_keys = {} @@ -52,9 +54,8 @@ def get_public_key(jwks_host, token): ) kid = jwt.get_unverified_header(token)['kid'] return public_keys.get(kid) - except tuple(expected_errors) as error: - message = expected_errors[error.__class__] - raise AuthorizationError(message) + except expected_errors: + raise AuthorizationError(WRONG_JWKS_HOST) def get_credentials(): From d59eaad8d9d6833782596be14195990976130b4a Mon Sep 17 00:00:00 2001 From: YuriiTsekhovyi <79151889+ytsek@users.noreply.github.com> Date: Tue, 3 Aug 2021 09:53:14 +0300 Subject: [PATCH 05/13] [CCTRI-2668] - alpine&python version update (#38) --- Dockerfile | 6 ++++-- README.md | 2 ++ code/requirements.txt | 13 ++++++------- code/tests/unit/test_enrich.py | 5 +++-- 4 files changed, 15 insertions(+), 11 deletions(-) diff --git a/Dockerfile b/Dockerfile index e17c40e..ee61c0a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,8 +1,10 @@ -FROM alpine:3.13 +FROM alpine:3.14 LABEL maintainer="Ian Redden " # install packages we need -RUN apk update && apk add --no-cache musl-dev openssl-dev gcc python3 py3-configobj python3-dev supervisor git libffi-dev uwsgi-python3 uwsgi-http jq nano syslog-ng uwsgi-syslog py3-pip +RUN apk update && apk add --no-cache musl-dev openssl-dev gcc py3-configobj \ +supervisor git libffi-dev uwsgi-python3 uwsgi-http jq syslog-ng uwsgi-syslog \ +py3-pip python3-dev # do the Python dependencies ADD code /app diff --git a/README.md b/README.md index cf979e7..c4c744f 100644 --- a/README.md +++ b/README.md @@ -69,6 +69,8 @@ curl http://localhost:9090 ## Implementation Details +This application was developed and tested under Python version 3.9. + ### Implemented Relay Endpoints - `POST /health` diff --git a/code/requirements.txt b/code/requirements.txt index 7797ef3..b90da97 100644 --- a/code/requirements.txt +++ b/code/requirements.txt @@ -1,9 +1,8 @@ -Flask==1.1.2 -marshmallow==3.11.1 +Flask==2.0.1 +marshmallow==3.12.1 requests==2.25.1 cryptography==3.3.2 -pyjwt[crypto]==2.0.1 -flake8==3.9.0 -coverage==5.2.1 -pytest==6.2.2 -Werkzeug==1.0.1 +pyjwt[crypto]==2.1.0 +flake8==3.9.2 +coverage==5.5 +pytest==6.2.4 diff --git a/code/tests/unit/test_enrich.py b/code/tests/unit/test_enrich.py index 8a30f1e..6302bfc 100644 --- a/code/tests/unit/test_enrich.py +++ b/code/tests/unit/test_enrich.py @@ -150,6 +150,7 @@ def test_enrich_call_success_with_extended_error_handling( ) assert response.status_code == HTTPStatus.OK - assert response.json.pop('data') - assert response.json == service_unavailable_expected_payload + response = response.get_json() + assert response.pop('data') + assert response == service_unavailable_expected_payload assert token_mock.call_count == 3 From 1ee07da28c7bbc01cfa7c5aefb8303e74cf79cc0 Mon Sep 17 00:00:00 2001 From: YuriiTsekhovyi <79151889+ytsek@users.noreply.github.com> Date: Thu, 5 Aug 2021 14:33:47 +0300 Subject: [PATCH 06/13] Version 2.0.1 (#41) --- code/container_settings.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/container_settings.json b/code/container_settings.json index 7407b2a..d49d5a9 100644 --- a/code/container_settings.json +++ b/code/container_settings.json @@ -1,4 +1,4 @@ { - "VERSION": "2.0.0", + "VERSION": "2.0.1", "NAME": "Microsoft Graph Security" } From 62316d279f3436783bb39a087c8f46c9f6d1cf91 Mon Sep 17 00:00:00 2001 From: mstoro <78480384+mstoro@users.noreply.github.com> Date: Tue, 17 Aug 2021 11:01:41 +0300 Subject: [PATCH 07/13] [CCTRI-2939] move from pip to pipenv (#42) --- .travis.yml | 11 -- Dockerfile | 8 +- README.md | 12 +- code/Pipfile | 19 ++ code/Pipfile.lock | 415 ++++++++++++++++++++++++++++++++++++++++++ code/requirements.txt | 8 - scripts/entrypoint.sh | 6 - 7 files changed, 448 insertions(+), 31 deletions(-) delete mode 100644 .travis.yml create mode 100644 code/Pipfile create mode 100644 code/Pipfile.lock delete mode 100644 code/requirements.txt diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 61c966d..0000000 --- a/.travis.yml +++ /dev/null @@ -1,11 +0,0 @@ -services: -- docker -jobs: - include: - - stage: build&test - script: - - docker build -t tr-05-microsoft-graph . - - docker run -d -p 9090:9090 --name tr-05-microsoft-graph tr-05-microsoft-graph - - while true; do if docker logs tr-05-microsoft-graph | grep "entered RUNNING state"; then - break; else sleep 1; fi done - - curl -X POST -sSLi http://localhost:9090 | grep '200 OK' diff --git a/Dockerfile b/Dockerfile index ee61c0a..c946e9c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,14 +1,18 @@ FROM alpine:3.14 LABEL maintainer="Ian Redden " +ENV PIP_IGNORE_INSTALLED 1 + # install packages we need RUN apk update && apk add --no-cache musl-dev openssl-dev gcc py3-configobj \ -supervisor git libffi-dev uwsgi-python3 uwsgi-http jq syslog-ng uwsgi-syslog \ +supervisor libffi-dev uwsgi-python3 uwsgi-http jq syslog-ng uwsgi-syslog \ py3-pip python3-dev # do the Python dependencies ADD code /app -RUN pip3 install -r /app/requirements.txt +ADD code/Pipfile code/Pipfile.lock / +RUN set -ex && pip install --no-cache-dir --upgrade pipenv && \ + pipenv install --system RUN chown -R uwsgi.uwsgi /etc/uwsgi # copy over scripts to init diff --git a/README.md b/README.md index c4c744f..ef67e0a 100644 --- a/README.md +++ b/README.md @@ -22,19 +22,23 @@ As some providers do not fully support OData query filters yet (e.g. Office 365 ## Testing (Optional) -If you want to test the application you will require Docker and several dependencies from the [requirements.txt](code/requirements.txt) file: +Open the code folder in your terminal. ``` -pip install --upgrade --requirement code/requirements.txt +cd code +``` + +If you want to test the application you will require Docker and several dependencies from the [Pipfile](code/Pipfile) file: +``` +pip install --no-cache-dir --upgrade pipenv && pipenv install --dev ``` You can perform two kinds of testing: - Run static code analysis checking for any semantic discrepancies and [PEP 8](https://www.python.org/dev/peps/pep-0008/) compliance: - `flake8 code` + `flake8 .` - Run the suite of unit tests and measure the code coverage: - `cd code` `coverage run --source api/ -m pytest --verbose tests/unit/ && coverage report` **NOTE.** If you need input data for testing purposes you can use data from the diff --git a/code/Pipfile b/code/Pipfile new file mode 100644 index 0000000..906db61 --- /dev/null +++ b/code/Pipfile @@ -0,0 +1,19 @@ +[[source]] +url = "https://pypi.org/simple" +verify_ssl = true +name = "pypi" + +[packages] +cryptography = "==3.3.2" +Flask = "==2.0.1" +marshmallow = "==3.12.1" +requests = "==2.25.1" +PyJWT = "==2.1.0" + +[dev-packages] +flake8 = "==3.9.2" +coverage = "==5.5" +pytest = "==6.2.4" + +[requires] +python_version = "3.9" diff --git a/code/Pipfile.lock b/code/Pipfile.lock new file mode 100644 index 0000000..30e17e1 --- /dev/null +++ b/code/Pipfile.lock @@ -0,0 +1,415 @@ +{ + "_meta": { + "hash": { + "sha256": "fdd746951392809b96e62d08cd666bb3a10042655dedf07c39610f4c56f43326" + }, + "pipfile-spec": 6, + "requires": { + "python_version": "3.9" + }, + "sources": [ + { + "name": "pypi", + "url": "https://pypi.org/simple", + "verify_ssl": true + } + ] + }, + "default": { + "certifi": { + "hashes": [ + "sha256:2bbf76fd432960138b3ef6dda3dde0544f27cbf8546c458e60baf371917ba9ee", + "sha256:50b1e4f8446b06f41be7dd6338db18e0990601dce795c2b1686458aa7e8fa7d8" + ], + "version": "==2021.5.30" + }, + "cffi": { + "hashes": [ + "sha256:06c54a68935738d206570b20da5ef2b6b6d92b38ef3ec45c5422c0ebaf338d4d", + "sha256:0c0591bee64e438883b0c92a7bed78f6290d40bf02e54c5bf0978eaf36061771", + "sha256:19ca0dbdeda3b2615421d54bef8985f72af6e0c47082a8d26122adac81a95872", + "sha256:22b9c3c320171c108e903d61a3723b51e37aaa8c81255b5e7ce102775bd01e2c", + "sha256:26bb2549b72708c833f5abe62b756176022a7b9a7f689b571e74c8478ead51dc", + "sha256:33791e8a2dc2953f28b8d8d300dde42dd929ac28f974c4b4c6272cb2955cb762", + "sha256:3c8d896becff2fa653dc4438b54a5a25a971d1f4110b32bd3068db3722c80202", + "sha256:4373612d59c404baeb7cbd788a18b2b2a8331abcc84c3ba40051fcd18b17a4d5", + "sha256:487d63e1454627c8e47dd230025780e91869cfba4c753a74fda196a1f6ad6548", + "sha256:48916e459c54c4a70e52745639f1db524542140433599e13911b2f329834276a", + "sha256:4922cd707b25e623b902c86188aca466d3620892db76c0bdd7b99a3d5e61d35f", + "sha256:55af55e32ae468e9946f741a5d51f9896da6b9bf0bbdd326843fec05c730eb20", + "sha256:57e555a9feb4a8460415f1aac331a2dc833b1115284f7ded7278b54afc5bd218", + "sha256:5d4b68e216fc65e9fe4f524c177b54964af043dde734807586cf5435af84045c", + "sha256:64fda793737bc4037521d4899be780534b9aea552eb673b9833b01f945904c2e", + "sha256:6d6169cb3c6c2ad50db5b868db6491a790300ade1ed5d1da29289d73bbe40b56", + "sha256:7bcac9a2b4fdbed2c16fa5681356d7121ecabf041f18d97ed5b8e0dd38a80224", + "sha256:80b06212075346b5546b0417b9f2bf467fea3bfe7352f781ffc05a8ab24ba14a", + "sha256:818014c754cd3dba7229c0f5884396264d51ffb87ec86e927ef0be140bfdb0d2", + "sha256:8eb687582ed7cd8c4bdbff3df6c0da443eb89c3c72e6e5dcdd9c81729712791a", + "sha256:99f27fefe34c37ba9875f224a8f36e31d744d8083e00f520f133cab79ad5e819", + "sha256:9f3e33c28cd39d1b655ed1ba7247133b6f7fc16fa16887b120c0c670e35ce346", + "sha256:a8661b2ce9694ca01c529bfa204dbb144b275a31685a075ce123f12331be790b", + "sha256:a9da7010cec5a12193d1af9872a00888f396aba3dc79186604a09ea3ee7c029e", + "sha256:aedb15f0a5a5949ecb129a82b72b19df97bbbca024081ed2ef88bd5c0a610534", + "sha256:b315d709717a99f4b27b59b021e6207c64620790ca3e0bde636a6c7f14618abb", + "sha256:ba6f2b3f452e150945d58f4badd92310449876c4c954836cfb1803bdd7b422f0", + "sha256:c33d18eb6e6bc36f09d793c0dc58b0211fccc6ae5149b808da4a62660678b156", + "sha256:c9a875ce9d7fe32887784274dd533c57909b7b1dcadcc128a2ac21331a9765dd", + "sha256:c9e005e9bd57bc987764c32a1bee4364c44fdc11a3cc20a40b93b444984f2b87", + "sha256:d2ad4d668a5c0645d281dcd17aff2be3212bc109b33814bbb15c4939f44181cc", + "sha256:d950695ae4381ecd856bcaf2b1e866720e4ab9a1498cba61c602e56630ca7195", + "sha256:e22dcb48709fc51a7b58a927391b23ab37eb3737a98ac4338e2448bef8559b33", + "sha256:e8c6a99be100371dbb046880e7a282152aa5d6127ae01783e37662ef73850d8f", + "sha256:e9dc245e3ac69c92ee4c167fbdd7428ec1956d4e754223124991ef29eb57a09d", + "sha256:eb687a11f0a7a1839719edd80f41e459cc5366857ecbed383ff376c4e3cc6afd", + "sha256:eb9e2a346c5238a30a746893f23a9535e700f8192a68c07c0258e7ece6ff3728", + "sha256:ed38b924ce794e505647f7c331b22a693bee1538fdf46b0222c4717b42f744e7", + "sha256:f0010c6f9d1a4011e429109fda55a225921e3206e7f62a0c22a35344bfd13cca", + "sha256:f0c5d1acbfca6ebdd6b1e3eded8d261affb6ddcf2186205518f1428b8569bb99", + "sha256:f10afb1004f102c7868ebfe91c28f4a712227fe4cb24974350ace1f90e1febbf", + "sha256:f174135f5609428cc6e1b9090f9268f5c8935fddb1b25ccb8255a2d50de6789e", + "sha256:f3ebe6e73c319340830a9b2825d32eb6d8475c1dac020b4f0aa774ee3b898d1c", + "sha256:f627688813d0a4140153ff532537fbe4afea5a3dffce1f9deb7f91f848a832b5", + "sha256:fd4305f86f53dfd8cd3522269ed7fc34856a8ee3709a5e28b2836b2db9d4cd69" + ], + "version": "==1.14.6" + }, + "chardet": { + "hashes": [ + "sha256:0d6f53a15db4120f2b08c94f11e7d93d2c911ee118b6b30a04ec3ee8310179fa", + "sha256:f864054d66fd9118f2e67044ac8981a54775ec5b67aed0441892edb553d21da5" + ], + "markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3, 3.4'", + "version": "==4.0.0" + }, + "click": { + "hashes": [ + "sha256:8c04c11192119b1ef78ea049e0a6f0463e4c48ef00a30160c704337586f3ad7a", + "sha256:fba402a4a47334742d782209a7c79bc448911afe1149d07bdabdf480b3e2f4b6" + ], + "markers": "python_version >= '3.6'", + "version": "==8.0.1" + }, + "cryptography": { + "hashes": [ + "sha256:0d7b69674b738068fa6ffade5c962ecd14969690585aaca0a1b1fc9058938a72", + "sha256:1bd0ccb0a1ed775cd7e2144fe46df9dc03eefd722bbcf587b3e0616ea4a81eff", + "sha256:3c284fc1e504e88e51c428db9c9274f2da9f73fdf5d7e13a36b8ecb039af6e6c", + "sha256:49570438e60f19243e7e0d504527dd5fe9b4b967b5a1ff21cc12b57602dd85d3", + "sha256:541dd758ad49b45920dda3b5b48c968f8b2533d8981bcdb43002798d8f7a89ed", + "sha256:5a60d3780149e13b7a6ff7ad6526b38846354d11a15e21068e57073e29e19bed", + "sha256:7951a966613c4211b6612b0352f5bf29989955ee592c4a885d8c7d0f830d0433", + "sha256:922f9602d67c15ade470c11d616f2b2364950602e370c76f0c94c94ae672742e", + "sha256:a0f0b96c572fc9f25c3f4ddbf4688b9b38c69836713fb255f4a2715d93cbaf44", + "sha256:a777c096a49d80f9d2979695b835b0f9c9edab73b59e4ceb51f19724dda887ed", + "sha256:a9a4ac9648d39ce71c2f63fe7dc6db144b9fa567ddfc48b9fde1b54483d26042", + "sha256:aa4969f24d536ae2268c902b2c3d62ab464b5a66bcb247630d208a79a8098e9b", + "sha256:c7390f9b2119b2b43160abb34f63277a638504ef8df99f11cb52c1fda66a2e6f", + "sha256:e18e6ab84dfb0ab997faf8cca25a86ff15dfea4027b986322026cc99e0a892da" + ], + "index": "pypi", + "version": "==3.3.2" + }, + "flask": { + "hashes": [ + "sha256:1c4c257b1892aec1398784c63791cbaa43062f1f7aeb555c4da961b20ee68f55", + "sha256:a6209ca15eb63fc9385f38e452704113d679511d9574d09b2cf9183ae7d20dc9" + ], + "index": "pypi", + "version": "==2.0.1" + }, + "idna": { + "hashes": [ + "sha256:b307872f855b18632ce0c21c5e45be78c0ea7ae4c15c828c20788b26921eb3f6", + "sha256:b97d804b1e9b523befed77c48dacec60e6dcb0b5391d57af6a65a312a90648c0" + ], + "markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3'", + "version": "==2.10" + }, + "itsdangerous": { + "hashes": [ + "sha256:5174094b9637652bdb841a3029700391451bd092ba3db90600dea710ba28e97c", + "sha256:9e724d68fc22902a1435351f84c3fb8623f303fffcc566a4cb952df8c572cff0" + ], + "markers": "python_version >= '3.6'", + "version": "==2.0.1" + }, + "jinja2": { + "hashes": [ + "sha256:1f06f2da51e7b56b8f238affdd6b4e2c61e39598a378cc49345bc1bd42a978a4", + "sha256:703f484b47a6af502e743c9122595cc812b0271f661722403114f71a79d0f5a4" + ], + "markers": "python_version >= '3.6'", + "version": "==3.0.1" + }, + "markupsafe": { + "hashes": [ + "sha256:01a9b8ea66f1658938f65b93a85ebe8bc016e6769611be228d797c9d998dd298", + "sha256:023cb26ec21ece8dc3907c0e8320058b2e0cb3c55cf9564da612bc325bed5e64", + "sha256:0446679737af14f45767963a1a9ef7620189912317d095f2d9ffa183a4d25d2b", + "sha256:0717a7390a68be14b8c793ba258e075c6f4ca819f15edfc2a3a027c823718567", + "sha256:0955295dd5eec6cb6cc2fe1698f4c6d84af2e92de33fbcac4111913cd100a6ff", + "sha256:0d4b31cc67ab36e3392bbf3862cfbadac3db12bdd8b02a2731f509ed5b829724", + "sha256:10f82115e21dc0dfec9ab5c0223652f7197feb168c940f3ef61563fc2d6beb74", + "sha256:168cd0a3642de83558a5153c8bd34f175a9a6e7f6dc6384b9655d2697312a646", + "sha256:1d609f577dc6e1aa17d746f8bd3c31aa4d258f4070d61b2aa5c4166c1539de35", + "sha256:1f2ade76b9903f39aa442b4aadd2177decb66525062db244b35d71d0ee8599b6", + "sha256:2a7d351cbd8cfeb19ca00de495e224dea7e7d919659c2841bbb7f420ad03e2d6", + "sha256:2d7d807855b419fc2ed3e631034685db6079889a1f01d5d9dac950f764da3dad", + "sha256:2ef54abee730b502252bcdf31b10dacb0a416229b72c18b19e24a4509f273d26", + "sha256:36bc903cbb393720fad60fc28c10de6acf10dc6cc883f3e24ee4012371399a38", + "sha256:37205cac2a79194e3750b0af2a5720d95f786a55ce7df90c3af697bfa100eaac", + "sha256:3c112550557578c26af18a1ccc9e090bfe03832ae994343cfdacd287db6a6ae7", + "sha256:3dd007d54ee88b46be476e293f48c85048603f5f516008bee124ddd891398ed6", + "sha256:47ab1e7b91c098ab893b828deafa1203de86d0bc6ab587b160f78fe6c4011f75", + "sha256:49e3ceeabbfb9d66c3aef5af3a60cc43b85c33df25ce03d0031a608b0a8b2e3f", + "sha256:4efca8f86c54b22348a5467704e3fec767b2db12fc39c6d963168ab1d3fc9135", + "sha256:53edb4da6925ad13c07b6d26c2a852bd81e364f95301c66e930ab2aef5b5ddd8", + "sha256:5855f8438a7d1d458206a2466bf82b0f104a3724bf96a1c781ab731e4201731a", + "sha256:594c67807fb16238b30c44bdf74f36c02cdf22d1c8cda91ef8a0ed8dabf5620a", + "sha256:5bb28c636d87e840583ee3adeb78172efc47c8b26127267f54a9c0ec251d41a9", + "sha256:60bf42e36abfaf9aff1f50f52644b336d4f0a3fd6d8a60ca0d054ac9f713a864", + "sha256:611d1ad9a4288cf3e3c16014564df047fe08410e628f89805e475368bd304914", + "sha256:6557b31b5e2c9ddf0de32a691f2312a32f77cd7681d8af66c2692efdbef84c18", + "sha256:693ce3f9e70a6cf7d2fb9e6c9d8b204b6b39897a2c4a1aa65728d5ac97dcc1d8", + "sha256:6a7fae0dd14cf60ad5ff42baa2e95727c3d81ded453457771d02b7d2b3f9c0c2", + "sha256:6c4ca60fa24e85fe25b912b01e62cb969d69a23a5d5867682dd3e80b5b02581d", + "sha256:6fcf051089389abe060c9cd7caa212c707e58153afa2c649f00346ce6d260f1b", + "sha256:7d91275b0245b1da4d4cfa07e0faedd5b0812efc15b702576d103293e252af1b", + "sha256:905fec760bd2fa1388bb5b489ee8ee5f7291d692638ea5f67982d968366bef9f", + "sha256:97383d78eb34da7e1fa37dd273c20ad4320929af65d156e35a5e2d89566d9dfb", + "sha256:984d76483eb32f1bcb536dc27e4ad56bba4baa70be32fa87152832cdd9db0833", + "sha256:99df47edb6bda1249d3e80fdabb1dab8c08ef3975f69aed437cb69d0a5de1e28", + "sha256:a30e67a65b53ea0a5e62fe23682cfe22712e01f453b95233b25502f7c61cb415", + "sha256:ab3ef638ace319fa26553db0624c4699e31a28bb2a835c5faca8f8acf6a5a902", + "sha256:add36cb2dbb8b736611303cd3bfcee00afd96471b09cda130da3581cbdc56a6d", + "sha256:b2f4bf27480f5e5e8ce285a8c8fd176c0b03e93dcc6646477d4630e83440c6a9", + "sha256:b7f2d075102dc8c794cbde1947378051c4e5180d52d276987b8d28a3bd58c17d", + "sha256:baa1a4e8f868845af802979fcdbf0bb11f94f1cb7ced4c4b8a351bb60d108145", + "sha256:be98f628055368795d818ebf93da628541e10b75b41c559fdf36d104c5787066", + "sha256:bf5d821ffabf0ef3533c39c518f3357b171a1651c1ff6827325e4489b0e46c3c", + "sha256:c47adbc92fc1bb2b3274c4b3a43ae0e4573d9fbff4f54cd484555edbf030baf1", + "sha256:d7f9850398e85aba693bb640262d3611788b1f29a79f0c93c565694658f4071f", + "sha256:d8446c54dc28c01e5a2dbac5a25f071f6653e6e40f3a8818e8b45d790fe6ef53", + "sha256:e0f138900af21926a02425cf736db95be9f4af72ba1bb21453432a07f6082134", + "sha256:e9936f0b261d4df76ad22f8fee3ae83b60d7c3e871292cd42f40b81b70afae85", + "sha256:f5653a225f31e113b152e56f154ccbe59eeb1c7487b39b9d9f9cdb58e6c79dc5", + "sha256:f826e31d18b516f653fe296d967d700fddad5901ae07c622bb3705955e1faa94", + "sha256:f8ba0e8349a38d3001fae7eadded3f6606f0da5d748ee53cc1dab1d6527b9509", + "sha256:f9081981fe268bd86831e5c75f7de206ef275defcb82bc70740ae6dc507aee51", + "sha256:fa130dd50c57d53368c9d59395cb5526eda596d3ffe36666cd81a44d56e48872" + ], + "markers": "python_version >= '3.6'", + "version": "==2.0.1" + }, + "marshmallow": { + "hashes": [ + "sha256:8050475b70470cc58f4441ee92375db611792ba39ca1ad41d39cad193ea9e040", + "sha256:b45cde981d1835145257b4a3c5cb7b80786dcf5f50dd2990749a50c16cb48e01" + ], + "index": "pypi", + "version": "==3.12.1" + }, + "pycparser": { + "hashes": [ + "sha256:2d475327684562c3a96cc71adf7dc8c4f0565175cf86b6d7a404ff4c771f15f0", + "sha256:7582ad22678f0fcd81102833f60ef8d0e57288b6b5fb00323d101be910e35705" + ], + "markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3'", + "version": "==2.20" + }, + "pyjwt": { + "hashes": [ + "sha256:934d73fbba91b0483d3857d1aff50e96b2a892384ee2c17417ed3203f173fca1", + "sha256:fba44e7898bbca160a2b2b501f492824fc8382485d3a6f11ba5d0c1937ce6130" + ], + "index": "pypi", + "version": "==2.1.0" + }, + "requests": { + "hashes": [ + "sha256:27973dd4a904a4f13b263a19c866c13b92a39ed1c964655f025f3f8d3d75b804", + "sha256:c210084e36a42ae6b9219e00e48287def368a26d03a048ddad7bfee44f75871e" + ], + "index": "pypi", + "version": "==2.25.1" + }, + "six": { + "hashes": [ + "sha256:1e61c37477a1626458e36f7b1d82aa5c9b094fa4802892072e49de9c60c4c926", + "sha256:8abb2f1d86890a2dfb989f9a77cfcfd3e47c2a354b01111771326f8aa26e0254" + ], + "markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2'", + "version": "==1.16.0" + }, + "urllib3": { + "hashes": [ + "sha256:39fb8672126159acb139a7718dd10806104dec1e2f0f6c88aab05d17df10c8d4", + "sha256:f57b4c16c62fa2760b7e3d97c35b255512fb6b59a259730f36ba32ce9f8e342f" + ], + "markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3, 3.4' and python_version < '4'", + "version": "==1.26.6" + }, + "werkzeug": { + "hashes": [ + "sha256:1de1db30d010ff1af14a009224ec49ab2329ad2cde454c8a708130642d579c42", + "sha256:6c1ec500dcdba0baa27600f6a22f6333d8b662d22027ff9f6202e3367413caa8" + ], + "markers": "python_version >= '3.6'", + "version": "==2.0.1" + } + }, + "develop": { + "attrs": { + "hashes": [ + "sha256:149e90d6d8ac20db7a955ad60cf0e6881a3f20d37096140088356da6c716b0b1", + "sha256:ef6aaac3ca6cd92904cdd0d83f629a15f18053ec84e6432106f7a4d04ae4f5fb" + ], + "markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3, 3.4'", + "version": "==21.2.0" + }, + "coverage": { + "hashes": [ + "sha256:004d1880bed2d97151facef49f08e255a20ceb6f9432df75f4eef018fdd5a78c", + "sha256:01d84219b5cdbfc8122223b39a954820929497a1cb1422824bb86b07b74594b6", + "sha256:040af6c32813fa3eae5305d53f18875bedd079960822ef8ec067a66dd8afcd45", + "sha256:06191eb60f8d8a5bc046f3799f8a07a2d7aefb9504b0209aff0b47298333302a", + "sha256:13034c4409db851670bc9acd836243aeee299949bd5673e11844befcb0149f03", + "sha256:13c4ee887eca0f4c5a247b75398d4114c37882658300e153113dafb1d76de529", + "sha256:184a47bbe0aa6400ed2d41d8e9ed868b8205046518c52464fde713ea06e3a74a", + "sha256:18ba8bbede96a2c3dde7b868de9dcbd55670690af0988713f0603f037848418a", + "sha256:1aa846f56c3d49205c952d8318e76ccc2ae23303351d9270ab220004c580cfe2", + "sha256:217658ec7187497e3f3ebd901afdca1af062b42cfe3e0dafea4cced3983739f6", + "sha256:24d4a7de75446be83244eabbff746d66b9240ae020ced65d060815fac3423759", + "sha256:2910f4d36a6a9b4214bb7038d537f015346f413a975d57ca6b43bf23d6563b53", + "sha256:2949cad1c5208b8298d5686d5a85b66aae46d73eec2c3e08c817dd3513e5848a", + "sha256:2a3859cb82dcbda1cfd3e6f71c27081d18aa251d20a17d87d26d4cd216fb0af4", + "sha256:2cafbbb3af0733db200c9b5f798d18953b1a304d3f86a938367de1567f4b5bff", + "sha256:2e0d881ad471768bf6e6c2bf905d183543f10098e3b3640fc029509530091502", + "sha256:30c77c1dc9f253283e34c27935fded5015f7d1abe83bc7821680ac444eaf7793", + "sha256:3487286bc29a5aa4b93a072e9592f22254291ce96a9fbc5251f566b6b7343cdb", + "sha256:372da284cfd642d8e08ef606917846fa2ee350f64994bebfbd3afb0040436905", + "sha256:41179b8a845742d1eb60449bdb2992196e211341818565abded11cfa90efb821", + "sha256:44d654437b8ddd9eee7d1eaee28b7219bec228520ff809af170488fd2fed3e2b", + "sha256:4a7697d8cb0f27399b0e393c0b90f0f1e40c82023ea4d45d22bce7032a5d7b81", + "sha256:51cb9476a3987c8967ebab3f0fe144819781fca264f57f89760037a2ea191cb0", + "sha256:52596d3d0e8bdf3af43db3e9ba8dcdaac724ba7b5ca3f6358529d56f7a166f8b", + "sha256:53194af30d5bad77fcba80e23a1441c71abfb3e01192034f8246e0d8f99528f3", + "sha256:5fec2d43a2cc6965edc0bb9e83e1e4b557f76f843a77a2496cbe719583ce8184", + "sha256:6c90e11318f0d3c436a42409f2749ee1a115cd8b067d7f14c148f1ce5574d701", + "sha256:74d881fc777ebb11c63736622b60cb9e4aee5cace591ce274fb69e582a12a61a", + "sha256:7501140f755b725495941b43347ba8a2777407fc7f250d4f5a7d2a1050ba8e82", + "sha256:796c9c3c79747146ebd278dbe1e5c5c05dd6b10cc3bcb8389dfdf844f3ead638", + "sha256:869a64f53488f40fa5b5b9dcb9e9b2962a66a87dab37790f3fcfb5144b996ef5", + "sha256:8963a499849a1fc54b35b1c9f162f4108017b2e6db2c46c1bed93a72262ed083", + "sha256:8d0a0725ad7c1a0bcd8d1b437e191107d457e2ec1084b9f190630a4fb1af78e6", + "sha256:900fbf7759501bc7807fd6638c947d7a831fc9fdf742dc10f02956ff7220fa90", + "sha256:92b017ce34b68a7d67bd6d117e6d443a9bf63a2ecf8567bb3d8c6c7bc5014465", + "sha256:970284a88b99673ccb2e4e334cfb38a10aab7cd44f7457564d11898a74b62d0a", + "sha256:972c85d205b51e30e59525694670de6a8a89691186012535f9d7dbaa230e42c3", + "sha256:9a1ef3b66e38ef8618ce5fdc7bea3d9f45f3624e2a66295eea5e57966c85909e", + "sha256:af0e781009aaf59e25c5a678122391cb0f345ac0ec272c7961dc5455e1c40066", + "sha256:b6d534e4b2ab35c9f93f46229363e17f63c53ad01330df9f2d6bd1187e5eaacf", + "sha256:b7895207b4c843c76a25ab8c1e866261bcfe27bfaa20c192de5190121770672b", + "sha256:c0891a6a97b09c1f3e073a890514d5012eb256845c451bd48f7968ef939bf4ae", + "sha256:c2723d347ab06e7ddad1a58b2a821218239249a9e4365eaff6649d31180c1669", + "sha256:d1f8bf7b90ba55699b3a5e44930e93ff0189aa27186e96071fac7dd0d06a1873", + "sha256:d1f9ce122f83b2305592c11d64f181b87153fc2c2bbd3bb4a3dde8303cfb1a6b", + "sha256:d314ed732c25d29775e84a960c3c60808b682c08d86602ec2c3008e1202e3bb6", + "sha256:d636598c8305e1f90b439dbf4f66437de4a5e3c31fdf47ad29542478c8508bbb", + "sha256:deee1077aae10d8fa88cb02c845cfba9b62c55e1183f52f6ae6a2df6a2187160", + "sha256:ebe78fe9a0e874362175b02371bdfbee64d8edc42a044253ddf4ee7d3c15212c", + "sha256:f030f8873312a16414c0d8e1a1ddff2d3235655a2174e3648b4fa66b3f2f1079", + "sha256:f0b278ce10936db1a37e6954e15a3730bea96a0997c26d7fee88e6c396c2086d", + "sha256:f11642dddbb0253cc8853254301b51390ba0081750a8ac03f20ea8103f0c56b6" + ], + "index": "pypi", + "version": "==5.5" + }, + "flake8": { + "hashes": [ + "sha256:07528381786f2a6237b061f6e96610a4167b226cb926e2aa2b6b1d78057c576b", + "sha256:bf8fd333346d844f616e8d47905ef3a3384edae6b4e9beb0c5101e25e3110907" + ], + "index": "pypi", + "version": "==3.9.2" + }, + "iniconfig": { + "hashes": [ + "sha256:011e24c64b7f47f6ebd835bb12a743f2fbe9a26d4cecaa7f53bc4f35ee9da8b3", + "sha256:bc3af051d7d14b2ee5ef9969666def0cd1a000e121eaea580d4a313df4b37f32" + ], + "version": "==1.1.1" + }, + "mccabe": { + "hashes": [ + "sha256:ab8a6258860da4b6677da4bd2fe5dc2c659cff31b3ee4f7f5d64e79735b80d42", + "sha256:dd8d182285a0fe56bace7f45b5e7d1a6ebcbf524e8f3bd87eb0f125271b8831f" + ], + "version": "==0.6.1" + }, + "packaging": { + "hashes": [ + "sha256:7dc96269f53a4ccec5c0670940a4281106dd0bb343f47b7471f779df49c2fbe7", + "sha256:c86254f9220d55e31cc94d69bade760f0847da8000def4dfe1c6b872fd14ff14" + ], + "markers": "python_version >= '3.6'", + "version": "==21.0" + }, + "pluggy": { + "hashes": [ + "sha256:15b2acde666561e1298d71b523007ed7364de07029219b604cf808bfa1c765b0", + "sha256:966c145cd83c96502c3c3868f50408687b38434af77734af1e9ca461a4081d2d" + ], + "markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3'", + "version": "==0.13.1" + }, + "py": { + "hashes": [ + "sha256:21b81bda15b66ef5e1a777a21c4dcd9c20ad3efd0b3f817e7a809035269e1bd3", + "sha256:3b80836aa6d1feeaa108e046da6423ab8f6ceda6468545ae8d02d9d58d18818a" + ], + "markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3'", + "version": "==1.10.0" + }, + "pycodestyle": { + "hashes": [ + "sha256:514f76d918fcc0b55c6680472f0a37970994e07bbb80725808c17089be302068", + "sha256:c389c1d06bf7904078ca03399a4816f974a1d590090fecea0c63ec26ebaf1cef" + ], + "markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3'", + "version": "==2.7.0" + }, + "pyflakes": { + "hashes": [ + "sha256:7893783d01b8a89811dd72d7dfd4d84ff098e5eed95cfa8905b22bbffe52efc3", + "sha256:f5bc8ecabc05bb9d291eb5203d6810b49040f6ff446a756326104746cc00c1db" + ], + "markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3'", + "version": "==2.3.1" + }, + "pyparsing": { + "hashes": [ + "sha256:c203ec8783bf771a155b207279b9bccb8dea02d8f0c9e5f8ead507bc3246ecc1", + "sha256:ef9d7589ef3c200abe66653d3f1ab1033c3c419ae9b9bdb1240a85b024efc88b" + ], + "markers": "python_version >= '2.6' and python_version not in '3.0, 3.1, 3.2'", + "version": "==2.4.7" + }, + "pytest": { + "hashes": [ + "sha256:50bcad0a0b9c5a72c8e4e7c9855a3ad496ca6a881a3641b4260605450772c54b", + "sha256:91ef2131a9bd6be8f76f1f08eac5c5317221d6ad1e143ae03894b862e8976890" + ], + "index": "pypi", + "version": "==6.2.4" + }, + "toml": { + "hashes": [ + "sha256:806143ae5bfb6a3c6e736a764057db0e6a0e05e338b5630894a5f779cabb4f9b", + "sha256:b3bda1d108d5dd99f4a20d24d9c348e91c4db7ab1b749200bded2f839ccbe68f" + ], + "markers": "python_version >= '2.6' and python_version not in '3.0, 3.1, 3.2'", + "version": "==0.10.2" + } + } +} diff --git a/code/requirements.txt b/code/requirements.txt deleted file mode 100644 index b90da97..0000000 --- a/code/requirements.txt +++ /dev/null @@ -1,8 +0,0 @@ -Flask==2.0.1 -marshmallow==3.12.1 -requests==2.25.1 -cryptography==3.3.2 -pyjwt[crypto]==2.1.0 -flake8==3.9.2 -coverage==5.5 -pytest==6.2.4 diff --git a/scripts/entrypoint.sh b/scripts/entrypoint.sh index 5d7524c..bccbded 100644 --- a/scripts/entrypoint.sh +++ b/scripts/entrypoint.sh @@ -1,12 +1,6 @@ #!/usr/bin/env sh set -e -# Grab the repository -if [ -n "$GITREPO" ]; then - echo "rm -rf /app && git clone $GITREPO /app" - rm -rf /app && git clone $GITREPO /app -fi - if [ -n "$ALPINEPYTHON" ] ; then export PYTHONPATH=$PYTHONPATH:/usr/local/lib/$ALPINEPYTHON/site-packages:/usr/lib/$ALPINEPYTHON/site-packages From 5a7c43118fdcf77925300d5f742f35840ff38996 Mon Sep 17 00:00:00 2001 From: mstoro <78480384+mstoro@users.noreply.github.com> Date: Mon, 23 Aug 2021 13:25:23 +0300 Subject: [PATCH 08/13] Release 2.0.2 (#44) * Release 2.0.1 (#40) * Add 404, 403 error handling and warning to CTR_ENTITIES_LIMIT variable * Added Jenkinsfile * Updated tips * Alpine & Python version update * Release 2.0.2 Co-authored-by: YuriiTsekhovyi <79151889+ytsek@users.noreply.github.com> --- code/container_settings.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/container_settings.json b/code/container_settings.json index d49d5a9..0bf8530 100644 --- a/code/container_settings.json +++ b/code/container_settings.json @@ -1,4 +1,4 @@ { - "VERSION": "2.0.1", + "VERSION": "2.0.2", "NAME": "Microsoft Graph Security" } From aed14c2755197c64d4732435d9483301cd3dc4dd Mon Sep 17 00:00:00 2001 From: oshynk <80475008+oshynk@users.noreply.github.com> Date: Tue, 9 Nov 2021 16:22:20 +0200 Subject: [PATCH 09/13] [CCTRI-3106] Remove unused endpoints (#45) --- code/api/enrich.py | 12 +------- code/api/respond.py | 15 ---------- code/app.py | 3 +- .../functional/tests/test_lambda_relay_api.py | 4 --- code/tests/unit/test_app.py | 4 --- code/tests/unit/test_enrich.py | 22 -------------- code/tests/unit/test_respond.py | 29 ------------------- 7 files changed, 2 insertions(+), 87 deletions(-) delete mode 100644 code/api/respond.py delete mode 100644 code/tests/unit/test_respond.py diff --git a/code/api/enrich.py b/code/api/enrich.py index 89a9e81..75ab937 100644 --- a/code/api/enrich.py +++ b/code/api/enrich.py @@ -4,7 +4,7 @@ from .mappings import Mapping from .schema import ObservableSchema -from .utils import get_json, jsonify_result, jsonify_data, get_credentials +from .utils import get_json, jsonify_result, get_credentials api = Blueprint('enrich', __name__) @@ -34,13 +34,3 @@ def observe(observable): g.sightings.extend(observe(observable)) return jsonify_result() - - -@api.route('/deliberate/observables', methods=['POST']) -def deliberate(): - return jsonify_data({}) - - -@api.route('/refer/observables', methods=['POST']) -def refer(): - return jsonify_data([]) diff --git a/code/api/respond.py b/code/api/respond.py deleted file mode 100644 index 335a181..0000000 --- a/code/api/respond.py +++ /dev/null @@ -1,15 +0,0 @@ -from flask import Blueprint - -from api.utils import jsonify_data - -api = Blueprint('respond', __name__) - - -@api.route('/respond/observables', methods=['POST']) -def observables(): - return jsonify_data([]) - - -@api.route('/respond/trigger', methods=['POST']) -def trigger(): - return jsonify_data({'status': 'failure'}) diff --git a/code/app.py b/code/app.py index bda4f63..06a234d 100644 --- a/code/app.py +++ b/code/app.py @@ -1,6 +1,6 @@ from flask import Flask, jsonify -from api import health, enrich, respond, version, watchdog +from api import health, enrich, version, watchdog from api.errors import TRFormattedError from api.utils import add_error, jsonify_result @@ -9,7 +9,6 @@ app.register_blueprint(health.api) app.register_blueprint(enrich.api) -app.register_blueprint(respond.api) app.register_blueprint(version.api) app.register_blueprint(watchdog.api) diff --git a/code/tests/functional/tests/test_lambda_relay_api.py b/code/tests/functional/tests/test_lambda_relay_api.py index 483a136..c3dd5f4 100644 --- a/code/tests/functional/tests/test_lambda_relay_api.py +++ b/code/tests/functional/tests/test_lambda_relay_api.py @@ -6,11 +6,7 @@ @pytest.mark.parametrize("relay_endpoint", ( "health", - "deliberate_observables", - "refer_observables", "observe_observables", - "respond_observables", - "respond_trigger" )) def test_positive_api(relay_endpoint, relay_api): """ Test relay api mock in Graph Security diff --git a/code/tests/unit/test_app.py b/code/tests/unit/test_app.py index c621163..fa447c1 100644 --- a/code/tests/unit/test_app.py +++ b/code/tests/unit/test_app.py @@ -14,11 +14,7 @@ def calls(): yield Call('DELETE', '/delete', HTTPStatus.NOT_FOUND) yield Call('GET', '/health', HTTPStatus.METHOD_NOT_ALLOWED) - yield Call('GET', '/deliberate/observables', HTTPStatus.METHOD_NOT_ALLOWED) yield Call('GET', '/observe/observables', HTTPStatus.METHOD_NOT_ALLOWED) - yield Call('GET', '/refer/observables', HTTPStatus.METHOD_NOT_ALLOWED) - yield Call('GET', '/respond/observables', HTTPStatus.METHOD_NOT_ALLOWED) - yield Call('GET', '/respond/trigger', HTTPStatus.METHOD_NOT_ALLOWED) yield Call('GET', '/version', HTTPStatus.METHOD_NOT_ALLOWED) yield Call('POST', '/watchdog', HTTPStatus.METHOD_NOT_ALLOWED) diff --git a/code/tests/unit/test_enrich.py b/code/tests/unit/test_enrich.py index 6302bfc..017e596 100644 --- a/code/tests/unit/test_enrich.py +++ b/code/tests/unit/test_enrich.py @@ -13,28 +13,6 @@ def valid_json(): {'type': 'file_name', 'value': 'file.bin'}] -def test_deliberate_call_success( - client, valid_jwt, valid_json -): - response = client.post( - '/deliberate/observables', headers=headers(valid_jwt), json=valid_json - ) - - assert response.status_code == HTTPStatus.OK - assert response.json == {'data': {}} - - -def test_refer_call_success( - client, valid_jwt, valid_json -): - response = client.post( - '/refer/observables', headers=headers(valid_jwt), json=valid_json - ) - - assert response.status_code == HTTPStatus.OK - assert response.json == {'data': []} - - OBSERVE_OBSERVABLES_ROUTE = '/observe/observables' TOKEN = 'token' diff --git a/code/tests/unit/test_respond.py b/code/tests/unit/test_respond.py deleted file mode 100644 index 8525687..0000000 --- a/code/tests/unit/test_respond.py +++ /dev/null @@ -1,29 +0,0 @@ -from http import HTTPStatus - -from pytest import fixture - - -def routes(): - yield '/respond/observables' - yield '/respond/trigger' - - -@fixture(scope='module', params=routes(), ids=lambda route: f'POST {route}') -def route(request): - return request.param - - -@fixture(scope='module') -def expected_payload(route): - if route.endswith('/observables'): - return {'data': []} - - if route.endswith('/trigger'): - return {'data': {'status': 'failure'}} - - -def test_respond_call_success(route, client, expected_payload): - response = client.post(route) - - assert response.status_code == HTTPStatus.OK - assert response.get_json() == expected_payload From c0f8fd461ec9114823fd4225e19a0f8ac49df454 Mon Sep 17 00:00:00 2001 From: Michelle Dougal <78505366+mdougal@users.noreply.github.com> Date: Tue, 7 Dec 2021 16:06:05 -0500 Subject: [PATCH 10/13] Update description Added note to description --- module_type.json.sample | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/module_type.json.sample b/module_type.json.sample index 12a7845..9b57ea2 100644 --- a/module_type.json.sample +++ b/module_type.json.sample @@ -2,7 +2,7 @@ "title": "Microsoft Graph Security API", "default_name": "Microsoft Graph Security API", "short_description": "The Microsoft Graph Security API is an intermediary service that provides a single programmatic interface to connect multiple Microsoft Graph Security providers. Requests to the Microsoft Graph Security API are federated to all applicable security providers.", - "description": "Part of Microsoft Graph, the Microsoft Graph Security API integrates with security solutions from Microsoft and partners in a federated model; it can also be used in conjunction with other Microsoft Graph entities to gain additional context (for example, Office 365 and Azure AD). The API has multiple entities, including: \n- Alerts from multiple security solutions, each representing that potentially malicious activity has been detected within the organization. \n- Secure Score provides information about an organization’s security posture, including a numeric rating based on elements like the enabled security features in your environment and outstanding security risks. This score is available at the tenant level as well as at a specific control area, such as device, app, and identity, through Secure Score Control Profiles. Scores and profiles are available from each security provider that offers them—valuable information that can help guide vulnerability remediation actions based on the suggested actions available in each profile. By default, 90 days of data is retained. \n- Threat intelligence indicators refer to information about known threats, such as malicious IP addresses, domains, or URLs. Organizations can send their threat intelligence to targeted Microsoft services to enable custom detections.", + "description": "Part of Microsoft Graph, the Microsoft Graph Security API integrates with security solutions from Microsoft and partners in a federated model; it can also be used in conjunction with other Microsoft Graph entities to gain additional context (for example, Office 365 and Azure AD). The API has multiple entities, including: \n- Alerts from multiple security solutions, each representing that potentially malicious activity has been detected within the organization. \n- Secure Score provides information about an organization’s security posture, including a numeric rating based on elements like the enabled security features in your environment and outstanding security risks. This score is available at the tenant level as well as at a specific control area, such as device, app, and identity, through Secure Score Control Profiles. Scores and profiles are available from each security provider that offers them—valuable information that can help guide vulnerability remediation actions based on the suggested actions available in each profile. By default, 90 days of data is retained. \n- Threat intelligence indicators refer to information about known threats, such as malicious IP addresses, domains, or URLs. Organizations can send their threat intelligence to targeted Microsoft services to enable custom detections.\n\n**Note:** The Microsoft Graph Security Relay uses Open Data Protocol (OData) filters (specifically the any lambda operator) while querying data from Microsoft Graph Security API. The Microsoft Graph Security API is a federation service that merges data from various Microsoft alert providers. As some providers do not support OData query filters (for example, Office 365 Security and Compliance and Microsoft Defender Advanced Threat Protection), alerts from those providers will not be included in the Microsoft Graph Security Relay output.", "tips": "When configuring Microsoft Graph Security API integration, you must create an app in the [Azure Portal](https://portal.azure.com/). After this is complete, you then add the Microsoft Graph Security API integration module in SecureX.\n\n1. Register an application with the Microsoft identity platform. For details, see [Register an application with the Microsoft identity platform endpoint](https://docs.microsoft.com/en-us/graph/security-authorization#register-an-application-with-the-microsoft-identity-platform-endpoint).\n2. In SecureX, complete the **Add New Microsoft Graph Security API Integration Module** form:\n - **Integration Module Name** - Leave the default name or enter a name that is meaningful to you.\n - **Application ID**, **Tenant ID**, and **Client Secret** - Enter the account information from your Microsoft Graph Security API credentials.\n - **Entities Limit** - Specify the maximum number of sightings in a single response, per requested observable (must be a positive value). We recommend that you enter a limit in the range of 50 to 1000. The default is 100 entities.\n\n 4. Click **Save** to complete the Microsoft Graph Security API integration module configuration.", "external_references": [ { From 7a4aa60632b83b23705329dad80240273099876e Mon Sep 17 00:00:00 2001 From: mstoro <78480384+mstoro@users.noreply.github.com> Date: Mon, 13 Dec 2021 16:58:03 +0200 Subject: [PATCH 11/13] [CCTRI-3409] add traceback to log file (#46) --- code/app.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/code/app.py b/code/app.py index 06a234d..82b4343 100644 --- a/code/app.py +++ b/code/app.py @@ -1,3 +1,5 @@ +import traceback + from flask import Flask, jsonify from api import health, enrich, version, watchdog @@ -15,14 +17,14 @@ @app.errorhandler(TRFormattedError) def handle_tr_formatted_error(error): - app.logger.error(error.json) + app.logger.error(traceback.format_exc()) add_error(error) return jsonify_result() @app.errorhandler(Exception) def handle_error(exception): - app.logger.error(exception) + app.logger.error(traceback.format_exc()) code = getattr(exception, 'code', 500) message = getattr(exception, 'description', 'Something went wrong.') reason = '.'.join([ From e5244d00f6ec0d21b01a4bff95cb973cc4ee885a Mon Sep 17 00:00:00 2001 From: mstoro <78480384+mstoro@users.noreply.github.com> Date: Fri, 1 Apr 2022 17:55:23 +0300 Subject: [PATCH 12/13] [CCTRI-3486] remove traceback from logs in case of 404 error (#47) --- code/app.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/code/app.py b/code/app.py index 82b4343..f6b9088 100644 --- a/code/app.py +++ b/code/app.py @@ -24,7 +24,6 @@ def handle_tr_formatted_error(error): @app.errorhandler(Exception) def handle_error(exception): - app.logger.error(traceback.format_exc()) code = getattr(exception, 'code', 500) message = getattr(exception, 'description', 'Something went wrong.') reason = '.'.join([ @@ -32,6 +31,9 @@ def handle_error(exception): exception.__class__.__name__, ]) + if code != 404: + app.logger.error(traceback.format_exc()) + response = jsonify(code=code, message=message, reason=reason) return response, code From 2c8a5185b6accba0f3e679332130f852045e2402 Mon Sep 17 00:00:00 2001 From: mstoro Date: Thu, 7 Apr 2022 12:42:22 +0300 Subject: [PATCH 13/13] Release 2.0.3 --- code/container_settings.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/container_settings.json b/code/container_settings.json index 0bf8530..313d3b5 100644 --- a/code/container_settings.json +++ b/code/container_settings.json @@ -1,4 +1,4 @@ { - "VERSION": "2.0.2", + "VERSION": "2.0.3", "NAME": "Microsoft Graph Security" }