diff --git a/src/fosslight_source/_scan_item.py b/src/fosslight_source/_scan_item.py index 0d2191d..4a94ba1 100644 --- a/src/fosslight_source/_scan_item.py +++ b/src/fosslight_source/_scan_item.py @@ -23,7 +23,7 @@ MAX_LICENSE_LENGTH = 200 MAX_LICENSE_TOTAL_LENGTH = 600 SUBSTRING_LICENSE_COMMENT = "Maximum character limit (License)" -KB_URL = "http://fosslight-kb.lge.com/query" +KB_URL = "http://fosslight-kb.lge.com/" class SourceItem(FileItem): @@ -108,7 +108,7 @@ def _get_origin_url_from_md5_hash(self, md5_hash: str, wfp: str = "") -> str: payload = {"file_hash": md5_hash} if wfp and wfp.strip(): payload["wfp_base64"] = base64.b64encode(wfp.strip().encode("utf-8")).decode("ascii") - request = urllib.request.Request(KB_URL, data=json.dumps(payload).encode('utf-8'), method='POST') + request = urllib.request.Request(f"{KB_URL}query", data=json.dumps(payload).encode('utf-8'), method='POST') request.add_header('Accept', 'application/json') request.add_header('Content-Type', 'application/json') diff --git a/src/fosslight_source/cli.py b/src/fosslight_source/cli.py index 6417d40..408430b 100755 --- a/src/fosslight_source/cli.py +++ b/src/fosslight_source/cli.py @@ -263,15 +263,18 @@ def create_report_file( def check_kb_server_reachable() -> bool: try: - request = urllib.request.Request(KB_URL, method='HEAD') - with urllib.request.urlopen(request, timeout=5) as response: + request = urllib.request.Request(f"{KB_URL}health", method='GET') + with urllib.request.urlopen(request, timeout=10) as response: logger.debug(f"KB server is reachable. Response status: {response.status}") return response.status != 404 except urllib.error.HTTPError as e: + logger.debug(f"KB server returned HTTP error: {e.code}") return e.code != 404 - except urllib.error.URLError: + except urllib.error.URLError as e: + logger.debug(f"KB server is unreachable (timeout or connection error): {e}") return False - except Exception: + except Exception as e: + logger.debug(f"Unexpected error checking KB server: {e}") return False