Add Certificate Signing Request (CSR) pattern with support for flattened keys #102
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.
Adds a new pattern to detect Certificate Signing Requests (CSRs) in the RSA Keys section, with full support for both standard PEM format and flattened keys commonly found in CI/CD environments.
Changes Summary
New Files:
rsa/csr_test.csr
- Real certificate signing request sample from the issue (1151 bytes)rsa/csr_flattened.txt
- CSR with literal\n
characters (simulates .env/CI format)Modified Files:
rsa/patterns.yml
- Added new CSR pattern entryPattern Details
csr
--BEGIN CERTIFICATE REQUEST--+(\\[nr]|[\r\n])+([a-zA-Z0-9+/=\s]|\\[rn])+(\\[rn]|[\r\n])+--+END CERTIFICATE REQUEST--
Key Features
The pattern properly handles both use cases:
\r\n
or\n
)\n
or\r
found in:The pattern uses
(\\[nr]|[\r\n])+
which matches:\\[nr]
- literal backslash followed by n or r (matching the two-character sequences\n
or\r
in raw text)[\r\n]
- actual carriage return or line feed charactersPattern Validation
✓ Matches real CSR file at offsets 3-1147 (actual newlines)
✓ Matches flattened CSR at offsets 18-1180 (literal
\n
characters)✓ Matches inline test data at offsets 0-64
✓ Handles JSON format (CI/CD use case)
✓ Handles .env format (environment variables)
✓ Matches standard 5-dash format (
-----BEGIN...-----
)✓ Matches minimum 2-dash format (
--BEGIN...--
)✓ No security vulnerabilities (CodeQL scan passed)
Notes
--
prefix with+
quantifier matches 2+ dashes, correctly handling the standard 5-dash PEM formatFixes #101
Original prompt
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.