fix: runtime Python import blocking via __import__ hook#30
Merged
Conversation
Override builtins.__import__ in PythonCExecutor to check govern.json
blocked imports list, catching dynamic imports (__import__("o"+"s"),
importlib) that bypass static source scanning. Closes F-3 from R6 audit.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
NAAb Governance Report
All governance checks passed! Generated by NAAb Governance Engine v4.0 |
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
builtins.__import__in PythonCExecutor to enforcegovern.jsonblocked imports at runtime__import__("o"+"s"),importlib.import_module()) that bypass static source scanningChanges
src/runtime/python_c_executor.cpp— inject__import__hook before user code execution, reading blocked list fromGovernanceEngine::getCurrent()->getLanguageConfig("python")->imports.blockedsrc/cli/main.cpp— replaced TODO with documentation comment pointing to new implementationTest plan
cd build && cmake .. && make naab-lang -j4— compiles cleanbash run-all-tests.sh— 396/396, 0 unexpected failures__import__("sub"+"process")blocked whensubprocessin blocked list🤖 Generated with Claude Code