Skip to content

Commit

Permalink
Fix module not found error for utils (#213)
Browse files Browse the repository at this point in the history
  • Loading branch information
mdazam1942 authored and delliott90 committed Nov 26, 2019
1 parent 90c04fa commit 30ad952
Show file tree
Hide file tree
Showing 8 changed files with 17 additions and 14 deletions.
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
stix2-patterns==1.1.0
stix2-patterns>=1.1.0
stix2-validator>=0.5.0
python-dateutil>=2.7.3
antlr4-python3-runtime==4.7
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@
#
# For an analysis of "install_requires" vs pip's requirements files see:
# https://packaging.python.org/en/latest/requirements.html
install_requires=['stix2-patterns==1.1.0', 'stix2-validator>=0.5.0',
install_requires=['stix2-patterns>=1.1.0', 'stix2-validator>=0.5.0',
'antlr4-python3-runtime==4.7', 'python-dateutil>=2.7.3', 'xmltodict>=0.11.0',
'requests_toolbelt==0.9.1', 'adal>=1.2.2', 'flatten_json==0.1.7'
# ,'stix2-matcher@https://github.com/oasis-open/cti-pattern-matcher/archive/v0.1.0.zip#egg=stix2-matcher' # uncomment when running setup.py locally
Expand Down
Empty file.
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ def obtainAccessToken(self):
raise Exception("Authorizaion Failed")

iamTokenURL = 'https://iam.cloud.ibm.com/identity/token'
requestBody = "grant_type=urn:ibm:params:oauth:grant-type:apikey&apikey="+ self.apiKey +"&response_type=cloud_iam"
requestBody = "grant_type=urn:ibm:params:oauth:grant-type:apikey&apikey={}&response_type=cloud_iam".format(self.apiKey)

header = {
'Content-Type': 'application/x-www-form-urlencoded',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,12 @@
from .security_advisor_status_connector import SecurityAdvisorStatusConnector
from .security_advisor_results_connector import SecurityAdvisorResultsConnector
from .security_advisor_delete_connector import SecurityAdvisorDeleteConnector
from .security_advisor_auth import SecurityAdvisorAuth


class Connector(BaseConnector):
def __init__(self, connection, configuration):
auth = configuration.get("auth")
api_key = auth.get("apiKey")
host = connection.get("host")
auth_token = SecurityAdvisorAuth(api_key)
auth["authToken"] = auth_token

self.query_connector = SecurityAdvisorQueryConnector(host, auth)
self.status_connector = SecurityAdvisorStatusConnector(host, auth)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
from ..base.base_ping import BasePing
import requests
from .....utils.error_response import ErrorResponder
from .security_advisor_auth import SecurityAdvisorAuth


class SecurityAdvisorPing(BasePing):
def __init__(self, host, auth):
self.host = host
self.auth = auth
api_key = auth.get("apiKey")
self.auth_token = SecurityAdvisorAuth(api_key)

def ping(self):
return_obj = {}
Expand All @@ -14,12 +18,12 @@ def ping(self):
'Accept': 'application/json'
}
url = self.host + self.auth["accountID"] + "/providers"
try :
authorization ='Bearer ' + self.auth["authToken"].obtainAccessToken()
try:
authorization = "Bearer {}".format(self.auth_token.obtainAccessToken())
header["Authorization"] = authorization

except Exception as e:
ErrorResponder.fill_error(return_obj, {'code':"Authorizaion Failed"}, message= str(e))
ErrorResponder.fill_error(return_obj, {'code':"Authorizaion Failed"}, message=str(e))
return return_obj

try:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
from ..base.base_results_connector import BaseResultsConnector
from .utils.stix_pattern_processor import StixPatternProcessor
from .....utils.error_response import ErrorResponder
from .security_advisor_auth import SecurityAdvisorAuth


class SecurityAdvisorResultsConnector(BaseResultsConnector):
def __init__(self, host, auth ):
self.host = host
self.auth = auth
api_key = auth.get("apiKey")
self.auth_token = SecurityAdvisorAuth(api_key)
self.StixPatternProcessor = StixPatternProcessor()

def create_results_connection(self, searchID , offset , length):
Expand All @@ -16,15 +19,15 @@ def create_results_connection(self, searchID , offset , length):
params["accountID"] = self.auth.get("accountID")
params["host"] = self.host

try :
params["accessToken"] = self.auth["authToken"].obtainAccessToken()
try:
params["accessToken"] = self.auth_token.obtainAccessToken()

except Exception as e:
ErrorResponder.fill_error(return_obj, {'code':"Authorizaion Failed"}, message= str(e))
return return_obj

try :
data = self.StixPatternProcessor.process(searchID,params)
try:
data = self.StixPatternProcessor.process(searchID, params)
return_obj["success"] = True
return_obj["data"] = data
return return_obj
Expand Down
Empty file.

0 comments on commit 30ad952

Please sign in to comment.