feat (Private Key Editing): Added private key format normalization#1080
feat (Private Key Editing): Added private key format normalization#1080GT-610 merged 4 commits intolollipopkit:mainfrom
Conversation
Added the _normalizePrivateKey method to normalize private key formats: - Removes whitespace characters from Base64 content - Ensures the standard format of 64 characters per line - Ensures that the private key ends with a newline character
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughAdded PEM-aware private key normalization and a Suggested reviewers
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
…rving metadata headers Properly handles metadata headers (such as Proc-Type and DEK-Info) in encrypted PEM keys and preserves these headers when cleaning up Base64 content. Additionally, optimizes the logic for removing whitespace characters and improves performance by using precompiled regular expressions.
… window caching logic - Remove unused egui::Context parameters from functions related to settings_page - Add a check for the length of items in the selection window cache to improve cache validity - Simplify the cache data structure and remove unnecessary online data validation logic
There was a problem hiding this comment.
🧹 Nitpick comments (1)
lib/view/page/private_key/edit.dart (1)
133-136: Also validate matching PEM type between BEGIN/END.Boundary format is checked, but mismatched pairs (e.g.,
BEGIN RSA+END EC) still pass this gate and get rewritten. Consider enforcing same label before mutating input.♻️ Proposed refinement
-final _pemBeginRegex = RegExp(r'^-----BEGIN [A-Z0-9 ]+-----$'); -final _pemEndRegex = RegExp(r'^-----END [A-Z0-9 ]+-----$'); +final _pemBeginRegex = RegExp(r'^-----BEGIN ([A-Z0-9 ]+)-----$'); +final _pemEndRegex = RegExp(r'^-----END ([A-Z0-9 ]+)-----$'); ... - if (!_pemBeginRegex.hasMatch(header) || !_pemEndRegex.hasMatch(footer)) { + final beginMatch = _pemBeginRegex.firstMatch(header); + final endMatch = _pemEndRegex.firstMatch(footer); + if (beginMatch == null || endMatch == null) { + return key; + } + if (beginMatch.group(1) != endMatch.group(1)) { return key; }🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@lib/view/page/private_key/edit.dart` around lines 133 - 136, The code currently only checks PEM boundary formats using _pemBeginRegex and _pemEndRegex but doesn't ensure the labels match; update the validation so after confirming both regexes match, extract the label/group from header and footer (using the capture group(s) in _pemBeginRegex/_pemEndRegex), compare them for equality, and if they differ return key without mutating; apply this check in the same function where header/footer are validated before any rewriting (referencing the header, footer, _pemBeginRegex, _pemEndRegex symbols).
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@lib/view/page/private_key/edit.dart`:
- Around line 133-136: The code currently only checks PEM boundary formats using
_pemBeginRegex and _pemEndRegex but doesn't ensure the labels match; update the
validation so after confirming both regexes match, extract the label/group from
header and footer (using the capture group(s) in _pemBeginRegex/_pemEndRegex),
compare them for equality, and if they differ return key without mutating; apply
this check in the same function where header/footer are validated before any
rewriting (referencing the header, footer, _pemBeginRegex, _pemEndRegex
symbols).
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: 630cae22-bc94-4448-9cb9-2bfe65f8d745
📒 Files selected for processing (1)
lib/view/page/private_key/edit.dart
… in PEM-format private keys Added validation for consistency of header and footer tags in PEM-format private keys to ensure that the content following “BEGIN” and “END” is identical
Resolve #910.
Added the _normalizePrivateKey method to normalize private key formats:
Summary by CodeRabbit