fix(security): freeze CMCP_DEV_MODE at process startup (TEE-002) - #256
Merged
Merged
Conversation
…testation upgrade (AUTH-001) Closes #163. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
… at runtime (TEE-002) Add module-level DEV_MODE constant in cmcp_gateway.config that reads CMCP_DEV_MODE exactly once at import time. Replace the runtime os.environ.get call in load_config() with this constant. Add tests asserting the constant is immutable after import. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
DEV_MODE: boolmodule-level constant tocmcp_gateway/config.pythat readsCMCP_DEV_MODEexactly once at import timeos.environ.get("CMCP_DEV_MODE")call inload_config()with the frozen constant — no code path re-reads the env var after startuptests/unit/test_tee_dev_mode_freeze.pywith 6 tests: constant isTrue/False/Falsefor env1/absent/0, and two immutability tests proving that mutatingos.environafter import cannot changeDEV_MODEcomplete_setupfixture intest_startup.pyto patch the frozen constant directly (monkeypatch.setattr) rather than only setting the env varTest plan
pytest tests/unit/test_tee_dev_mode_freeze.py— 6/6 passpytest tests/unit/test_startup.py tests/unit/test_tee.py— all passos.environ.get("CMCP_DEV_MODE")calls outside the one freeze lineCloses #141
🤖 Generated with Claude Code