Skip to content

fix(ci): scope gunicorn instance .update() scan to namespace aliases - #245

Merged
AlexanderWagnerDev merged 6 commits into
mainfrom
cursor/ci-autofix-automation-fb4b
Sep 17, 2026
Merged

AlexanderWagnerDev merged 6 commits into
mainfrom
cursor/ci-autofix-automation-fb4b

Conversation

@cursor

@cursor cursor Bot commented Sep 17, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes CI test failures on PR #244 caused by overly broad instance .update() detection in the Gunicorn worker AST scanner.

Changes

  • Remove _expression_has_risky_instance_update from import-time statement scanning (restores PR Fix gunicorn workers scan false positives for unrelated .update() calls #197 behavior)
  • Extend namespace alias collection to walrus bindings in if/while tests and match captures on globals()
  • Keep instance .update() heuristics scoped to lambda bodies where receivers cannot be proven static

Context

PR #244 added _expression_has_risky_instance_update to _is_dynamic_workers_mutation, which flagged unrelated local dict updates (e.g. settings.update({'workers': 4})) and safe dict-subclass patterns as dynamic.

Open in Web View Automation 

Note

Medium Risk
Changes security-sensitive static analysis for Gunicorn worker counts; incorrect heuristics could falsely block startup or miss dynamic worker overrides.

Overview
Tightens the Gunicorn workers AST scanner so configs that mutate workers indirectly are marked dynamic (blocking unsafe memory:// rate limits with multiple workers).

Namespace alias collection now includes walrus bindings in if/while tests and bare case ns: captures when matching on globals() (and similar), so patterns like if (ns := globals()): ns.update(...) are tracked.

Class-hook analysis is expanded: metaclass __new__, dataclass-style __post_init__, __init_subclass__ on base classes, and descriptor __get__ access (including fields instantiated from descriptor classes) are treated as import-time or expression-triggered side effects. match guards that mutate workers are also classified as dynamic.

Adds parametrized tests (test_security_review_sep17.py) asserting these bypass shapes return (1, True) from _workers_from_gunicorn_config_path.

Reviewed by Cursor Bugbot for commit c284c26. Bugbot is set up for automated code reviews on this repo. Configure here.

cursoragent and others added 2 commits September 17, 2026 02:06
Detect walrus-if and match-guard namespace updates, __init_subclass__
subclass definitions, dataclass __post_init__ instantiation, metaclass
__new__ hooks, and descriptor __get__ attribute access that mutate
workers at import time without being flagged as dynamic.

Startup with RATELIMIT_STORAGE_URI=memory:// would otherwise allow
multi-worker Gunicorn to bypass per-worker login rate limits and session
stores while the panel believes it runs single-worker.

Co-authored-by: Alexander Wagner <info@alexanderwagnerdev.com>
PR #244 reintroduced false positives by treating every instance
.update({'workers': ...}) as dynamic. Restore PR #197 behavior for
import-time scans and extend namespace-alias collection to walrus
bindings in if/while tests and match captures on globals().

Co-authored-by: Alexander Wagner <info@alexanderwagnerdev.com>
@coderabbitai

coderabbitai Bot commented Sep 17, 2026

Copy link
Copy Markdown

Important

Review skipped

Bot user detected.

To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Advanced

Run ID: 565dcf68-cb74-40f7-8c91-db3a164f317b

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@sonarqubecloud

Copy link
Copy Markdown

@AlexanderWagnerDev
AlexanderWagnerDev marked this pull request as ready for review September 17, 2026 13:04
@cursor

cursor Bot commented Sep 17, 2026

Copy link
Copy Markdown
Contributor Author

Bugbot couldn't run - usage limit reached

Bugbot is counted against Cursor usage for this user or team, and this run hit a usage or spend limit.

A user or team admin can review and increase usage limits in the Cursor dashboard.

(requestId: serverGenReqId_46d6deb6-2edb-4fb3-b3a0-e45043c0304c)

@AlexanderWagnerDev
AlexanderWagnerDev merged commit 39b53da into main Sep 17, 2026
13 checks passed
@AlexanderWagnerDev
AlexanderWagnerDev deleted the cursor/ci-autofix-automation-fb4b branch September 17, 2026 13:09
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