Skip to content

Commit

Permalink
Add proxy support for API requests. Closes #14.
Browse files Browse the repository at this point in the history
  • Loading branch information
jshcodes committed Apr 20, 2023
1 parent 12024fc commit e4f82ad
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 4 deletions.
3 changes: 2 additions & 1 deletion cs_misp_import/importer.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,8 @@ def __init__(self, intel_api_client, import_settings, provided_arguments, settin
max_threads=import_settings["max_threads"],
logger=logger,
cs_org_id=import_settings["crowdstrike_org_uuid"],
http_headers=import_settings["ext_headers"]
http_headers=import_settings["ext_headers"],
proxies=import_settings["proxy"]
)
self.config = provided_arguments
self.settings = settings
Expand Down
4 changes: 3 additions & 1 deletion cs_misp_import/intel_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ def __init__(self,
crowdstrike_url,
api_request_max,
ext_headers,
proxies,
use_ssl: bool = True,
logger: logging.Logger = None
):
Expand All @@ -45,7 +46,8 @@ def __init__(self,
base_url=crowdstrike_url,
ssl_verify=use_ssl,
user_agent=ua,
ext_headers=ext_headers
ext_headers=ext_headers,
proxy=proxies
)
self.valid_report_types = [x.name.lower() for x in ReportType]
self.request_size_limit = api_request_max
Expand Down
4 changes: 4 additions & 0 deletions misp_import.ini
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,10 @@ taxonomic_IEP2_VERSION = False
taxonomic_TLP = True
taxonomic_WORKFLOW = True

[PROXY]
; http = http://my.http.proxy:8080
; https = https://my.https.proxy

[EXTRA_HEADERS]
; Headers will be provided as strings regardless of datatype
; ExampleHeader1 = StringExample
Expand Down
14 changes: 12 additions & 2 deletions misp_import.py
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,15 @@ def main():
# Not specified, default to enable warnings
pass

# Configure the proxy if specified
proxies = {}
if "PROXY" in settings:
# Only the two proxies (http / https) are allowed
if "http" in settings["PROXY"]:
proxies["http"] = settings["PROXY"]["http"]
if "https" in settings["PROXY"]:
proxies["https"] = settings["PROXY"]["https"]

# Set any extra headers to pass to the APIs
extra_headers = {}
if "EXTRA_HEADERS" in settings:
Expand All @@ -299,13 +308,13 @@ def main():

extra_headers[header_item] = set_val


# Interface to the CrowdStrike Falcon Intel API
intel_api_client = IntelAPIClient(settings["CrowdStrike"]["client_id"],
settings["CrowdStrike"]["client_secret"],
settings["CrowdStrike"]["crowdstrike_url"],
int(settings["CrowdStrike"]["api_request_max"]),
extra_headers,
proxies,
False if "F" in settings["CrowdStrike"]["api_enable_ssl"].upper() else True,
main_log
)
Expand All @@ -331,7 +340,8 @@ def main():
"type": args.type,
"publish": args.publish,
"verbose_tags": args.verbose,
"ext_headers": extra_headers
"ext_headers": extra_headers,
"proxy": proxies
}

if not import_settings["unknown_mapping"]:
Expand Down

0 comments on commit e4f82ad

Please sign in to comment.