fix(shacrypt): return none for unknown identifiers - #352
Conversation
NewVariant returned VariantSHA512 for any identifier it did not recognise, so the VariantNone checks relying on it could never fail. As a result Decode accepted digests from other algorithms, such as md5crypt ($1$) or bcrypt ($2b$), and treated them as SHA512 digests, and WithVariantName silently selected SHA512 for invalid names instead of returning an error. NewVariant now returns VariantNone for unknown identifiers, so Decode rejects them with ErrEncodedHashInvalidIdentifier and WithVariantName returns ErrParameterInvalid, consistent with the other algorithms. Decoding through crypt.Decoder is unaffected as only the 5 and 6 identifiers are registered.
|
Navigate logical layers of code changes, visualize relationships, and explore their blast radius. No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (2)
Included review availability: Your plan provides up to 1 included review per hour; 0 remain after this review. 📝 WalkthroughWalkthrough
ChangesSHA crypt variant validation
Priority: ➖ Normal Estimated code review effort: 2 (Simple) | ~10 minutes Change: Bug fix Merge Risk: ⚪ Minimal · up to Unsupported SHA-crypt identifiers are rejected instead of being treated as SHA-512. The supplied caller summaries and regression cases support the intended behavior, with no concrete merge risk identified. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
🧪 Generate unit tests (beta)
Warning Some tools did not complete. Review the errors below. 🔧 golangci-lint (2.13.2)Error: can't load config: unsupported version of the configuration: "" See https://golangci-lint.run/docs/product/migration-guide for migration instructions 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 |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #352 +/- ##
==========================================
+ Coverage 82.28% 82.82% +0.53%
==========================================
Files 49 49
Lines 1716 1723 +7
==========================================
+ Hits 1412 1427 +15
+ Misses 304 296 -8 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
@coderabbitai full review |
|
|
@coderabbitai full review |
✅ Action performedFull review finished. |
NewVariant returned VariantSHA512 for any identifier it did not recognise, so the VariantNone checks relying on it could never fail. As a result Decode accepted digests from other algorithms, such as md5crypt ($1$ ) or bcrypt ($2b$ ), and treated them as SHA512 digests, and WithVariantName silently selected SHA512 for invalid names instead of returning an error.
NewVariant now returns VariantNone for unknown identifiers, so Decode rejects them with ErrEncodedHashInvalidIdentifier and WithVariantName returns ErrParameterInvalid, consistent with the other algorithms. Decoding through crypt.Decoder is unaffected as only the 5 and 6 identifiers are registered.
Summary by CodeRabbit