Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added the ability to enable trusted_env. #1727

Merged
merged 3 commits into from
Aug 27, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,10 @@ def __init__(self, host, port=None, headers={}, url_modifier_function=None, cert
unique_file_handle = uuid.uuid4()
self.server_cert_name = "/tmp/{0}-server_cert.pem".format(unique_file_handle)
server_ip = host
self.trust_env_enabled = os.environ.get("STIX_SHIFTER_ENABLE_TRUST_ENV", False)
benjamin-craig marked this conversation as resolved.
Show resolved Hide resolved
self.logger.error(f"Proxy Environment - Trusted_Env Enabled : {self.trust_env_enabled}")
DerekRushton marked this conversation as resolved.
Show resolved Hide resolved
if self.trust_env_enabled:
self.trust_env_enabled = True
if port is not None:
server_ip += ":" + str(port)
self.server_ip = server_ip
Expand Down Expand Up @@ -101,7 +105,7 @@ async def call_api(self, endpoint, method, headers=None, cookies=None, data=None
try:
client_timeout = ClientTimeout(connect=self.connect_timeout, total=timeout) # https://docs.aiohttp.org/en/stable/client_reference.html?highlight=timeout#aiohttp.ClientTimeout
retry_options = ExponentialRetry(attempts=self.retry_max, statuses=[429, 500, 502, 503, 504])
async with RetryClient(retry_options=retry_options) as client:
async with RetryClient(trust_env=self.trust_env_enabled, retry_options=retry_options) as client:
call = getattr(client, method.lower())

async with call(url, headers=actual_headers, params=urldata, data=data,
Expand Down
Loading