Skip to content
Merged
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
4 changes: 2 additions & 2 deletions src/fosslight_source/_scan_item.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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')

Expand Down
11 changes: 7 additions & 4 deletions src/fosslight_source/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down