Add configurable Python module lists via config directives - #122
Merged
ldayton merged 1 commit intoJun 8, 2026
Merged
Conversation
Add python-allow-module and python-deny-module config directives so users can customize which Python modules are considered safe or dangerous during static analysis. - Config: parse and validate module names (dotted identifiers only), accumulate across config layers, support inline comments - SafetyAnalyzer: parameterize with extra_safe_modules/extra_deny_modules merged with hardcoded sets. Allow overrides exact matches in the dangerous list (submodules must be allowed separately). - Thread Config through HandlerContext so python handler can access configured module lists. Example .dippy config: python-allow-module numpy python-allow-module pandas python-deny-module requests
nickdavies
force-pushed
the
claude/python-configurable-modules-GCu5f
branch
from
April 1, 2026 00:36
7910583 to
42ddb64
Compare
Closed
nickdavies
marked this pull request as ready for review
April 1, 2026 00:42
ldayton
approved these changes
Jun 8, 2026
ldayton
left a comment
Owner
There was a problem hiding this comment.
Thanks for this — and sorry for the long wait on review.
This is a clean, self-contained change. A few things I checked that made me comfortable merging it on its own:
- When no
python-allow-module/python-deny-moduleis configured, behavior is byte-identical to before (empty sets), so there's no change for users who don't opt in. allowoverriding the hardcoded dangerous list via exact-match set subtraction is correct — submodules likehttp.serverstay denied because they're separate entries, so allowinghttpdoesn't leak them (your test covers this).- It's an opt-in user override, which fits the security model the same way
allow …/set default allowalready do. - Merges cleanly onto current
mainand the full suite passes.
Merging. The -c analysis and secrets work (#134/#135) I'll follow up on separately.
ldayton
added a commit
that referenced
this pull request
Jun 8, 2026
python -c was always ask. Now the inline body is run through the same AST safety analyzer used for script files: expansion-free code that passes analysis is auto-approved, dangerous imports/builtins ask, and any bash expansion ($VAR, $(...)) in the -c argument falls back to ask because bash rewrites the code at runtime. Based on @nickdavies's #134 (rebased onto main after its base #122 landed), plus a fix for a token-alignment bug: the per-token expansion flags were indexed against the full word list while the handler sees env-stripped tokens, so a leading FOO=bar shifted the flags and wrapper recursion dropped them. The flags are now re-sliced in lockstep with tokens at both points. Closes #134. Co-authored-by: Nick Davies <github@nicolasdavies.com.au>
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.
I wanted to be able to configure Python modules in preparation for enabling -c analysis. I'm not super familiar with the codebase so please let me know what you think of the approach. Happy to adjust to match any style etc.
Add python-allow-module and python-deny-module config directives so users can customize which Python modules are considered safe or dangerous during static analysis.
Example .dippy config:
python-allow-module numpy python-allow-module pandas python-deny-module requests