Skip to content

cleanup(medcat-demo):CU-869c8r073 Remove demo keep model distribution#351

Merged
mart-r merged 39 commits intomainfrom
cleanup/medcat-demo/CU-869c8r073-remove-demo-keep-model-distribution
Feb 27, 2026
Merged

cleanup(medcat-demo):CU-869c8r073 Remove demo keep model distribution#351
mart-r merged 39 commits intomainfrom
cleanup/medcat-demo/CU-869c8r073-remove-demo-keep-model-distribution

Conversation

@mart-r
Copy link
Collaborator

@mart-r mart-r commented Feb 24, 2026

This PR aims to remo the "demo" capabilities from the medcat-demo-webapp (sub)project. It should only keep the model distribution parts of it (i.e downloading openly available models if/when you have permission).

This also means the "demo" doesn't need medcat anymore since it's just about .zip file distribution.

PS:
I think it may be worth renaming the folder as well. Might do that at the end of the PR along with the relevant workflow changes. Now done as part of this PR.

@tomolopolis
Copy link
Member

full_url = f"{url}?api_key={urllib.parse.quote(api_key)}"
keep_api_key = min(len(api_key) - 1, 10)
remove_from_end = len(api_key) - keep_api_key
print(f" GET {full_url[:-remove_from_end]}...")

Check failure

Code scanning / CodeQL

Clear-text logging of sensitive information High test

This expression logs sensitive data (password) as clear text.
This expression logs sensitive data (password) as clear text.

Copilot Autofix

AI 6 days ago

In general, the fix is to avoid logging any representation of the API key (or other secrets) in clear text. For HTTP requests that include secrets in the URL or headers, logs should either omit those parts entirely or replace them with a fixed placeholder like [REDACTED].

For this specific file, the only problematic logging is the print(f" GET {full_url[:-remove_from_end]}...") line. The full_url string contains the API key in the query string. The current approach attempts to hide the tail of the key, but that still leaks part of it. The safest fix that preserves existing functionality is to log a version of the URL with the api_key value fully redacted. We can construct a new string, e.g. safe_url = f"{url}?api_key=[REDACTED]", and log that instead of full_url. This keeps the helpful information that a GET is being performed on a specific endpoint while ensuring no part of the actual key is printed.

Concretely:

  • Edit medcat-demo-app/tests/test_integration.py near line 50.
  • Replace the calculation of keep_api_key, remove_from_end, and the print that uses full_url[:-remove_from_end] with a single creation of a redacted_url (or similar) that hardcodes [REDACTED] as the api_key value, and print that.
  • No new imports, methods, or global definitions are needed; this is a straightforward string change in place.
Suggested changeset 1
medcat-demo-app/tests/test_integration.py

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/medcat-demo-app/tests/test_integration.py b/medcat-demo-app/tests/test_integration.py
--- a/medcat-demo-app/tests/test_integration.py
+++ b/medcat-demo-app/tests/test_integration.py
@@ -45,9 +45,8 @@
 
     # ── 1. Call with key in query string ──────────────────────────────────────
     full_url = f"{url}?api_key={urllib.parse.quote(api_key)}"
-    keep_api_key = min(len(api_key) - 1, 10)
-    remove_from_end = len(api_key) - keep_api_key
-    print(f"  GET {full_url[:-remove_from_end]}...")
+    redacted_url = f"{url}?api_key=[REDACTED]"
+    print(f"  GET {redacted_url}...")
 
     try:
         req = urllib.request.Request(full_url)
EOF
@@ -45,9 +45,8 @@

# ── 1. Call with key in query string ──────────────────────────────────────
full_url = f"{url}?api_key={urllib.parse.quote(api_key)}"
keep_api_key = min(len(api_key) - 1, 10)
remove_from_end = len(api_key) - keep_api_key
print(f" GET {full_url[:-remove_from_end]}...")
redacted_url = f"{url}?api_key=[REDACTED]"
print(f" GET {redacted_url}...")

try:
req = urllib.request.Request(full_url)
Copilot is powered by AI and may make mistakes. Always verify output.
Unable to commit as this autofix suggestion is now outdated
Copy link
Collaborator

Choose a reason for hiding this comment

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

same as above mentioned by Mart

Copy link
Collaborator

@dcstang dcstang left a comment

Choose a reason for hiding this comment

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

lgtm. looks clean

full_url = f"{url}?api_key={urllib.parse.quote(api_key)}"
keep_api_key = min(len(api_key) - 1, 10)
remove_from_end = len(api_key) - keep_api_key
print(f" GET {full_url[:-remove_from_end]}...")
Copy link
Collaborator

Choose a reason for hiding this comment

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

same as above mentioned by Mart

@mart-r mart-r merged commit 9dc139b into main Feb 27, 2026
8 checks passed
@mart-r mart-r deleted the cleanup/medcat-demo/CU-869c8r073-remove-demo-keep-model-distribution branch February 27, 2026 10:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants