Repository navigation
fix(contrib): HashTypeFactory.from_composite_str() raise UnknownHashTypeException for unsupported or malformed composite hashes - #1080
Conversation
…osite hashes Closes CycloneDX#1075 Signed-off-by: Vaibhav Lalwani <vaibhav4046@users.noreply.github.com>
Up to standards ✅🟢 Issues
|
| Metric | Results |
|---|---|
| Complexity | 0 |
| Duplication | 0 |
NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.
HashTypeFactory.from_composite_str() raise UnknownHashTypeException for unsupported or malformed composite hashes
|
@vaibhav4046 could you have your AI agent update the PR description according to our PR template? |
Signed-off-by: Vaibhav Lalwani <vaibhav4046@users.noreply.github.com>
|
Thanks for the review. I rewrote the change to keep it in scope: the original structure of from_composite_str is untouched. It now only adds a missing-separator check and replaces the four getattr lookups with a small helper that raises UnknownHashTypeException. The PR description now follows the template, including the AI disclosure. |
| ('blake2b256:ABC', HashAlgorithm.BLAKE2B_256), | ||
| ('blake3:ABC', HashAlgorithm.BLAKE3), | ||
| ): | ||
| with self.subTest(composite=composite): |
There was a problem hiding this comment.
please, don't use the subtest.
we use DDT here - https://ddt.readthedocs.io/en/latest/example.html
see the other test files for examples.
Description
HashTypeFactory.from_composite_str() documents UnknownHashTypeException but raised AttributeError for sha/sha3/blake2 prefixes with no matching HashAlgorithm member (for example blake2b_256, sha224) and IndexError when the colon separator is missing. Both now raise UnknownHashTypeException. Behaviour for supported prefixes is unchanged. New tests in tests/test_contrib/test_hash_factories.py fail on main and pass with the change.
Resolves or fixes issue: #1075
AI Tool Disclosure
Affirmation