What's Changed
Fixed
- Log injection prevention in tag sanitization (CWE-117, ERROR):
memory_service.pytag sanitization now strips CRLF characters (\r,\n) before including user-supplied tag strings in log output. Forged log lines via crafted tag values are no longer possible. Resolves CodeQL alerts #258 and #259 (py/log-injection). HTTPClientStorage.retrieve()missingtagsparameter (WARNING): Theretrieve()method signature instorage/http_client.pydid not include thetagskeyword argument required by theBaseStorageinterface, causing a CodeQL signature-mismatch alert. Parameter added and wired through to the HTTP query. Resolves CodeQL alert #261.- Import-time
print()replaced withwarnings.warn()(NOTE): Three modules (server/utils/response_limiter.py,server/handlers/utility.py, andserver/client_detection.py) executedprint()at module import time. Replaced withwarnings.warn()usingstacklevel=2so callers see the correct source location. Resolves CodeQL alerts #254, #255, #257 (py/print-during-import). - Unnecessary
passstatements removed (WARNING): Twopassstatements that appeared afterreturnorraisestatements (unreachable code) were removed fromconsolidation/consolidator.pyandconsolidation/compression.py. Resolves CodeQL alerts #252 and #253 (py/unnecessary-pass). - Unused global cache variables wired up in
models/ontology.py(NOTE):_TYPE_HIERARCHY_CACHEand_VALIDATED_TYPES_CACHEwere declared as module-level globals but never read. Both caches are now populated on first access and returned on subsequent calls, eliminating the redundant per-call computation they were intended to prevent. Resolves CodeQL alerts #263, #264, #265. - Unused imports removed from consolidation modules (NOTE): Removed five dead
importstatements acrossconsolidation/clustering.py,consolidation/compression.py,consolidation/consolidator.py,consolidation/forgetting.py, andserver_impl.py. No behaviour change. Resolves CodeQL alerts #266, #267, #268, #269, #270 (py/unused-import). Ellipsis(...) replaced withpassinStorageProtocol(NOTE): Four abstract-style method stubs inservices/memory_service.pyusedEllipsisliterals as bodies, which CodeQL flags as ineffectual statements. Replaced withpassfor idiomatic Python. Resolves CodeQL alerts #248, #249, #250, #251 (py/ineffectual-statement).
Added
tests/services/test_memory_service_log_injection.py: 5 new tests verifying that CRLF characters in tag values are sanitised before reaching log output (covers empty tags, single tag, multiple tags, embedded CRLF, and standalone CR/LF).tests/storage/test_http_client_signature.py: 2 new tests confirmingHTTPClientStorage.retrieve()accepts atagskeyword argument matching theBaseStorageinterface.
CodeQL Alert Summary
| Severity | Count | Categories |
|---|---|---|
| ERROR | 2 | py/log-injection (CWE-117)
|
| WARNING | 3 | py/unnecessary-pass, py/signature-mismatch
|
| NOTE | 16 | py/unused-import, py/unused-global-variable, py/empty-except, py/print-during-import, py/ineffectual-statement
|
| Total | 21 |
Full Changelog: https://github.com/doobidoo/mcp-memory-service/blob/main/CHANGELOG.md