Files
cleveragents-core/features/plugins_loader_coverage.feature
T
HAL9000 5b6224daa8
CI / benchmark-publish (pull_request) Has been skipped
CI / lint (pull_request) Successful in 1m59s
CI / push-validation (pull_request) Successful in 36s
CI / build (pull_request) Successful in 1m5s
CI / helm (pull_request) Successful in 51s
CI / benchmark-regression (pull_request) Failing after 1m45s
CI / typecheck (pull_request) Successful in 2m23s
CI / quality (pull_request) Successful in 2m13s
CI / security (pull_request) Successful in 2m19s
CI / integration_tests (pull_request) Successful in 4m30s
CI / e2e_tests (pull_request) Successful in 4m42s
CI / unit_tests (pull_request) Successful in 5m54s
CI / docker (pull_request) Successful in 1m44s
CI / coverage (pull_request) Successful in 11m32s
CI / status-check (pull_request) Successful in 3s
CI / benchmark-publish (push) Has started running
CI / helm (push) Successful in 38s
CI / build (push) Successful in 1m6s
CI / push-validation (push) Successful in 24s
CI / lint (push) Successful in 1m16s
CI / quality (push) Successful in 1m29s
CI / typecheck (push) Successful in 1m41s
CI / security (push) Successful in 1m55s
CI / integration_tests (push) Successful in 3m54s
CI / benchmark-regression (push) Has been skipped
CI / unit_tests (push) Successful in 5m5s
CI / e2e_tests (push) Successful in 5m21s
CI / docker (push) Successful in 1m52s
CI / coverage (push) Successful in 15m41s
CI / status-check (push) Successful in 3s
fix(plugins): prevent arbitrary code execution in PluginLoader.validate_protocol()
- Add guard in TypeError fallback path: raise ProtocolMismatchError when
  issubclass raises TypeError and protocol has no inspectable members,
  preventing silent True return for unverifiable protocols
- Update test scenario descriptions to accurately reflect the new
  implementation (no instantiation occurs at any point)
- Update step definition comments to remove references to old
  instantiation-based code paths

ISSUES CLOSED: #7418
2026-05-08 09:32:29 +00:00

50 lines
2.7 KiB
Gherkin

Feature: Plugin Loader Coverage Boost
Scenarios targeting uncovered lines in the PluginLoader class:
- Lines 203-209: entry point load failure exception handler
- validate_protocol: issubclass succeeds (class satisfies protocol structurally)
- validate_protocol: issubclass raises TypeError with unverifiable protocol
- validate_protocol: issubclass returns False (class missing required members)
Background:
Given the plugin loader module is imported
# -----------------------------------------------------------------------
# Entry-point discovery: failure path (lines 203-209)
# -----------------------------------------------------------------------
Scenario: Entry point that fails to load is skipped with a warning
Given the entry points are mocked with one that raises on load
When I call load_from_entry_points
Then the plugin result should be an empty descriptor list
And the failed entry point should have been logged as a warning
# -----------------------------------------------------------------------
# validate_protocol: issubclass succeeds for class satisfying protocol
# -----------------------------------------------------------------------
Scenario: validate_protocol returns True when class satisfies protocol via issubclass
Given I have a class that requires constructor arguments
And I have a runtime checkable protocol the class satisfies via issubclass
When I call validate_protocol with the non-instantiable class and protocol
Then validate_protocol should return True
# -----------------------------------------------------------------------
# validate_protocol: issubclass raises TypeError for unverifiable protocol
# -----------------------------------------------------------------------
Scenario: validate_protocol raises ProtocolMismatchError when issubclass raises TypeError
Given I have a class that cannot be instantiated without arguments
And I have a protocol-like object that causes issubclass to raise TypeError
When I call validate_protocol expecting a mismatch error
Then a plugin-loader ProtocolMismatchError should be raised
# -----------------------------------------------------------------------
# validate_protocol: issubclass returns False (class missing required members)
# -----------------------------------------------------------------------
Scenario: validate_protocol raises ProtocolMismatchError when issubclass returns False
Given I have a class that cannot be instantiated without arguments
And I have a runtime checkable protocol the class does not satisfy
When I call validate_protocol expecting a mismatch error
Then a plugin-loader ProtocolMismatchError should be raised