-
Notifications
You must be signed in to change notification settings - Fork 614
[BUG]: detect-private-key hook fails on test fixtures containing private keys #2733
Copy link
Copy link
Closed
Copy link
Labels
SHOULDP2: Important but not vital; high-value items that are not crucial for the immediate releaseP2: Important but not vital; high-value items that are not crucial for the immediate releasebugSomething isn't workingSomething isn't working
Milestone
Description
🐞 Bug Summary
The detect-private-key pre-commit hook fails when running make pre-commit, blocking commits due to legitimate test fixtures that contain private keys for testing TLS and cryptographic key generation functionality.
🧩 Affected Component
Select the area of the project impacted:
-
mcpgateway- API -
mcpgateway- UI (admin panel) -
mcpgateway.wrapper- stdio wrapper - Federation or Transports
- CLI, Makefiles, or shell scripts
- Container setup (Docker/Podman/Compose)
- Other (explain below)
🔁 Steps to Reproduce
- Run
make pre-commitin the project root - Observe the
detect-private-keyhook failure - Note the flagged files are test fixtures
🤔 Expected Behavior
The detect-private-key hook should allow test files containing private keys used as test fixtures for TLS and cryptographic testing. These are not actual secrets but necessary test data for validating security functionality.
📓 Logs / Error Output
🔐 Detect Private Key....................................................Failed
- hook id: detect-private-key
- exit code: 1
Private key found: tests/unit/mcpgateway/plugins/framework/external/mcp/test_tls_utils.py
Private key found: tests/unit/mcpgateway/utils/test_generate_keys.py
🧠 Environment Info
You can retrieve most of this from the /version endpoint.
| Key | Value |
|---|---|
| Version or commit | main |
| Runtime | Python 3.11+ |
| Platform / OS | macOS |
| Container | none |
🧩 Additional Context (optional)
Affected Files:
tests/unit/mcpgateway/plugins/framework/external/mcp/test_tls_utils.py- Tests for TLS utilities requiring certificate fixturestests/unit/mcpgateway/utils/test_generate_keys.py- Tests for Ed25519 key generation requiring key fixtures
Potential Solutions:
- Add test fixture paths to the
excludepattern in.pre-commit-config.yaml - Move test private keys to separate fixture files and exclude those specific files
- Use the
args: ['--allow-missing-credentials']parameter for the hook (if supported) - Generate keys dynamically in tests instead of using hardcoded fixtures
Configuration Location:
The hook is configured in .pre-commit-config.yaml at lines 42-45:
- id: detect-private-key
name: 🔐 Detect Private Key
description: Detects the presence of private keys.
types: [text]Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
SHOULDP2: Important but not vital; high-value items that are not crucial for the immediate releaseP2: Important but not vital; high-value items that are not crucial for the immediate releasebugSomething isn't workingSomething isn't working