Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
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
15 changes: 13 additions & 2 deletions checkov/common/images/image_referencer.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,11 +185,22 @@ async def _fetch_image_results_async(image_names_to_query: list[str]) -> list[di
This is an async implementation of `_fetch_image_results`. The only change is we're getting a session
as an input, and the asyncio behavior is managed in the calling method.
"""
async with aiohttp.ClientSession() as session:
async with aiohttp.ClientSession(trust_env=True) as session:
results: list[dict[str, Any]] = await asyncio.gather(*[
image_scanner.get_scan_results_from_cache_async(session, f"image:{i}")
for i in image_names_to_query
])
logger = logging.getLogger()
logger.setLevel(logging.DEBUG)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @jumiles-pa
Why are we hardcoding the log level to DEBUG?
The log level should be injected from an external configuration.

try:
logging.debug(session)
logging.debug("trust_env " + session.trust_env)
logging.debug("headers " + session.headers)
logging.debug("_default_proxy " + session._default_proxy)
logging.debug("_default_proxy_auth " + session._default_proxy_auth)
except Exception as e:
logging.debug("Extra logging causing more errors")
logging.debug(e)
return results

def _add_image_records(
Expand Down Expand Up @@ -320,7 +331,7 @@ def extract_images(
async def _fetch_licenses_per_image(image_names: list[str], image_results: list[dict[str, Any]]) \
-> dict[str, list[_LicenseStatus]]:
merged_result: dict[str, list[_LicenseStatus]] = {}
async with aiohttp.ClientSession() as session:
async with aiohttp.ClientSession(trust_env=True) as session:
license_results = await asyncio.gather(*[
get_license_statuses_async(session, result['results'][0].get('packages') or [], image_names[i])
for i, result in enumerate(image_results)
Expand Down
2 changes: 1 addition & 1 deletion checkov/common/util/http_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ async def aiohttp_client_session_wrapper(
# adding retry mechanism for avoiding the next repeated unexpected issues:
# 1. Gateway Timeout from the server
# 2. ClientOSError
async with aiohttp.ClientSession(connector=aiohttp.TCPConnector(resolver=aiohttp.AsyncResolver())) as session:
async with aiohttp.ClientSession(connector=aiohttp.TCPConnector(resolver=aiohttp.AsyncResolver()), trust_env=True) as session:
for i in range(request_max_tries):
logging.info(
f"[http_utils](aiohttp_client_session_wrapper) reporting attempt {i + 1} out of {request_max_tries}")
Expand Down
Loading