Skip to content

:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.

chore: warn when a new django model takes the deprecated UUIDT key (#108214)

Daniel Marchukd391750b00df
diff --git a/.semgrep/rules/security/prefer-uuid7-django-pk.yaml b/.semgrep/rules/security/prefer-uuid7-django-pk.yaml
index da40a6221984..fb21cd8452f6 100644
--- a/.semgrep/rules/security/prefer-uuid7-django-pk.yaml
+++ b/.semgrep/rules/security/prefer-uuid7-django-pk.yaml
@@ -14,11 +14,18 @@ rules:
for `UUIDModel` and `uuid7`.
severity: WARNING
languages: [python]
- patterns:
- - pattern-either:
- - pattern: models.UUIDField(..., default=uuid.uuid4, ...)
- - pattern: models.UUIDField(..., default=uuid4, ...)
- - pattern: models.UUIDField(..., primary_key=True, ...)
+ pattern-either:
+ - patterns:
+ - pattern-either:
+ - pattern: models.UUIDField(..., default=uuid.uuid4, ...)
+ - pattern: models.UUIDField(..., default=uuid4, ...)
+ - pattern: models.UUIDField(..., primary_key=True, ...)
+ # `UUIDTModel` predates the UUIDv7 spec and its own docstring says it is not for new
+ # models. Its ids do not sort or compare as uuid7 ids do, so a value that travels between
+ # systems stops matching one written by anything newer.
+ - pattern: |
+ class $NAME(..., UUIDTModel, ...):
+ ...
paths:
include:
- '**/models.py'