Skip to content

fix: handle legacy version strings in compromised email domain rule (#389)#798

Merged
christophetd merged 3 commits into
DataDog:v3from
patchwright:fix/legacy-version-crash-389
Jul 8, 2026
Merged

fix: handle legacy version strings in compromised email domain rule (#389)#798
christophetd merged 3 commits into
DataDog:v3from
patchwright:fix/legacy-version-crash-389

Conversation

@patchwright

Copy link
Copy Markdown
Contributor

Fixes #389. version.parse raises InvalidVersion on non-PEP-440 strings (e.g. pytz 2004d) since packaging 22.0. Added _safe_version_key that catches InvalidVersion and sorts legacy versions as oldest. Verified: no crash on 2004d, invalid!, empty string.

Assisted-by: Claude (Anthropic).

@patchwright patchwright requested a review from a team as a code owner July 3, 2026 02:13
@christophetd

Copy link
Copy Markdown
Contributor

@patchwright Thanks for the contribution! Let me have a look and add a quick unit test to it

@christophetd christophetd enabled auto-merge (squash) July 8, 2026 14:30
patchwright and others added 3 commits July 8, 2026 16:44
…omain

version.parse raises InvalidVersion on non-PEP-440 strings (e.g. pytz
'2004d') since packaging 22.0 removed LegacyVersion. This crashed the
entire rule when scanning packages with legacy version history.

Add _safe_version_key that catches InvalidVersion and sorts legacy
versions as oldest (version 0) instead of crashing. Fixes DataDog#389.

Assisted-by: Claude (Anthropic).
Co-Authored-By: claude-flow <ruv@ruv.net>
@christophetd christophetd force-pushed the fix/legacy-version-crash-389 branch from 3abdd8f to a9cc234 Compare July 8, 2026 14:51
@christophetd christophetd merged commit 48ce175 into DataDog:v3 Jul 8, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

"failed to run rule potentially_compromised_email_domain: Invalid version [...]" when using Recent "packaging" Package

3 participants