fix(environment): protect the dynamic-tool-loading control variable#526
Draft
yonib05 wants to merge 1 commit into
Draft
fix(environment): protect the dynamic-tool-loading control variable#526yonib05 wants to merge 1 commit into
yonib05 wants to merge 1 commit into
Conversation
Add STRANDS_DISABLE_LOAD_TOOL to the environment tool's PROTECTED_VARS so it cannot be set or deleted through the tool. The set and delete paths both check PROTECTED_VARS, so this covers both operations. Add regression tests confirming that set and delete of STRANDS_DISABLE_LOAD_TOOL are refused.
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.
Description
The
environmenttool can set and delete arbitrary environment variables, but itsPROTECTED_VARSset did not includeSTRANDS_DISABLE_LOAD_TOOL. This variable is the control that operators use to disable dynamic tool loading. Because it was not protected, it could be modified or removed through theenvironmenttool, re-enabling dynamic tool loading after an operator had turned it off.This change adds
STRANDS_DISABLE_LOAD_TOOLtoPROTECTED_VARS. Both thesetanddeletepaths in the tool check membership inPROTECTED_VARSbefore mutating, so a single addition protects both operations.Changes
STRANDS_DISABLE_LOAD_TOOLtoPROTECTED_VARSinsrc/strands_tools/environment.py.setanddeleteofSTRANDS_DISABLE_LOAD_TOOLvia theenvironmenttool are refused and the value is left unchanged.Testing
pytest tests/test_environment.py-> 19 passed (including 2 new tests).ruff format --checkandruff checkpass on the changed files.