fix: remove hardcoded private key placeholders from docstrings and add signing tests#4867
Open
devin-ai-integration[bot] wants to merge 2 commits intomainfrom
Open
Conversation
…d signing tests - Replace '-----BEGIN PRIVATE KEY-----...' and '-----BEGIN PUBLIC KEY-----...' placeholders in docstring examples with '<PEM-encoded private key>' and '<PEM-encoded public key>' to avoid triggering security scanners. - Add comprehensive test suite for agent_card_signing.py (40 tests) covering: - Key normalization (bytes, str, SecretStr) - AgentCard serialization (JSON validity, determinism, signature exclusion) - Base64url encoding (padding, URL safety, roundtrip) - RSA signing and verification - EC (ES256) signing and verification - Tampered card detection - Corrupted signature handling - Key ID extraction from protected/unprotected headers - Assertion that no hardcoded PEM key headers exist in source Closes #4864 Co-Authored-By: João <joao@crewai.com>
Contributor
Author
|
Prompt hidden (unlisted session) |
Contributor
Author
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Co-Authored-By: João <joao@crewai.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Summary
Addresses issue #4864 — security scanners flagging
-----BEGIN PRIVATE KEY-----...in docstring examples as a hardcoded credential.Docstring fix: Replaced PEM header placeholders in
sign_agent_cardandverify_agent_card_signaturedocstring examples with<PEM-encoded private key>/<PEM-encoded public key>so they no longer trigger secret-detection tools.New tests: Added 40 tests for
agent_card_signing.py, which previously had zero test coverage. All keys are dynamically generated viacryptographyfixtures — no hardcoded secrets. Coverage includes:_normalize_private_key(bytes / str / SecretStr inputs)_serialize_agent_card(JSON validity, determinism, signature exclusion, sorted keys)_base64url_encode(padding removal, URL safety, roundtrip)sign_agent_cardwith RSA (RS256) and EC (ES256)verify_agent_card_signature(valid, wrong key, tampered card, corrupted sig, algorithm mismatch)get_key_id_from_signature(protected/unprotected header, precedence, invalid input)-----BEGIN PRIVATE KEY-----in module sourceReview & Testing Checklist for Human
-----BEGIN PRIVATE KEY-----...at line 106 was indeed only a docstring placeholder and not an actual leaked credential (it was — just a truncated example string)uv run pytest lib/crewai/tests/a2a/utils/test_agent_card_signing.py -vvto confirm all 40 tests passNotes
Note
Low Risk
Primarily adds test coverage and tweaks docstring examples; runtime behavior is unchanged, so risk is low aside from potential CI/test dependency issues.
Overview
Updates
agent_card_signing.pydocstring examples to use non-PEM placeholders (e.g.,<PEM-encoded private key>) to avoid secret scanners flagging the repository.Adds a new
test_agent_card_signing.pysuite that generates RSA/EC keys at runtime and exercises_normalize_private_key,_serialize_agent_card,_base64url_encode,sign_agent_card,verify_agent_card_signature, andget_key_id_from_signature, including negative cases (tampering, wrong key, algorithm mismatch) and a regression check that no PEM headers appear in the module source.Written by Cursor Bugbot for commit c768afd. This will update automatically on new commits. Configure here.