Repository navigation
fix: hide plugin input, raise dependency floors - #653
Conversation
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
Reviewer's GuideThe 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 errorssequenceDiagram
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)
Sequence diagram for sanitized custom configuration errorssequenceDiagram
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
Flow diagram for safe validation error formattingflowchart 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]
File-Level Changes
Possibly linked issues
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
Codecov Report✅ All modified and coverable lines are covered by tests. 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
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_011FSoqMUX3EU35poH13xMgG
There was a problem hiding this comment.
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
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 withdrew this approval because the latest commits introduced blocking findings.
Summary
urllib3>=2.8,<3andpymongo>=4.18.3,<5(CVE-2026-97688, CVE-2026-97689, CVE-2026-106435).config, stepparamsand 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 raisePluginError, as they are no client error.The custom configuration's message stays, and
__cause__is now a plainValueErrorwith<setting>: <reason>. proTES's tests readstr(__cause__)(a first version with no cause failed 4 of them, against the FOCA candidate). cloud-registry'stests/test_app.py:2057,2076checkisinstance(__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 pytestwith MongoDB 7.0.34, Python 3.13: 3349 passed, 1 skipped, 100% coverage.ruff,mypy,ast-grep,semgrep,mkdocs build --strict: passed.foca/utils, config and plugin errors pass.Declined review findings
__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.foca/plugins/selection.py:_first_error(quality, low): it reports one error to clients, on its own input.SystemExitfrom 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:
Enhancements:
Documentation:
Tests: