: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.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
fix(devex): report the admin freeze rule on the get_urls name (#130043)
Julian Bez22de30be8bda
diff --git a/.semgrep/rules/devex/no-new-custom-admin-views.py b/.semgrep/rules/devex/no-new-custom-admin-views.pyindex f6d468fb036b..926f02f61518 100644--- a/.semgrep/rules/devex/no-new-custom-admin-views.py+++ b/.semgrep/rules/devex/no-new-custom-admin-views.py@@ -23,3 +23,21 @@ urlpatterns = [# ruleid: no-new-custom-admin-viewspath("admin/tophog/", admin.site.admin_view(tophog_dashboard_view)),]+++class OrganizationAdmin(admin.ModelAdmin):+ # ruleid: no-new-custom-admin-views+ def get_urls(self):+ return [+ # A URL without admin_view still counts, because it skips Django admin's staff check.+ # ruleid: no-new-custom-admin-views+ path("<path:object_id>/report/", self.report),+ # ruleid: no-new-custom-admin-views+ re_path(r"^(?P<object_id>.+)/usage/$", self.usage),+ ] + super().get_urls()+++api_urlpatterns = [+ # ok: no-new-custom-admin-views+ path("api/projects/", projects_view),+]diff --git a/.semgrep/rules/devex/no-new-custom-admin-views.yaml b/.semgrep/rules/devex/no-new-custom-admin-views.yamlindex cddf1a59debd..6d5aa99556be 100644--- a/.semgrep/rules/devex/no-new-custom-admin-views.yaml+++ b/.semgrep/rules/devex/no-new-custom-admin-views.yaml@@ -11,9 +11,24 @@ rules:languages: [python]severity: WARNINGpattern-either:- - pattern: |- def get_urls(self, ...):- ...+ # Report the name, not the whole function, so a PR that drains URLs from a grandfathered+ # get_urls keeps the same finding instead of looking like a new one to the baseline scan.+ - patterns:+ - pattern: |+ def $FUNC(self, ...):+ ...+ - metavariable-regex:+ metavariable: $FUNC+ regex: ^get_urls$+ - focus-metavariable: $FUNC+ # Each URL entry is its own finding, so a URL added to a grandfathered get_urls is still new.+ - patterns:+ - pattern-inside: |+ def get_urls(self, ...):+ ...+ - pattern-either:+ - pattern: path(...)+ - pattern: re_path(...)- patterns:- pattern: $TEMPLATE = $VALUE- metavariable-regex: