Skip to content

feat(python): add dataflow for default parameter values#1876

Merged
cfabianski merged 3 commits intoBearer:mainfrom
ronens88:feat/python-default-param-dataflow
Dec 16, 2025
Merged

feat(python): add dataflow for default parameter values#1876
cfabianski merged 3 commits intoBearer:mainfrom
ronens88:feat/python-default-param-dataflow

Conversation

@ronens88
Copy link
Copy Markdown
Contributor

  • analyzer.go: Create alias from parameter name to default value, enabling string resolution through function parameters
  • filters.go: Return matched content from regex filter instead of empty string, allowing variable references to be captured

Enables tracing values through Python function default parameters.

Description

This PR adds dataflow tracking for Python function parameters with default values.

Problem: Previously, when a function parameter with a default value was used inside the function body, Bearer couldn't trace it back to the default value string.

Solution:

  1. In analyzer.go, create an alias from the parameter name to its default value during parameter analysis
  2. In filters.go, return the matched node content from the regex filter instead of an empty string

Example - Before:
def connect(host: str = "localhost"):
return open_connection(host=host) # host couldn't be resolvedExample - After:
def connect(host: str = "localhost"):
return open_connection(host=host) # host now resolves to "localhost"This enables rules to detect string values passed through function parameters when they originate from default values.

Checklist

If this is your first time contributing please sign the CLA

  • I've added test coverage that shows my fix or feature works as expected.
  • I've updated or added documentation if required.

- analyzer.go: Create alias from parameter name to default value,
  enabling string resolution through function parameters
- filters.go: Return matched content from regex filter instead of
  empty string, allowing variable references to be captured

Enables tracing values through Python function default parameters.
@cfabianski cfabianski merged commit 966a6f5 into Bearer:main Dec 16, 2025
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants