Skip to content

fix: hide plugin input, raise dependency floors - #653

Merged
uniqueg merged 7 commits into
devfrom
fix/plugin-input-and-floors
Nov 3, 2026
Merged

uniqueg merged 7 commits into
devfrom
fix/plugin-input-and-floors

Conversation

@uniqueg

@uniqueg uniqueg commented Nov 3, 2026 •

Copy link
Copy Markdown
Member

Summary

  • Raises the floors to urllib3>=2.8,<3 and pymongo>=4.18.3,<5 (CVE-2026-97688, CVE-2026-97689, CVE-2026-106435).
  • Validation errors of plugin config, step params and the custom configuration no longer show the input, in their message or chain. This makes the statement of the migration guide true.

Messages of pydantic that quote parts of the input (import_error, union_tag_invalid, zoneinfo_str, byte_size_unit, uuid_parsing, bytes_invalid_encoding), and any message containing the input as a whole, are replaced by the error's type. Other errors of validators show their type only; on params, they are logged and raise PluginError, as they are no client error.

The custom configuration's message stays, and __cause__ is now a plain ValueError with <setting>: <reason>. proTES's tests read str(__cause__) (a first version with no cause failed 4 of them, against the FOCA candidate). cloud-registry's tests/test_app.py:2057,2076 check isinstance(__cause__, ValidationError) and need changing when it moves to FOCA 0.20; the migration guide says so.

Closes #645
Closes #646

How it was verified

  • coverage run -m pytest with MongoDB 7.0.34, Python 3.13: 3349 passed, 1 skipped, 100% coverage. ruff, mypy, ast-grep, semgrep, mkdocs build --strict: passed.
  • Lowest dependencies, Python 3.11: resolves to urllib3 2.8.0, pymongo 4.18.3, pydantic 2.7.0; the tests of foca/utils, config and plugin errors pass.
  • Full review, two rounds.

Declined review findings

  • Names of keys stay in the messages (adversarial, medium): they tell what to correct; a mistyped key is the main case. The guide says that they must not contain secrets.
  • __context__ still holds the original error (adversarial, low): tracebacks honour the suppression, and nothing in FOCA reads it. Only code in the process, which has the configuration anyway, can reach it.
  • Non-validation errors of the custom configuration show only their type (adversarial, low): deliberate, as their messages may show the input.
  • Share a formatter with foca/plugins/selection.py:_first_error (quality, low): it reports one error to clients, on its own input.
  • SystemExit from a params validator escapes (adversarial, low): predates this PR.

🤖 Generated with Claude Code

https://claude.ai/code/session_011FSoqMUX3EU35poH13xMgG

Summary by Sourcery

Protect configuration and plugin validation errors from exposing sensitive input while updating dependency minimums for security fixes.

Bug Fixes:

  • Prevent plugin configuration, step parameters, and custom configuration validation errors from exposing invalid input values or leaking them through chained exceptions.
  • Report unexpected plugin validator failures by type, log them without input values, and raise the appropriate plugin error.
  • Raise the minimum urllib3 and pymongo versions to include fixes for identified security vulnerabilities.

Enhancements:

  • Add shared validation-error descriptions that preserve useful field locations while redacting quoted or full input values.

Documentation:

  • Document the updated dependency floors and the revised redaction behavior for configuration and plugin validation errors.

Tests:

  • Add coverage for redacted validation errors, validator failures, exception chains, and sensitive input handling across custom configuration and plugins.

uniqueg and others added 4 commits November 3, 2026 10:59
urllib3 below 2.8 has CVE-2026-97688 and CVE-2026-97689, which defeat
the deadline and size limit of GuardedClient against hostile servers.
pymongo 4.18.2 has CVE-2026-106435.

Closes #645

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_011FSoqMUX3EU35poH13xMgG
Plugin config and step params are validated against plugin-owned models,
which need not set hide_input_in_errors, and the error went into the
startup message, with its input. The custom configuration chained the
same error, so tracebacks showed it. A mistyped key or a missing field
could put a secret into the logs.

Name the location and message only, and don't chain the original error.
This makes the statement of the migration guide true.

Closes #646

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_011FSoqMUX3EU35poH13xMgG
Don't pass on pydantic's messages that quote the input (unknown tags of
unions, import paths), and describe other errors of validators by their
type. Keep a cause on the custom configuration's error, as apps read it
(proTES's tests do), but one without the input. Name the new floors and
the new format of the errors in the migration guide.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_011FSoqMUX3EU35poH13xMgG
Pydantic quotes the input in more messages than the first list had, and
validators may quote it too: replace messages of these types, and those
that contain the input as a whole. A bug of a params validator is no
client error: log it, by type only, and raise PluginError. Say in the
guide what changes for the custom configuration's cause.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_011FSoqMUX3EU35poH13xMgG
@sourcery-ai

sourcery-ai Bot commented Nov 3, 2026 •

Copy link
Copy Markdown

Reviewer's Guide

The PR prevents sensitive validation inputs from leaking through plugin configuration, step parameters, custom configuration errors, exception chains, and logs by introducing a shared safe error formatter and applying it at validation boundaries. It also raises urllib3 and pymongo dependency floors for security fixes, updates migration and configuration documentation, and adds comprehensive regression coverage.

Sequence diagram for sanitized plugin validation errors

sequenceDiagram
    participant Loader as PluginLoader
    participant Model as PluginModel
    participant Formatter as describe_validation_error
    participant Caller as Caller

    Loader->>Model: model_validate(config)
    Model-->>Loader: ValidationError
    Loader->>Formatter: describe_validation_error(exc)
    Formatter-->>Loader: field locations and safe reasons
    Loader-->>Caller: ValueError(safe description)

    participant Engine as StepEngine
    Engine->>Model: model_validate(params)
    Model-->>Engine: ValidationError
    Engine->>Formatter: describe_validation_error(exc)
    Formatter-->>Engine: sanitized description
    Engine-->>Caller: ValueError(safe description)
Loading

Sequence diagram for sanitized custom configuration errors

sequenceDiagram
    participant Parser as ConfigParser
    participant Model as CustomConfigModel
    participant Formatter as describe_validation_error
    participant Caller as Caller

    Parser->>Model: model_class(**custom)
    Model-->>Parser: validation exception
    Parser->>Formatter: describe_validation_error(exc)
    Formatter-->>Parser: setting and safe reason
    Parser-->>Caller: ValueError(custom message)
    Caller->>Caller: str(__cause__) returns setting and reason
Loading

Flow diagram for safe validation error formatting

flowchart LR
    Error[Validation exception] --> Check{ValidationError?}
    Check -->|No| Type[Return exception type]
    Check -->|Yes| Errors[Read validation errors without input context]
    Errors --> Sanitize[Replace quoted input messages with error type]
    Sanitize --> Result[Return field location and safe reason]
Loading

File-Level Changes

Change Details Files
Centralize sanitization of validation failures so error messages and exception chains do not expose invalid configuration or parameter values.
  • Add a formatter that preserves field locations but replaces quoted inputs and unsafe validator failures with safe descriptions.
  • Apply sanitized errors to custom configuration and plugin configuration, suppressing the original exception chain.
  • Handle unexpected plugin parameter validator exceptions as logged, sanitized PluginError failures; retain normal validation errors as client-facing ValueError failures.
foca/utils/misc.py
foca/config/config_parser.py
foca/plugins/loader.py
foca/plugins/engine.py
Raise dependency minimums to versions containing fixes for the listed security vulnerabilities.
  • Require urllib3>=2.8,<3.
  • Require pymongo>=4.18.3,<5 and document the associated CVE fixes.
pyproject.toml
docs/migration-0.20.md
Document the new secret-handling guarantees and migration impact for plugin and custom configuration errors.
  • Clarify that plugin config, step params, and custom configuration validation errors omit input values while retaining safe locations and validator messages.
  • Document the changed custom-configuration cause type and dependency floors.
docs/configuration/plugins.md
docs/migration-0.20.md
Add regression coverage for sanitized messages, tracebacks, logs, exception causes, and edge-case Pydantic errors.
  • Test hidden inputs for custom configuration, plugin configuration, and plugin parameters.
  • Cover quoted-input Pydantic error types, missing fields, extra keys, model-level errors, and non-validation exceptions.
  • Verify unexpected parameter validator failures produce sanitized logs and PluginError exceptions.
tests/config/test_config_parser.py
tests/plugins/test_plugin_error_input.py
tests/test_files/model_valid.py
tests/utils/test_misc.py

Possibly linked issues


Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@codecov

codecov Bot commented Nov 3, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (631da3a) to head (af61c08).

Additional details and impacted files
@@            Coverage Diff            @@
##               dev      #653   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           56        56           
  Lines         7164      7189   +25     
=========================================
+ Hits          7164      7189   +25     
Flag Coverage Δ
test_unit 100.00% <100.00%> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@uniqueg
uniqueg marked this pull request as ready for review November 3, 2026 10:50

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Hey - I've found 4 issues

Prompt for AI Agents
Please address the comments from this code review:

## Individual Comments

### Comment 1
<location path="foca/utils/misc.py" line_range="74" />
<code_context>
+    for error in exc.errors(include_url=False, include_context=False):
+        value = error["input"]
+        quoted = (
+            isinstance(value, str)
+            and len(value) >= _MIN_QUOTED_INPUT
+            and value in error["msg"]
</code_context>
<issue_to_address>
**Validator secrets leak in errors**

When a plugin or custom validator includes a rejected input or part of a secret in its error message, and the input is short, non-string, or nested, `describe_validation_error` only detects sufficiently long string inputs that appear verbatim in the message, so it passes other messages through and exposes the value in startup errors, tracebacks, or client-facing validation errors.

Redact validator messages that contain rejected inputs, including short strings, non-string or nested values, and partial secrets.
</issue_to_address>

### Comment 2
<location path="foca/plugins/engine.py" line_range="822" />
<code_context>
-                    raise ValueError(f"{invalid}: {exc}") from exc
+                    raise ValueError(
+                        f"{invalid}: {describe_validation_error(exc)}"
+                    ) from None
+                except Exception as exc:  # bugs of validators; may show the input
+                    name = describe_validation_error(exc)
</code_context>
<issue_to_address>
**Custom parameter errors leak values**

When a plugin's `check_params` raises `InvalidParams` with a message containing a secret parameter value, `check_params` runs after this sanitized model-validation branch, but its `InvalidParams` handler still puts the plugin-provided message in a `ValueError` and chains the original exception; a message containing a parameter value therefore reaches startup errors or the client-facing selection error.

Sanitize `InvalidParams` messages and avoid chaining exceptions that may contain parameter values.
</issue_to_address>

### Comment 3
<location path="foca/plugins/loader.py" line_range="371-375" />
<code_context>
             try:
                 config = cls.Config.model_validate(available.config)
-            except ValidationError as exc:
+            except Exception as exc:  # validators of plugins may raise anything
                 raise ValueError(
-                    f"Invalid config of plugin {plugin_id!r}: {exc}"
-                ) from exc
+                    f"Invalid config of plugin {plugin_id!r}: "
+                    f"{describe_validation_error(exc)}"
+                ) from None
             loaded[plugin_id] = LoadedPlugin(
                 id=plugin_id,
</code_context>
<issue_to_address>
**Harness config errors still reveal input**

When a caller supplies invalid plugin config to the documented `PluginHarness` helper, `PluginHarness` validates its config directly instead of using this sanitized loader path, so invalid test-harness configuration still raises a raw Pydantic error containing the input and can expose secrets in test output.

Sanitize config-validation errors in `PluginHarness` as well, or route its config validation through the same helper.
</issue_to_address>

### Comment 4
<location path="foca/plugins/loader.py" line_range="371-375" />
<code_context>
             try:
                 config = cls.Config.model_validate(available.config)
-            except ValidationError as exc:
+            except Exception as exc:  # validators of plugins may raise anything
                 raise ValueError(
-                    f"Invalid config of plugin {plugin_id!r}: {exc}"
-                ) from exc
+                    f"Invalid config of plugin {plugin_id!r}: "
+                    f"{describe_validation_error(exc)}"
+                ) from None
             loaded[plugin_id] = LoadedPlugin(
                 id=plugin_id,
</code_context>
<issue_to_address>
**Plugin bugs look like config errors**

When a plugin's config validator raises an exception other than `ValidationError`, `load_plugins` converts every validator exception into a `ValueError` and suppresses its cause, while `describe_validation_error` retains only the exception type; with no log of the failure, operators see an invalid-config error but lose the diagnostic context for a plugin bug.

Keep sanitized `ValidationError`s as configuration errors, but distinguish unexpected validator failures and report them with safe diagnostic logging.
</issue_to_address>

Linked issues

#645 build: raise urllib3 and pymongo floors · 1 of 1 met

# Requirement Status Notes
1 Raise the urllib3 and pymongo minimum versions to the requested floors, with comments explaining the fixes. ✅ Met pyproject.toml sets urllib3>=2.8,<3 and pymongo>=4.18.3,<5, and documents the relevant advisories.

#646 fix(plugins): hide input in validation errors · 1 of 3 met

# Requirement Status Notes
1 Format plugin config and step params validation errors without input, and do not chain the original error. 🟡 Partly met The plugin paths use the sanitized description and suppress the original chain, but the description can still include input embedded in some validator messages.
2 Format custom configuration validation errors without input, and do not chain the original error. 🟡 Partly met The original error is replaced in the cause, but the shared description helper can still include input embedded in some validator messages.
3 Add regression tests for the plugin config, step params, and custom configuration paths. ✅ Met Tests cover all three paths, including validator failures and traceback leakage.

Sourcery assessment

Approval pending. 3 findings to address first.

Blocking findings: foca/utils/misc.py:74, foca/plugins/engine.py:822, foca/plugins/loader.py:375


Sourcery is free for open source - if you like our reviews please consider sharing them ✨

Comment thread foca/utils/misc.py Resolved
Comment thread foca/plugins/engine.py Resolved
Comment thread foca/plugins/loader.py Resolved
Comment thread foca/plugins/loader.py Resolved
sourcery-ai[bot]
sourcery-ai Bot previously approved these changes Nov 3, 2026

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Sourcery assessment

Approved.

Exceptions other than validation errors now read as failures of the
plugin and are logged by type, as for step params. Tell plugin authors
that messages of validators and of InvalidParams are shown.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_011FSoqMUX3EU35poH13xMgG
@sourcery-ai
sourcery-ai Bot dismissed their stale review November 3, 2026 11:26

Sourcery withdrew this approval because the latest commits introduced blocking findings.

@uniqueg
uniqueg merged commit ad23227 into dev Nov 3, 2026
55 checks passed
@uniqueg
uniqueg deleted the fix/plugin-input-and-floors branch November 3, 2026 11:37
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.

fix(plugins): hide input in validation errors build: raise urllib3 and pymongo floors

1 participant