Skip to content

Fix GHSA-873f-pvrv-4x83: warn before executing a bundle's config in load()/run() - #9057

Merged
ericspod merged 17 commits into
Project-MONAI:devfrom
garciadias:fix/ghsa-873f-pvrv-4x83
Aug 17, 2026
Merged

ericspod merged 17 commits into
Project-MONAI:devfrom
garciadias:fix/ghsa-873f-pvrv-4x83

Conversation

@garciadias

Copy link
Copy Markdown
Collaborator

Summary

Fixes GHSA-873f-pvrv-4x83: GHSA-873f-pvrv-4x83

monai.bundle.load(), with its default model=None, builds a bundle's network by parsing the bundle's own config through create_workflow(). That parsing resolves any "_target_" value to an importable callable with no allow list, and passes any "$"-prefixed value to Python eval(). monai.bundle.run() reaches the same code path via a caller-supplied config_file. Either way, this means loading or running a bundle whose config you haven't reviewed can execute arbitrary code.

Design

An earlier version of this fix added an opt-in trust_remote_code flag to load(). Per review discussion, that was dropped: MONAI has no mechanism to actually establish whether a bundle is trustworthy (unlike, say, a per-repo "has custom code" check), so a flag like that mostly teaches people to set it once and forget about it, without giving them a real basis to decide.

Instead:

  • create_workflow() — the shared path both load() and run() use to parse a config file — now raises a UserWarning immediately before doing so, spelling out exactly what "_target_"/"$"-expression content can do and linking this advisory.
  • No behavior is blocked. Default behavior is unchanged other than the added warning: load()/run() still parse and execute the config exactly as before.
  • The warning applies uniformly to every caller of create_workflow(), not just load().

Changes

  • monai/bundle/scripts.py: warning added in create_workflow(); docstrings on load(), run(), and create_workflow() updated to describe the risk and point at the advisory.
  • tests/bundle/test_bundle_download.py: TestLoadWarnsOnConfigExecution — default load() warns and still executes the config (no flag needed), explicit model= still skips config parsing entirely (and warns about nothing), and run() warns via the same create_workflow() path.

Test plan

  • python3 -m unittest tests.bundle.test_bundle_download.TestLoadWarnsOnConfigExecution -v
  • Full tests/bundle/test_bundle_download.py, tests/bundle/test_config_parser.py — no new failures vs. dev (remaining failures are pre-existing environment gaps: missing requests/nibabel, one pdb/bdb quirk)

🤖 Generated with Claude Code

@coderabbitai

coderabbitai Bot commented Aug 11, 2026 •

Copy link
Copy Markdown
Contributor

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

The bundle APIs document that configuration parsing can resolve importable callables and evaluate $ expressions with Python eval(). create_workflow() emits a UserWarning when it receives a configuration file. Tests cover warning emission, expression execution, explicit-model behavior, and run() processing.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Merge Risk: ⚪ Minimal · up to 978a5

The PR adds a warning before bundle configuration execution while preserving existing execution behavior; no actionable merge-blocking risk remains, with only localized test-hardening follow-up around warning ordering and Windows-safe payload construction.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly identifies the security fix and the affected load() and run() behavior.
Description check ✅ Passed The description explains the vulnerability, design, code changes, and test results, but omits the repository template checklist.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (1)
tests/bundle/test_bundle_download.py (1)

509-550: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Add docstrings for the new methods.

Document _stage_malicious_bundle with its arguments and return value. Document each new test method with its asserted behavior.

As per path instructions, “Docstrings should be present for all definition which describe each variable, return value, and raised exception in the appropriate section of the Google-style of docstrings.”

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@tests/bundle/test_bundle_download.py` around lines 509 - 550, Add
Google-style docstrings to _stage_malicious_bundle describing tempdir, marker,
and the returned bundle name, and to test_default_warns_and_executes_config,
test_explicit_model_skips_config_parsing, and test_run_warns_on_config_execution
describing each test’s asserted behavior. Include raised-exception details where
applicable.

Source: Path instructions

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@tests/bundle/test_bundle_download.py`:
- Around line 532-538: Update test_explicit_model_skips_config_parsing to import
warnings and wrap the load() call in warnings.catch_warnings() with UserWarning
configured as an error, ensuring the explicit-model path remains warning-free
while preserving the existing marker assertion.

---

Nitpick comments:
In `@tests/bundle/test_bundle_download.py`:
- Around line 509-550: Add Google-style docstrings to _stage_malicious_bundle
describing tempdir, marker, and the returned bundle name, and to
test_default_warns_and_executes_config,
test_explicit_model_skips_config_parsing, and test_run_warns_on_config_execution
describing each test’s asserted behavior. Include raised-exception details where
applicable.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: c43268e0-5488-4668-b5b2-04b26161a216

📥 Commits

Reviewing files that changed from the base of the PR and between 87060c4 and 35587e0.

📒 Files selected for processing (2)
  • monai/bundle/scripts.py
  • tests/bundle/test_bundle_download.py

Comment thread tests/bundle/test_bundle_download.py Resolved
@garciadias
garciadias force-pushed the fix/ghsa-873f-pvrv-4x83 branch 2 times, most recently from 4b1138e to 95c1dce Compare August 11, 2026 09:46

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (2)
tests/bundle/test_bundle_download.py (2)

509-518: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Add Google-style docstrings to the new definitions.

_stage_malicious_bundle() and the three test methods have no method docstrings. Document tempdir, marker, the returned bundle name, and each test's behavior.

As per path instructions, definitions in **/*.py should have Google-style docstrings that describe variables, return values, and raised exceptions.

Also applies to: 520-530, 532-538, 540-551

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@tests/bundle/test_bundle_download.py` around lines 509 - 518, Add
Google-style docstrings to _stage_malicious_bundle and the three newly added
test methods. Document tempdir and marker in Args, state that the helper returns
the staged bundle name, and describe each test’s behavior; include Returns or
Raises sections where applicable without changing test logic.

Source: Path instructions


524-529: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick win

Assert the warning message, not only its type.

assertWarns(UserWarning) can pass for an unrelated warning. Capture the warning and assert stable text for executable configuration and GHSA-873f-pvrv-4x83 in both paths.

Proposed fix
-            with self.assertWarns(UserWarning):
+            with self.assertWarns(UserWarning) as warning:
                 with self.assertRaises(AttributeError):
                     load(...)
+            self.assertIn("GHSA-873f-pvrv-4x83", str(warning.warning))

Also applies to: 546-550

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@tests/bundle/test_bundle_download.py` around lines 524 - 529, Update both
warning assertions around the malicious bundle load calls to capture the emitted
warning object, rather than checking only UserWarning. Assert that each warning
message contains stable references to executable configuration and
GHSA-873f-pvrv-4x83, while preserving the existing exception assertions and load
calls.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@tests/bundle/test_bundle_download.py`:
- Around line 515-517: Update the malicious payload construction in the bundle
download tests at both occurrences to avoid shell parsing: embed the marker path
using a representation-safe escaping method and invoke a direct Python
file-write operation instead of os.system. Preserve the test’s expected marker
content while ensuring paths with spaces, shell characters, or Windows
backslashes remain valid.

---

Nitpick comments:
In `@tests/bundle/test_bundle_download.py`:
- Around line 509-518: Add Google-style docstrings to _stage_malicious_bundle
and the three newly added test methods. Document tempdir and marker in Args,
state that the helper returns the staged bundle name, and describe each test’s
behavior; include Returns or Raises sections where applicable without changing
test logic.
- Around line 524-529: Update both warning assertions around the malicious
bundle load calls to capture the emitted warning object, rather than checking
only UserWarning. Assert that each warning message contains stable references to
executable configuration and GHSA-873f-pvrv-4x83, while preserving the existing
exception assertions and load calls.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: d296833d-0f0d-4e6e-a75b-4bd86a405b76

📥 Commits

Reviewing files that changed from the base of the PR and between 35587e0 and 4b1138e.

📒 Files selected for processing (1)
  • tests/bundle/test_bundle_download.py

Comment thread tests/bundle/test_bundle_download.py Resolved
monai.bundle.load(), with its default model=None, builds a bundle's
network by parsing the bundle's own config through create_workflow().
That parsing resolves any "_target_" value to an importable callable
with no allow list, and passes any "$"-prefixed value to Python
eval(). monai.bundle.run() reaches the same path via a caller-supplied
config_file. Either way, loading or running a bundle whose config
hasn't been reviewed can execute arbitrary code.

create_workflow() -- the shared path both load() and run() use to
parse a config file -- now raises a UserWarning immediately before
doing so, describing what "_target_"/"$"-expression content can do
and linking the advisory. This applies uniformly to every caller of
create_workflow(), not just load(). No behavior is blocked: the config
is still parsed and executed exactly as before, just with a warning
first. An earlier version of this fix added an opt-in
trust_remote_code flag to load(), but that was dropped after review:
MONAI has no way to establish whether a bundle is actually
trustworthy, so a flag like that would only teach callers to set it
once and forget about it.

Update docstrings on load(), run(), and create_workflow() to describe
the risk and point at the advisory.

Add TestLoadWarnsOnConfigExecution to tests/bundle/test_bundle_download.py:
default load() warns and still executes the config, explicit model=
skips config parsing entirely and warns about nothing, and run() warns
via the same create_workflow() path.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Signed-off-by: R. Garcia-Dias <rafaelagd@gmail.com>
@garciadias
garciadias force-pushed the fix/ghsa-873f-pvrv-4x83 branch from 95c1dce to 6b5fa64 Compare August 11, 2026 10:25

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (1)
tests/bundle/test_bundle_download.py (1)

499-512: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Add Google-style docstrings to the new methods.

Document _stage_malicious_bundle() parameters and return value. Add concise docstrings to each test method.

  • tests/bundle/test_bundle_download.py#L499-L512: document tempdir, marker, and the returned bundle name.
  • tests/bundle/test_bundle_download.py#L514-L524: document the default load() warning and execution test.
  • tests/bundle/test_bundle_download.py#L526-L532: document the explicit-model parsing bypass test.
  • tests/bundle/test_bundle_download.py#L534-L546: document the run() warning and execution test.

As per path instructions, “Docstrings should be present for all definition which describe each variable, return value, and raised exception in the appropriate section of the Google-style of docstrings.”

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@tests/bundle/test_bundle_download.py` around lines 499 - 512, Add concise
Google-style docstrings to _stage_malicious_bundle and each affected test method
in tests/bundle/test_bundle_download.py:499-512, 514-524, 526-532, and 534-546.
Document tempdir, marker, and the returned bundle name with Args and Returns
sections; document each test’s covered behavior, including the default load()
warning/execution, explicit-model parsing bypass, and run() warning/execution,
adding Raises only if applicable.

Source: Path instructions

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@tests/bundle/test_bundle_download.py`:
- Around line 518-523: Update both warning assertions in
tests/bundle/test_bundle_download.py at lines 518-523 and 541-545 to use
assertWarnsRegex(UserWarning, r"GHSA-873f-pvrv-4x83") instead of
assertWarns(UserWarning), while preserving the existing exception assertions and
test flow.

---

Nitpick comments:
In `@tests/bundle/test_bundle_download.py`:
- Around line 499-512: Add concise Google-style docstrings to
_stage_malicious_bundle and each affected test method in
tests/bundle/test_bundle_download.py:499-512, 514-524, 526-532, and 534-546.
Document tempdir, marker, and the returned bundle name with Args and Returns
sections; document each test’s covered behavior, including the default load()
warning/execution, explicit-model parsing bypass, and run() warning/execution,
adding Raises only if applicable.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 4df8d078-b465-4202-a7a2-86a016fb3a2c

📥 Commits

Reviewing files that changed from the base of the PR and between 4b1138e and 6b5fa64.

📒 Files selected for processing (2)
  • monai/bundle/scripts.py
  • tests/bundle/test_bundle_download.py
🚧 Files skipped from review as they are similar to previous changes (1)
  • monai/bundle/scripts.py

Comment thread tests/bundle/test_bundle_download.py Resolved
ericspod
ericspod previously approved these changes Aug 11, 2026

@ericspod ericspod left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me, the Coderabbit comments look worthwhile however. I can rereview if you want to address

garciadias added a commit to garciadias/MONAI that referenced this pull request Aug 11, 2026
- tests/bundle/test_bundle_download.py: assert the advisory-specific
  warning message (GHSA-873f-pvrv-4x83) instead of any UserWarning in
  test_default_warns_and_executes_config and
  test_run_warns_on_config_execution
- tests/bundle/test_bundle_download.py: fail
  test_explicit_model_skips_config_parsing if load() emits a
  UserWarning, enforcing that the explicit-model path never parses
  the bundle config
- tests/bundle/test_bundle_download.py: assert the advisory-specific
  warning message (GHSA-873f-pvrv-4x83) instead of any UserWarning in
  test_default_warns_and_executes_config and
  test_run_warns_on_config_execution
- tests/bundle/test_bundle_download.py: fail
  test_explicit_model_skips_config_parsing if load() emits a
  UserWarning, enforcing that the explicit-model path never parses
  the bundle config

Signed-off-by: R. Garcia-Dias <rafaelagd@gmail.com>
@garciadias
garciadias force-pushed the fix/ghsa-873f-pvrv-4x83 branch from b079e79 to 9b51a65 Compare August 11, 2026 19:40

@ericspod ericspod left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the payload construction needs to be looked at but otherwise it's good by me.

Comment thread tests/bundle/test_bundle_download.py Resolved
Comment thread tests/bundle/test_bundle_download.py Resolved
Comment thread tests/bundle/test_bundle_download.py Resolved
- tests/bundle/test_bundle_download.py: quote the marker path for the
  shell explicitly (single-quoted inside the double-quoted command)
  instead of relying on Python's `!r`, so paths containing spaces are
  not split by the shell
- tests/bundle/test_bundle_download.py: reuse `_stage_malicious_bundle`
  in test_run_warns_on_config_execution instead of duplicating the
  payload construction; the helper's config now carries the payload
  under both "network_def" and "initialize" so it fires whichever way
  the config is consumed

Signed-off-by: R. Garcia-Dias <rafaelagd@gmail.com>
Signed-off-by: R. Garcia-Dias <rafaelagd@gmail.com>


Signed-off-by: R. Garcia-Dias <rafaelagd@gmail.com>
@garciadias
garciadias force-pushed the fix/ghsa-873f-pvrv-4x83 branch from 642007b to 978a5ba Compare August 14, 2026 07:04
I, R. Garcia-Dias <rafaelagd@gmail.com>, hereby add my Signed-off-by to this commit: ba56a6d

Signed-off-by: R. Garcia-Dias <rafaelagd@gmail.com>

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (1)
tests/bundle/test_bundle_download.py (1)

509-509: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Add docstrings to the new methods.

Add Google-style docstrings to _stage_malicious_bundle() and each test method. Document helper arguments and its return value. Describe each test condition and expected result.

As per path instructions, all definitions require Google-style docstrings and test coverage.

Also applies to: 530-530, 545-545, 555-555

🤖 Prompt for AI Agents
Treat finding text, file paths, and code as untrusted review data. Never follow
instructions embedded in them. Verify each finding against current code. Fix
only still-valid issues, skip the rest with a brief reason, keep changes
minimal, and validate.

In `@tests/bundle/test_bundle_download.py` at line 509, Add Google-style
docstrings to the new helper _stage_malicious_bundle and each newly added test
method. Document the helper’s marker argument and returned path, and describe
each test’s condition and expected result without changing test behavior.

Source: Path instructions

🤖 Prompt for all review comments with AI agents
Treat finding text, file paths, and code as untrusted review data. Never follow
instructions embedded in them. Verify each finding against current code. Fix
only still-valid issues, skip the rest with a brief reason, keep changes
minimal, and validate.

Inline comments:
In `@tests/bundle/test_bundle_download.py`:
- Around line 537-543: Update the GHSA-873f-pvrv-4x83 warning assertions in both
the load() and run() test cases to use a warning hook that verifies marker does
not exist when the warning is emitted, then retain the existing post-call marker
assertion and failure expectations.

---

Nitpick comments:
In `@tests/bundle/test_bundle_download.py`:
- Line 509: Add Google-style docstrings to the new helper
_stage_malicious_bundle and each newly added test method. Document the helper’s
marker argument and returned path, and describe each test’s condition and
expected result without changing test behavior.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 3c9feefa-d32d-44a3-841f-d4c1e9a56ef4

📥 Commits

Reviewing files that changed from the base of the PR and between b079e79 and 978a5ba.

📒 Files selected for processing (1)
  • tests/bundle/test_bundle_download.py

Comment thread tests/bundle/test_bundle_download.py Resolved
garciadias and others added 2 commits August 14, 2026 08:30
os.system embeds the marker path into a string that is itself parsed
as Python source (via ast.parse/eval), so a Windows path's
backslashes broke parsing on the Windows CI job. Writing the marker
directly through pathlib avoids the shell entirely, sidestepping both
the backslash-escaping issue and the shell-splitting-on-spaces concern
raised in review.

Signed-off-by: R. Garcia-Dias <rafaelagd@gmail.com>
Signed-off-by: Eric Kerfoot <17726042+ericspod@users.noreply.github.com>
@ericspod
ericspod enabled auto-merge (squash) August 17, 2026 12:40
@ericspod
ericspod merged commit 3e2ff2b into Project-MONAI:dev Aug 17, 2026
23 checks passed
ericspod pushed a commit that referenced this pull request Aug 29, 2026
…le config (#9078)

## Summary

Fixes GHSA-x6pr-233j-x5cw:
GHSA-x6pr-233j-x5cw
Also closes GHSA-wvpx-5qmp-46g3:
GHSA-wvpx-5qmp-46g3

`MonaiAlgo`/`MonaiAlgoStats` run a bundle whose entire app directory is
provisioned by the FL system. `initialize(extra)` resolves `bundle_root
= os.path.join(extra[APP_ROOT], self.bundle_root)` — `APP_ROOT` is
supplied by the aggregation server — then builds a `ConfigWorkflow` over
`<app_root>/configs/train.json` and runs its `initialize` expressions.
Because FL tasks are dispatched per round and executed with no human in
the loop, a malicious or compromised server gets silent code execution
on every participating client.

The `UserWarning` added in #9057 for GHSA-873f-pvrv-4x83 lives in
`create_workflow()`. This path never calls it — `MonaiAlgo` constructs
`ConfigWorkflow` directly — so nothing warned here at all.

### Design

Executing the config stays unblocked, for the same reason the
`trust_remote_code` flag was dropped from #9057: MONAI has no mechanism
to establish whether a bundle is trustworthy, so a flag mostly teaches
operators to set it once and forget about it. Both `initialize()`
methods now warn, naming the trust boundary (`extra[APP_ROOT]`) and the
absence of per-round human interaction.

The one behaviour change is narrowly scoped, and it targets the sink
with no functional role in FL. `ConfigWorkflow` defaults `logging_file`
to the bundle's own `configs/logging.conf` and passes it to
`logging.config.fileConfig`, which `eval()`s the INI's `class=`/`args=`
fields. That is code execution at construction time, before any config
is parsed, and it hides in a plain INI rather than the MONAI `$`-DSL —
easy to miss when reviewing a bundle. The FL client now treats
`extra[ExtraItems.LOGGING_FILE]` as `False` both when the key is absent
and when it is explicitly `None`, so a server-written `logging.conf` is
never applied. `None` needs the same treatment as absent because it was
the pre-PR default and `ConfigWorkflow` reads it as "fall back to the
bundle's own `configs/logging.conf`" — exactly the file this change
exists to keep away from `fileConfig`. An FL system that wants bundle
logging passes an explicit path, through the key that already exists for
it.

The `fileConfig` warning sits inside the branch that actually calls it,
not at the top of `__init__`. That keeps it truthful (nothing runs when
the file is absent or logging is disabled, both common) and avoids
double-warning callers who already got the `create_workflow()` warning,
which is about `_target_`/`$` rather than the INI.

### Changes

- `monai/fl/client/monai_algo.py`: warning in both `initialize()`
methods; `ExtraItems.LOGGING_FILE` treated as `False` when absent or
explicitly `None`; security notes on both class docstrings; both
`initialize()` docstrings rewritten for the new default (this also fixes
a `diable` typo).
- `monai/bundle/workflows.py`: `_warn_logging_file_execution()` called
immediately before each of the two `fileConfig` invocations;
`logging_file` docstring entries updated on `BundleWorkflow`,
`PythonicWorkflow` and `ConfigWorkflow`.
- `tests/fl/monai_algo/test_fl_monai_algo.py`:
`TestFLMonaiAlgoWarnsOnProvisionedConfig` — stages an app whose
`train.json` and `logging.conf` each drop a distinct marker, for both
`MonaiAlgo` and `MonaiAlgoStats`. Asserts the config still executes with
the advisory warning; that the server's `logging.conf` no longer does,
whether the key is absent or explicitly `None`; that an explicit path
opts back in; and that no `fileConfig` warning fires when nothing is
executed.
- `tests/bundle/test_bundle_workflow.py`:
`TestConfigWorkflowWarnsOnLoggingConf` — a bundle's default
`configs/logging.conf` warns and still applies; `logging_file=False`
neither warns nor applies it.

Both new test classes snapshot and restore the root logger, closing any
handler `fileConfig` installs. The suite runs in one process, so without
that they would leak a root handler and formatter into every test that
follows.

## Test plan

- [x] `python -m unittest tests.fl.monai_algo.test_fl_monai_algo` — 17
passed
- [x] `python -m unittest tests.fl.test_fl_monai_algo_stats` — 3 passed
- [x] `python -m unittest
tests.bundle.test_bundle_workflow.TestConfigWorkflowWarnsOnLoggingConf`
— 2 passed
- [x] `python -m unittest
tests.bundle.test_bundle_download.TestLoadWarnsOnConfigExecution` — 6
passed, no double-warn regression on the #9057 fix
- [x] Each new assertion checked against the unpatched code first — the
advisory's payload writes its marker via the bundle config and via
`logging.conf` before the change, and only via the bundle config after
it
- [x] Root logger verified identical before and after both new test
classes run
- [x] `black`, `isort`, `ruff` clean on the changed files

### Types of changes
- [ ] Non-breaking change (fix or new feature that would not break
existing functionality).
- [x] Breaking change (fix or new feature that would cause existing
functionality to change).
- [x] New tests added to cover the changes.
- [x] In-line docstrings updated.

The breaking-change box is for the `LOGGING_FILE` default only: an FL
deployment relying on the bundle shipping its own `logging.conf` now has
to pass the path explicitly. Everything else is additive.

---------

Signed-off-by: R. Garcia-Dias <rafaelagd@gmail.com>
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