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.

1.4 KB
Raw Blame
rules:
    - id: facade-views-read-object-not-dangerously-get-object
      message: |
          `dangerously_get_object()` skips the object permission checks of `TeamAndOrgViewSetMixin`,
          so each override has to call `check_object_permissions` itself, and nothing makes it adapt
          a facade contract for `AccessControlPermission`.

          A view that reads through a facade overrides `read_object()` instead. The mixin's
          `get_object()` then runs the object permission checks on the record and returns it. Also
          define `object_access_ref(record)` to return the record's `ObjectAccessRef`, or set
          `records_have_object_access_rules = False` when no access rule can name one record.
          See "Who owns RBAC?" in `products/architecture.md`.
      severity: ERROR
      languages: [python]
      paths:
          include:
              - 'products/**'
          exclude:
              - '**/test/**'
              - '**/tests/**'
              - '**/test_*.py'
              - '**/*_test.py'
              # Workflow templates are INTERNAL to access control, and their own permission class
              # reads the template's scope from the returned object.
              - 'products/workflows/backend/presentation/views/hog_flow_template.py'
      patterns:
          - pattern: |
                def dangerously_get_object(...):
                    ...
      metadata:
          category: best-practice