diff --git a/checkov/common/images/image_referencer.py b/checkov/common/images/image_referencer.py index 92d439f7cb..8248d87d75 100644 --- a/checkov/common/images/image_referencer.py +++ b/checkov/common/images/image_referencer.py @@ -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) + 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( @@ -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) diff --git a/checkov/common/util/http_utils.py b/checkov/common/util/http_utils.py index 40743ea236..7a43c34042 100644 --- a/checkov/common/util/http_utils.py +++ b/checkov/common/util/http_utils.py @@ -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}")