Skip to content

test: add secrets detection hook regressions - #3931

Merged
crivetimihai merged 5 commits into
mainfrom
fix/issue-5-secrets-detection-hooks
Apr 3, 2026
Merged

crivetimihai merged 5 commits into
mainfrom
fix/issue-5-secrets-detection-hooks

Conversation

@lucarlig

@lucarlig lucarlig commented Mar 30, 2026 •

Copy link
Copy Markdown
Contributor

🔗 Related Issue

Related internal mirror issue: contextforge-org/mcp-context-forge#5


📝 Summary

This PR adds regression coverage for the secrets detection plugin hook paths reported in the issue: prompt_pre_fetch, tool_post_invoke, and resource_post_fetch.

Only test changes were needed because targeted local verification showed the current plugin implementation already handled the reported redact-only and block-only behaviors correctly. The gap was missing automated coverage for those scenarios through the framework dispatch path, so this PR codifies those cases to prevent regressions.


🏷️ Type of Change

  • Bug fix
  • Feature / Enhancement
  • Documentation
  • Refactor
  • Chore (deps, CI, tooling)
  • Other (test-only regression coverage)

🧪 Verification

Check Command Status
Lint suite make lint Not run
Unit tests source .venv/bin/activate && python -m pytest tests/unit/plugins/test_secrets_detection.py -q Passed
Coverage ≥ 80% make coverage Not run

✅ Checklist

  • Code formatted (make black isort pre-commit)
  • Tests added/updated for changes
  • Documentation updated (if applicable)
  • No secrets or credentials committed

📓 Notes (optional)

The regression cases are loaded through a minimal plugin config so the tests exercise PluginManager.initialize() and hook dispatch, rather than only calling plugin methods directly.

@lucarlig
lucarlig marked this pull request as ready for review March 30, 2026 15:13

@gandhipratik203 gandhipratik203 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Nit (non-blocking): The three blocking tests (test_prompt_pre_fetch_blocks_without_redaction, test_tool_post_invoke_blocks_without_redaction, test_resource_post_fetch_blocks_without_redaction) assert result.modified_payload == payload. This works via Pydantic value equality, but the modified_payload here is backfilled by the executor (manager.py:361-363), not set by the plugin itself. A brief inline comment would help future readers understand this isn't testing plugin output directly.

@gandhipratik203 gandhipratik203 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM — good regression coverage for the secrets detection hooks across all three dispatch paths.

@lucarlig

Copy link
Copy Markdown
Contributor Author

@gandhipratik203 added the comment

@lucarlig lucarlig added release-fix Critical bugfix required for the release wxo wxo integration python Python / backend development (FastAPI) plugins labels Mar 30, 2026

@gandhipratik203 gandhipratik203 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM — good regression coverage for the secrets detection hooks across all three dispatch paths.

@lucarlig lucarlig added this to the Release 1.0.0-RC3 milestone Mar 31, 2026
@crivetimihai crivetimihai self-assigned this Apr 3, 2026
lucarlig and others added 5 commits April 3, 2026 09:09
- Regenerate .secrets.baseline to reflect shifted line numbers after
  test additions (466 → 636)
- Fix isort import section ordering in test_secrets_detection.py

Signed-off-by: Mihai Criveti <[email protected]>

@crivetimihai crivetimihai 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 — well-structured regression tests for the three secrets detection hook dispatch paths (prompt_pre_fetch, tool_post_invoke, resource_post_fetch).

What was reviewed:

  • All 6 new tests correctly exercise the real PluginManager.invoke_hook dispatch, not just direct plugin method calls
  • Redact paths verify continue_processing=True, modified payload contents, and metadata
  • Block paths verify continue_processing=False, violation code, and payload backfill behavior
  • Test isolation is solid: PluginManager.reset() autouse fixture + try/finally shutdown
  • Consistent with existing test patterns in the codebase

Changes made during rebase:

  • Rebased onto main, removed merge commit
  • Regenerated .secrets.baseline (line number shift 466 → 665)
  • Fixed isort import section ordering

@crivetimihai
crivetimihai merged commit 860ef3f into main Apr 3, 2026
19 checks passed
@crivetimihai
crivetimihai deleted the fix/issue-5-secrets-detection-hooks branch April 3, 2026 08:28
jonpspri pushed a commit that referenced this pull request Apr 10, 2026
* test: add secrets detection hook regressions

Signed-off-by: lucarlig <[email protected]>

* test: exercise secrets detection through manager dispatch

Signed-off-by: lucarlig <[email protected]>

* test: load secrets hook cases through plugin config

Signed-off-by: lucarlig <[email protected]>

* test: clarify manager-backed blocked payload assertions

Signed-off-by: lucarlig <[email protected]>

* fix: update secrets baseline line numbers and fix import ordering

- Regenerate .secrets.baseline to reflect shifted line numbers after
  test additions (466 → 636)
- Fix isort import section ordering in test_secrets_detection.py

Signed-off-by: Mihai Criveti <[email protected]>

---------

Signed-off-by: lucarlig <[email protected]>
Signed-off-by: Mihai Criveti <[email protected]>
Co-authored-by: Mihai Criveti <[email protected]>
msureshkumar88 pushed a commit that referenced this pull request May 13, 2026
* test: add secrets detection hook regressions

Signed-off-by: lucarlig <[email protected]>

* test: exercise secrets detection through manager dispatch

Signed-off-by: lucarlig <[email protected]>

* test: load secrets hook cases through plugin config

Signed-off-by: lucarlig <[email protected]>

* test: clarify manager-backed blocked payload assertions

Signed-off-by: lucarlig <[email protected]>

* fix: update secrets baseline line numbers and fix import ordering

- Regenerate .secrets.baseline to reflect shifted line numbers after
  test additions (466 → 636)
- Fix isort import section ordering in test_secrets_detection.py

Signed-off-by: Mihai Criveti <[email protected]>

---------

Signed-off-by: lucarlig <[email protected]>
Signed-off-by: Mihai Criveti <[email protected]>
Co-authored-by: Mihai Criveti <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

plugins python Python / backend development (FastAPI) release-fix Critical bugfix required for the release wxo wxo integration

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants