Skip to content

Commit

Permalink
Merge pull request #53 from CiscoSecurity/release-2.0.4
Browse files Browse the repository at this point in the history
Release 2.0.4
  • Loading branch information
mstoro authored Dec 16, 2021
2 parents e69b033 + e2a9e58 commit 9809661
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 8 deletions.
11 changes: 7 additions & 4 deletions code/api/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from ssl import SSLCertVerificationError

import requests
from requests.exceptions import SSLError
from requests.exceptions import SSLError, InvalidHeader

from api.errors import (
SSLCertificateVerificationFailedError,
Expand All @@ -11,6 +11,9 @@
)


AUTHORIZATION_FAILED = "Authorization failed on AlienVault OTX side"


class Client:

def __init__(self, key, url, headers=None, params=None):
Expand Down Expand Up @@ -38,14 +41,14 @@ def query(self, endpoint, headers=None, params=None):
getattr(error, 'verify_message', error.args[0]).capitalize()
)
raise SSLCertificateVerificationFailedError(reason=reason)
except (InvalidHeader, UnicodeEncodeError):
raise AuthenticationRequiredError(reason=AUTHORIZATION_FAILED)

if response.status_code == HTTPStatus.BAD_REQUEST:
return None

if response.status_code == HTTPStatus.FORBIDDEN:
raise AuthenticationRequiredError(
reason="Authorization failed on AlienVault OTX side"
)
raise AuthenticationRequiredError(reason=AUTHORIZATION_FAILED)

if response.status_code == HTTPStatus.NOT_FOUND:
return None
Expand Down
7 changes: 4 additions & 3 deletions code/app.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import traceback

from flask import Flask, jsonify

from api.enrich import enrich_api
from api.health import health_api
from api.version import version_api
from api.watchdog import watchdog_api

from api.errors import RelayError
from api.utils import jsonify_errors

Expand All @@ -21,13 +22,13 @@

@app.errorhandler(RelayError)
def handle_relay_error(error):
app.logger.error(error.json())
app.logger.error(traceback.format_exc())
return jsonify_errors(error)


@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([
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.3",
"VERSION": "2.0.4",
"NAME": "AlienVault OTX"
}

0 comments on commit 9809661

Please sign in to comment.