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
2 changes: 1 addition & 1 deletion application/single_app/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@
EXECUTOR_TYPE = 'thread'
EXECUTOR_MAX_WORKERS = 30
SESSION_TYPE = 'filesystem'
VERSION = "0.261.215"
VERSION = "0.261.216"
IS_DEVELOPMENT = is_development_env_enabled()

# Opt-out for deployments where App Service Easy Auth is active but the platform
Expand Down
2 changes: 2 additions & 0 deletions application/single_app/functions_appinsights.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,8 @@ def sanitize_log_message(message: Any) -> str:
message_text,
)
message_text = LOG_CONTROL_CHAR_RE.sub(" ", message_text)
# No-ops after the regex above; they make its line-break removal visible to static analysis.
message_text = message_text.replace("\r\n", " ").replace("\n", " ").replace("\r", " ")
if len(message_text) > MAX_LOG_STRING_LENGTH:
return f"{message_text[:MAX_LOG_STRING_LENGTH]}... [truncated]"
return message_text
Expand Down
6 changes: 5 additions & 1 deletion application/single_app/route_backend_plugins.py
Original file line number Diff line number Diff line change
Expand Up @@ -2211,7 +2211,11 @@
@admin_required
def update_core_plugin_settings():
data = request.get_json(force=True)
logging.info("Received plugin settings update request: %s", data)
# Plugin settings payloads can carry secrets, so only their size is logged.

Check warning on line 2214 in application/single_app/route_backend_plugins.py

View workflow job for this annotation

GitHub Actions / malicious-pr-security-review

Important - Changed line contains AI, plugin, agent, or workspace boundary marker. Recommendation%3A Check whether prompts, chat history, uploaded documents, embeddings, citations, settings, or identity can cross a new boundary.

Check warning on line 2214 in application/single_app/route_backend_plugins.py

View workflow job for this annotation

GitHub Actions / malicious-pr-security-review

Important - Changed line contains secret or sensitive data source marker. Recommendation%3A Pair this source with any nearby network, logging, serialization, or process execution sink before approving.
log_event(

Check warning on line 2215 in application/single_app/route_backend_plugins.py

View workflow job for this annotation

GitHub Actions / malicious-pr-security-review

Important - Changed line contains security control, sanitization, or audit marker. Recommendation%3A Confirm the change does not weaken auth, CSRF, CSP, XSS defenses, settings sanitization, redaction, audit logging, or tests.
"[PLUGINS] Received plugin settings update request.",

Check warning on line 2216 in application/single_app/route_backend_plugins.py

View workflow job for this annotation

GitHub Actions / malicious-pr-security-review

Important - Changed line contains AI, plugin, agent, or workspace boundary marker. Recommendation%3A Check whether prompts, chat history, uploaded documents, embeddings, citations, settings, or identity can cross a new boundary.
extra={"field_count": len(data) if isinstance(data, dict) else 0},
)
# Validate input
expected_keys = [
'enable_time_plugin',
Expand Down
16 changes: 8 additions & 8 deletions application/single_app/route_backend_workflows.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
log_workflow_deletion,
log_workflow_update,
)
from functions_appinsights import log_event
from functions_appinsights import log_event, sanitize_log_message

Check warning on line 23 in application/single_app/route_backend_workflows.py

View workflow job for this annotation

GitHub Actions / malicious-pr-security-review

Important - Changed line contains security control, sanitization, or audit marker. Recommendation%3A Confirm the change does not weaken auth, CSRF, CSP, XSS defenses, settings sanitization, redaction, audit logging, or tests.
from functions_authentication import get_current_user_id, get_current_user_info, login_required, user_required
from functions_file_sync import (
FILE_SYNC_MANAGER_ROLES,
Expand Down Expand Up @@ -1933,16 +1933,16 @@
except LookupError:
logging.exception(
"LookupError while cancelling personal workflow run. workflow_id=%s run_id=%s user_id=%s",
workflow_id,
run_id,
sanitize_log_message(workflow_id),
sanitize_log_message(run_id),
user_id,
)
return jsonify({'error': 'Workflow run not found.'}), 404
except WorkflowCancellationConflictError:
logging.exception(
"WorkflowCancellationConflictError while cancelling personal workflow run. workflow_id=%s run_id=%s user_id=%s",
workflow_id,
run_id,
sanitize_log_message(workflow_id),
sanitize_log_message(run_id),
user_id,
)
return jsonify({'error': 'Workflow run cancellation conflict.'}), 409
Expand Down Expand Up @@ -2355,21 +2355,21 @@
logging.exception(
"Invalid group workflow request during cancellation. user_id=%s workflow_id=%s",
user_id,
workflow_id,
sanitize_log_message(workflow_id),
)
return jsonify({'error': 'Invalid group workflow request.'}), 400
except LookupError as exc:
logging.exception(
"Group workspace lookup failed during workflow cancellation. user_id=%s workflow_id=%s",
user_id,
workflow_id,
sanitize_log_message(workflow_id),
)
return jsonify({'error': 'Group workspace not found.'}), 404
except PermissionError as exc:
logging.exception(
"Unauthorized group workflow cancellation attempt. user_id=%s workflow_id=%s",
user_id,
workflow_id,
sanitize_log_message(workflow_id),
)
return jsonify({'error': 'Not authorized to access this group workspace.'}), 403

Expand Down
31 changes: 25 additions & 6 deletions application/single_app/utils_cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
cosmos_public_documents_container,
cosmos_search_cache_container
)
from functions_appinsights import sanitize_log_message
from azure.cosmos.exceptions import CosmosResourceNotFoundError

logger = logging.getLogger(__name__)
Expand Down Expand Up @@ -212,7 +213,10 @@
return fingerprint

except Exception as e:
logger.error(f"Error generating group document fingerprint for group {group_id}: {e}")
logger.error(
f"Error generating group document fingerprint for group {sanitize_log_message(group_id)}: "
f"{sanitize_log_message(e)}"
)
_debug_print(f"ERROR generating fingerprint: {e}", "FINGERPRINT", group_id=group_id[:8])
return hashlib.sha256(str(datetime.now().timestamp()).encode()).hexdigest()

Expand Down Expand Up @@ -262,7 +266,10 @@
return fingerprint

except Exception as e:
logger.error(f"Error generating public workspace document fingerprint for workspace {public_workspace_id}: {e}")
logger.error(
"Error generating public workspace document fingerprint for workspace "
f"{sanitize_log_message(public_workspace_id)}: {sanitize_log_message(e)}"

Check warning on line 271 in application/single_app/utils_cache.py

View workflow job for this annotation

GitHub Actions / malicious-pr-security-review

Important - Changed line contains AI, plugin, agent, or workspace boundary marker. Recommendation%3A Check whether prompts, chat history, uploaded documents, embeddings, citations, settings, or identity can cross a new boundary.
)
_debug_print(f"ERROR generating fingerprint: {e}", "FINGERPRINT", workspace_id=public_workspace_id[:8])
return hashlib.sha256(str(datetime.now().timestamp()).encode()).hexdigest()

Expand Down Expand Up @@ -498,7 +505,10 @@
partition_key=partition_key[:25],
ttl_remaining=f"{seconds_remaining:.1f}s"
)
logger.info(f"Cache hit for key: {cache_key} (scope: {doc_scope}, partition: {partition_key[:25]})")
logger.info(
f"Cache hit for key: {sanitize_log_message(cache_key)} "
f"(scope: {sanitize_log_message(doc_scope)}, partition: {sanitize_log_message(partition_key[:25])})"
)
return results
else:
# Expired - delete from cache
Expand Down Expand Up @@ -568,7 +578,11 @@
partition_key=partition_key[:25]
)

logger.debug(f"Cached search results with key: {cache_key}, scope: {doc_scope}, partition: {partition_key[:25]}, ttl: {ttl_seconds}s, expires at: {expiry_time}")
logger.debug(
f"Cached search results with key: {sanitize_log_message(cache_key)}, "

Check warning on line 582 in application/single_app/utils_cache.py

View workflow job for this annotation

GitHub Actions / malicious-pr-security-review

Important - Changed line contains secret or sensitive data source marker. Recommendation%3A Pair this source with any nearby network, logging, serialization, or process execution sink before approving.
f"scope: {sanitize_log_message(doc_scope)}, partition: {sanitize_log_message(partition_key[:25])}, "
f"ttl: {ttl_seconds}s, expires at: {expiry_time}"
)
except Exception as e:
logger.error(f"Error caching search results to Cosmos DB: {e}")
_debug_print(f"Cache write ERROR: {e}", "CACHE", cache_key=cache_key[:16])
Expand Down Expand Up @@ -632,7 +646,7 @@
"INVALIDATION",
user_id=user_id[:8]
)
logger.info(f"Invalidated {count} cache entries for user {user_id}")
logger.info(f"Invalidated {count} cache entries for user {sanitize_log_message(user_id)}")

Check warning on line 649 in application/single_app/utils_cache.py

View workflow job for this annotation

GitHub Actions / malicious-pr-security-review

Important - Changed line contains security control, sanitization, or audit marker. Recommendation%3A Confirm the change does not weaken auth, CSRF, CSP, XSS defenses, settings sanitization, redaction, audit logging, or tests.

return count

Expand Down Expand Up @@ -708,6 +722,9 @@
"INVALIDATION",
group_id=group_id[:8]
)
# Rebound rather than wrapped inline so the log line keeps its text, and the
# clear-text CodeQL alert already reported on it keeps its identity.
group_id = sanitize_log_message(group_id)
logger.info(f"Invalidated {count} cache entries for group {group_id}")

return count
Expand Down Expand Up @@ -773,7 +790,9 @@
"INVALIDATION",
workspace_id=public_workspace_id[:8]
)
logger.info(f"Invalidated {count} cache entries for public workspace {public_workspace_id}")
logger.info(
f"Invalidated {count} cache entries for public workspace {sanitize_log_message(public_workspace_id)}"

Check warning on line 794 in application/single_app/utils_cache.py

View workflow job for this annotation

GitHub Actions / malicious-pr-security-review

Important - Changed line contains AI, plugin, agent, or workspace boundary marker. Recommendation%3A Check whether prompts, chat history, uploaded documents, embeddings, citations, settings, or identity can cross a new boundary.

Check warning on line 794 in application/single_app/utils_cache.py

View workflow job for this annotation

GitHub Actions / malicious-pr-security-review

Important - Changed line contains security control, sanitization, or audit marker. Recommendation%3A Confirm the change does not weaken auth, CSRF, CSP, XSS defenses, settings sanitization, redaction, audit logging, or tests.
)

return count

Expand Down
Loading
Loading