Skip to content

Commit

Permalink
Merge pull request #48 from CiscoSecurity/release-2.0.3
Browse files Browse the repository at this point in the history
Release 2.0.3
  • Loading branch information
mstoro authored Apr 7, 2022
2 parents 07c2c88 + 837acc3 commit 82647dd
Show file tree
Hide file tree
Showing 8 changed files with 9 additions and 90 deletions.
12 changes: 1 addition & 11 deletions code/api/enrich.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__)

Expand Down Expand Up @@ -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([])
15 changes: 0 additions & 15 deletions code/api/respond.py

This file was deleted.

11 changes: 7 additions & 4 deletions code/app.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import traceback

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

Expand All @@ -9,28 +11,29 @@

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)


@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)
code = getattr(exception, 'code', 500)
message = getattr(exception, 'description', 'Something went wrong.')
reason = '.'.join([
exception.__class__.__module__,
exception.__class__.__name__,
])

if code != 404:
app.logger.error(traceback.format_exc())

response = jsonify(code=code, message=message, reason=reason)
return response, code

Expand Down
2 changes: 1 addition & 1 deletion code/container_settings.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"VERSION": "2.0.2",
"VERSION": "2.0.3",
"NAME": "Microsoft Graph Security"
}
4 changes: 0 additions & 4 deletions code/tests/functional/tests/test_lambda_relay_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 0 additions & 4 deletions code/tests/unit/test_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
22 changes: 0 additions & 22 deletions code/tests/unit/test_enrich.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'

Expand Down
29 changes: 0 additions & 29 deletions code/tests/unit/test_respond.py

This file was deleted.

0 comments on commit 82647dd

Please sign in to comment.