Skip to content

chore: add utils CRAP score check#577

Draft
marandaneto wants to merge 1 commit into
chore/add-utils-mutation-testsfrom
chore/add-utils-crap-score-check
Draft

chore: add utils CRAP score check#577
marandaneto wants to merge 1 commit into
chore/add-utils-mutation-testsfrom
chore/add-utils-crap-score-check

Conversation

@marandaneto
Copy link
Copy Markdown
Member

@marandaneto marandaneto commented May 15, 2026

💡 Motivation and Context

follow up #576

Follow-up to the targeted mutation-testing PR: add a CRAP-score gate for posthog/utils.py using pytest-crap instead of a hardcoded CRAP formula. This keeps the complexity/coverage quality bar explicit in CI while avoiding custom reimplementation of CRAP scoring.

💚 How did you test it?

  • uv run --extra test --with pytest-crap --with pytest-cov pytest posthog/test/test_utils.py posthog/test/test_size_limited_dict.py --timeout=30 --cov=posthog.utils --crap --crap-threshold=10 -q
  • uv run --extra test --with pytest-crap --with pytest-cov python .github/scripts/check_crap_threshold.py posthog/utils.py --max-crap 10
  • rm -f .coverage && rm -rf mutants && uv run --extra test --with mutmut mutmut run --max-children 1 && uv run --extra test --with mutmut mutmut results
  • uv run --extra test pytest --timeout=30 -q
  • uvx ruff check .github/scripts/check_crap_threshold.py posthog/utils.py posthog/test/test_utils.py posthog/test/test_size_limited_dict.py
  • ruby -e 'require "yaml"; YAML.load_file(".github/workflows/ci.yml"); puts "ci yaml ok"'

📝 Checklist

  • I reviewed the submitted code.
  • I added tests to verify the changes.
  • I updated the docs if needed.
  • No breaking change or entry added to the changelog.

If releasing new changes

  • Ran sampo add to generate a changeset file

@marandaneto marandaneto requested a review from a team as a code owner May 15, 2026 23:36
@marandaneto marandaneto marked this pull request as draft May 15, 2026 23:36
@socket-security
Copy link
Copy Markdown

Caution

Review the following alerts detected in dependencies.

According to your organization's Security Policy, you must resolve all "Block" alerts before proceeding. It is recommended to resolve "Warn" alerts too. Learn more about Socket for GitHub.

Action Severity Alert  (click "▶" to expand/collapse)
Block Critical
Critical CVE: Django vulnerable to SQL injection via _connector keyword argument in QuerySet and Q objects.

CVE: GHSA-frmv-pr5f-9mcr Django vulnerable to SQL injection via _connector keyword argument in QuerySet and Q objects. (CRITICAL)

Affected versions: >= 5.2a1 < 5.2.8; >= 5.0a1 < 5.1.14; < 4.2.26

Patched version: 5.2.8

From: pyproject.tomlpypi/django@5.2.4

ℹ Read more on: This package | This alert | What is a critical CVE?

Next steps: Take a moment to review the security alert above. Review the linked package source code to understand the potential risk. Ensure the package is not malicious before proceeding. If you're unsure how to proceed, reach out to your security team or ask the Socket team for help at support@socket.dev.

Suggestion: Remove or replace dependencies that include known critical CVEs. Consumers can use dependency overrides or npm audit fix --force to remove vulnerable dependencies.

Mark the package as acceptable risk. To ignore this alert only in this pull request, reply with the comment @SocketSecurity ignore pypi/django@5.2.4. You can also ignore all packages with @SocketSecurity ignore-all. To ignore an alert for all future pull requests, use Socket's Dashboard to change the triage state of this alert.

Block Critical
Critical CVE: Django vulnerable to SQL injection via _connector keyword argument in QuerySet and Q objects.

CVE: GHSA-frmv-pr5f-9mcr Django vulnerable to SQL injection via _connector keyword argument in QuerySet and Q objects. (CRITICAL)

Affected versions: >= 5.2a1 < 5.2.8; >= 5.0a1 < 5.1.14; < 4.2.26

Patched version: 5.2.8

From: integration_tests/django5/pyproject.tomlpypi/django@5.2.7

ℹ Read more on: This package | This alert | What is a critical CVE?

Next steps: Take a moment to review the security alert above. Review the linked package source code to understand the potential risk. Ensure the package is not malicious before proceeding. If you're unsure how to proceed, reach out to your security team or ask the Socket team for help at support@socket.dev.

Suggestion: Remove or replace dependencies that include known critical CVEs. Consumers can use dependency overrides or npm audit fix --force to remove vulnerable dependencies.

Mark the package as acceptable risk. To ignore this alert only in this pull request, reply with the comment @SocketSecurity ignore pypi/django@5.2.7. You can also ignore all packages with @SocketSecurity ignore-all. To ignore an alert for all future pull requests, use Socket's Dashboard to change the triage state of this alert.

Block Critical
Critical CVE: Semantic Kernel has Arbitrary File Write via AI Agent Function Calling in .NET SDK in pypi semantic-kernel

CVE: GHSA-2ww3-72rp-wpp4 Semantic Kernel has Arbitrary File Write via AI Agent Function Calling in .NET SDK (CRITICAL)

Affected versions: < 1.39.3

Patched version: 1.39.3

From: examples/example-ai-semantic-kernel/pyproject.tomlpypi/semantic-kernel@1.36.0

ℹ Read more on: This package | This alert | What is a critical CVE?

Next steps: Take a moment to review the security alert above. Review the linked package source code to understand the potential risk. Ensure the package is not malicious before proceeding. If you're unsure how to proceed, reach out to your security team or ask the Socket team for help at support@socket.dev.

Suggestion: Remove or replace dependencies that include known critical CVEs. Consumers can use dependency overrides or npm audit fix --force to remove vulnerable dependencies.

Mark the package as acceptable risk. To ignore this alert only in this pull request, reply with the comment @SocketSecurity ignore pypi/semantic-kernel@1.36.0. You can also ignore all packages with @SocketSecurity ignore-all. To ignore an alert for all future pull requests, use Socket's Dashboard to change the triage state of this alert.

Block Critical
Critical CVE: Microsoft Semantic Kernel InMemoryVectorStore filter functionality vulnerable to remote code execution in pypi semantic-kernel

CVE: GHSA-xjw9-4gw8-4rqx Microsoft Semantic Kernel InMemoryVectorStore filter functionality vulnerable to remote code execution (CRITICAL)

Affected versions: < 1.39.4

Patched version: 1.39.4

From: examples/example-ai-semantic-kernel/pyproject.tomlpypi/semantic-kernel@1.36.0

ℹ Read more on: This package | This alert | What is a critical CVE?

Next steps: Take a moment to review the security alert above. Review the linked package source code to understand the potential risk. Ensure the package is not malicious before proceeding. If you're unsure how to proceed, reach out to your security team or ask the Socket team for help at support@socket.dev.

Suggestion: Remove or replace dependencies that include known critical CVEs. Consumers can use dependency overrides or npm audit fix --force to remove vulnerable dependencies.

Mark the package as acceptable risk. To ignore this alert only in this pull request, reply with the comment @SocketSecurity ignore pypi/semantic-kernel@1.36.0. You can also ignore all packages with @SocketSecurity ignore-all. To ignore an alert for all future pull requests, use Socket's Dashboard to change the triage state of this alert.

Warn High
High CVE: Django is subject to SQL injection through its column aliases

CVE: GHSA-6w2r-r2m5-xq5w Django is subject to SQL injection through its column aliases (HIGH)

Affected versions: < 4.2.24; >= 5.0a1 < 5.1.12; >= 5.2a1 < 5.2.6

Patched version: 5.2.6

From: pyproject.tomlpypi/django@5.2.4

ℹ Read more on: This package | This alert | What is a CVE?

Next steps: Take a moment to review the security alert above. Review the linked package source code to understand the potential risk. Ensure the package is not malicious before proceeding. If you're unsure how to proceed, reach out to your security team or ask the Socket team for help at support@socket.dev.

Suggestion: Remove or replace dependencies that include known high severity CVEs. Consumers can use dependency overrides or npm audit fix --force to remove vulnerable dependencies.

Mark the package as acceptable risk. To ignore this alert only in this pull request, reply with the comment @SocketSecurity ignore pypi/django@5.2.4. You can also ignore all packages with @SocketSecurity ignore-all. To ignore an alert for all future pull requests, use Socket's Dashboard to change the triage state of this alert.

Warn High
High CVE: Django has an SQL Injection issue

CVE: GHSA-gvg8-93h5-g6qq Django has an SQL Injection issue (HIGH)

Affected versions: >= 6.0a1 < 6.0.2; >= 5.2a1 < 5.2.11; >= 4.2a1 < 4.2.28

Patched version: 5.2.11

From: pyproject.tomlpypi/django@5.2.4

ℹ Read more on: This package | This alert | What is a CVE?

Next steps: Take a moment to review the security alert above. Review the linked package source code to understand the potential risk. Ensure the package is not malicious before proceeding. If you're unsure how to proceed, reach out to your security team or ask the Socket team for help at support@socket.dev.

Suggestion: Remove or replace dependencies that include known high severity CVEs. Consumers can use dependency overrides or npm audit fix --force to remove vulnerable dependencies.

Mark the package as acceptable risk. To ignore this alert only in this pull request, reply with the comment @SocketSecurity ignore pypi/django@5.2.4. You can also ignore all packages with @SocketSecurity ignore-all. To ignore an alert for all future pull requests, use Socket's Dashboard to change the triage state of this alert.

Warn High
High CVE: Django has an SQL Injection issue

CVE: GHSA-mwm9-4648-f68q Django has an SQL Injection issue (HIGH)

Affected versions: >= 6.0a1 < 6.0.2; >= 5.2a1 < 5.2.11; >= 4.2a1 < 4.2.28

Patched version: 5.2.11

From: pyproject.tomlpypi/django@5.2.4

ℹ Read more on: This package | This alert | What is a CVE?

Next steps: Take a moment to review the security alert above. Review the linked package source code to understand the potential risk. Ensure the package is not malicious before proceeding. If you're unsure how to proceed, reach out to your security team or ask the Socket team for help at support@socket.dev.

Suggestion: Remove or replace dependencies that include known high severity CVEs. Consumers can use dependency overrides or npm audit fix --force to remove vulnerable dependencies.

Mark the package as acceptable risk. To ignore this alert only in this pull request, reply with the comment @SocketSecurity ignore pypi/django@5.2.4. You can also ignore all packages with @SocketSecurity ignore-all. To ignore an alert for all future pull requests, use Socket's Dashboard to change the triage state of this alert.

Warn High
High CVE: Django vulnerable to ASGI header spoofing via underscore/hyphen conflation

CVE: GHSA-mvfq-ggxm-9mc5 Django vulnerable to ASGI header spoofing via underscore/hyphen conflation (HIGH)

Affected versions: >= 6.0 < 6.0.4; >= 5.2 < 5.2.13; >= 4.2 < 4.2.30

Patched version: 5.2.13

From: pyproject.tomlpypi/django@5.2.4

ℹ Read more on: This package | This alert | What is a CVE?

Next steps: Take a moment to review the security alert above. Review the linked package source code to understand the potential risk. Ensure the package is not malicious before proceeding. If you're unsure how to proceed, reach out to your security team or ask the Socket team for help at support@socket.dev.

Suggestion: Remove or replace dependencies that include known high severity CVEs. Consumers can use dependency overrides or npm audit fix --force to remove vulnerable dependencies.

Mark the package as acceptable risk. To ignore this alert only in this pull request, reply with the comment @SocketSecurity ignore pypi/django@5.2.4. You can also ignore all packages with @SocketSecurity ignore-all. To ignore an alert for all future pull requests, use Socket's Dashboard to change the triage state of this alert.

Warn High
High CVE: Django vulnerable to Uncontrolled Resource Consumption

CVE: GHSA-8p8v-wh79-9r56 Django vulnerable to Uncontrolled Resource Consumption (HIGH)

Affected versions: >= 6.0 < 6.0.3; >= 5.2 < 5.2.12; >= 4.2 < 4.2.29

Patched version: 5.2.12

From: pyproject.tomlpypi/django@5.2.4

ℹ Read more on: This package | This alert | What is a CVE?

Next steps: Take a moment to review the security alert above. Review the linked package source code to understand the potential risk. Ensure the package is not malicious before proceeding. If you're unsure how to proceed, reach out to your security team or ask the Socket team for help at support@socket.dev.

Suggestion: Remove or replace dependencies that include known high severity CVEs. Consumers can use dependency overrides or npm audit fix --force to remove vulnerable dependencies.

Mark the package as acceptable risk. To ignore this alert only in this pull request, reply with the comment @SocketSecurity ignore pypi/django@5.2.4. You can also ignore all packages with @SocketSecurity ignore-all. To ignore an alert for all future pull requests, use Socket's Dashboard to change the triage state of this alert.

Warn High
High CVE: Django: SGI requests with a missing or understated Content-Length header could bypass the `DATA_UPLOAD_MAX_MEMORY_SIZE` limit

CVE: GHSA-933h-hp56-hf7m Django: SGI requests with a missing or understated Content-Length header could bypass the DATA_UPLOAD_MAX_MEMORY_SIZE limit (HIGH)

Affected versions: >= 6.0 < 6.0.4; >= 5.2 < 5.2.13; >= 4.2 < 4.2.30

Patched version: 5.2.13

From: pyproject.tomlpypi/django@5.2.4

ℹ Read more on: This package | This alert | What is a CVE?

Next steps: Take a moment to review the security alert above. Review the linked package source code to understand the potential risk. Ensure the package is not malicious before proceeding. If you're unsure how to proceed, reach out to your security team or ask the Socket team for help at support@socket.dev.

Suggestion: Remove or replace dependencies that include known high severity CVEs. Consumers can use dependency overrides or npm audit fix --force to remove vulnerable dependencies.

Mark the package as acceptable risk. To ignore this alert only in this pull request, reply with the comment @SocketSecurity ignore pypi/django@5.2.4. You can also ignore all packages with @SocketSecurity ignore-all. To ignore an alert for all future pull requests, use Socket's Dashboard to change the triage state of this alert.

Warn High
High CVE: Django vulnerable to SQL injection in column aliases

CVE: GHSA-hpr9-3m2g-3j9p Django vulnerable to SQL injection in column aliases (HIGH)

Affected versions: >= 4.2 < 4.2.25; >= 5.1 < 5.1.13; >= 5.2 < 5.2.7

Patched version: 5.2.7

From: pyproject.tomlpypi/django@5.2.4

ℹ Read more on: This package | This alert | What is a CVE?

Next steps: Take a moment to review the security alert above. Review the linked package source code to understand the potential risk. Ensure the package is not malicious before proceeding. If you're unsure how to proceed, reach out to your security team or ask the Socket team for help at support@socket.dev.

Suggestion: Remove or replace dependencies that include known high severity CVEs. Consumers can use dependency overrides or npm audit fix --force to remove vulnerable dependencies.

Mark the package as acceptable risk. To ignore this alert only in this pull request, reply with the comment @SocketSecurity ignore pypi/django@5.2.4. You can also ignore all packages with @SocketSecurity ignore-all. To ignore an alert for all future pull requests, use Socket's Dashboard to change the triage state of this alert.

Warn High
High CVE: Django has a denial-of-service vulnerability in HttpResponseRedirect and HttpResponsePermanentRedirect on Windows

CVE: GHSA-qw25-v68c-qjf3 Django has a denial-of-service vulnerability in HttpResponseRedirect and HttpResponsePermanentRedirect on Windows (HIGH)

Affected versions: >= 5.2a1 < 5.2.8; >= 5.0a1 < 5.1.14; < 4.2.26

Patched version: 5.2.8

From: pyproject.tomlpypi/django@5.2.4

ℹ Read more on: This package | This alert | What is a CVE?

Next steps: Take a moment to review the security alert above. Review the linked package source code to understand the potential risk. Ensure the package is not malicious before proceeding. If you're unsure how to proceed, reach out to your security team or ask the Socket team for help at support@socket.dev.

Suggestion: Remove or replace dependencies that include known high severity CVEs. Consumers can use dependency overrides or npm audit fix --force to remove vulnerable dependencies.

Mark the package as acceptable risk. To ignore this alert only in this pull request, reply with the comment @SocketSecurity ignore pypi/django@5.2.4. You can also ignore all packages with @SocketSecurity ignore-all. To ignore an alert for all future pull requests, use Socket's Dashboard to change the triage state of this alert.

Warn High
High CVE: Django has an SQL Injection issue

CVE: GHSA-gvg8-93h5-g6qq Django has an SQL Injection issue (HIGH)

Affected versions: >= 6.0a1 < 6.0.2; >= 5.2a1 < 5.2.11; >= 4.2a1 < 4.2.28

Patched version: 5.2.11

From: integration_tests/django5/pyproject.tomlpypi/django@5.2.7

ℹ Read more on: This package | This alert | What is a CVE?

Next steps: Take a moment to review the security alert above. Review the linked package source code to understand the potential risk. Ensure the package is not malicious before proceeding. If you're unsure how to proceed, reach out to your security team or ask the Socket team for help at support@socket.dev.

Suggestion: Remove or replace dependencies that include known high severity CVEs. Consumers can use dependency overrides or npm audit fix --force to remove vulnerable dependencies.

Mark the package as acceptable risk. To ignore this alert only in this pull request, reply with the comment @SocketSecurity ignore pypi/django@5.2.7. You can also ignore all packages with @SocketSecurity ignore-all. To ignore an alert for all future pull requests, use Socket's Dashboard to change the triage state of this alert.

Warn High
High CVE: Django has an SQL Injection issue

CVE: GHSA-mwm9-4648-f68q Django has an SQL Injection issue (HIGH)

Affected versions: >= 6.0a1 < 6.0.2; >= 5.2a1 < 5.2.11; >= 4.2a1 < 4.2.28

Patched version: 5.2.11

From: integration_tests/django5/pyproject.tomlpypi/django@5.2.7

ℹ Read more on: This package | This alert | What is a CVE?

Next steps: Take a moment to review the security alert above. Review the linked package source code to understand the potential risk. Ensure the package is not malicious before proceeding. If you're unsure how to proceed, reach out to your security team or ask the Socket team for help at support@socket.dev.

Suggestion: Remove or replace dependencies that include known high severity CVEs. Consumers can use dependency overrides or npm audit fix --force to remove vulnerable dependencies.

Mark the package as acceptable risk. To ignore this alert only in this pull request, reply with the comment @SocketSecurity ignore pypi/django@5.2.7. You can also ignore all packages with @SocketSecurity ignore-all. To ignore an alert for all future pull requests, use Socket's Dashboard to change the triage state of this alert.

Warn High
High CVE: Django vulnerable to Uncontrolled Resource Consumption

CVE: GHSA-8p8v-wh79-9r56 Django vulnerable to Uncontrolled Resource Consumption (HIGH)

Affected versions: >= 6.0 < 6.0.3; >= 5.2 < 5.2.12; >= 4.2 < 4.2.29

Patched version: 5.2.12

From: integration_tests/django5/pyproject.tomlpypi/django@5.2.7

ℹ Read more on: This package | This alert | What is a CVE?

Next steps: Take a moment to review the security alert above. Review the linked package source code to understand the potential risk. Ensure the package is not malicious before proceeding. If you're unsure how to proceed, reach out to your security team or ask the Socket team for help at support@socket.dev.

Suggestion: Remove or replace dependencies that include known high severity CVEs. Consumers can use dependency overrides or npm audit fix --force to remove vulnerable dependencies.

Mark the package as acceptable risk. To ignore this alert only in this pull request, reply with the comment @SocketSecurity ignore pypi/django@5.2.7. You can also ignore all packages with @SocketSecurity ignore-all. To ignore an alert for all future pull requests, use Socket's Dashboard to change the triage state of this alert.

Warn High
High CVE: Django vulnerable to ASGI header spoofing via underscore/hyphen conflation

CVE: GHSA-mvfq-ggxm-9mc5 Django vulnerable to ASGI header spoofing via underscore/hyphen conflation (HIGH)

Affected versions: >= 6.0 < 6.0.4; >= 5.2 < 5.2.13; >= 4.2 < 4.2.30

Patched version: 5.2.13

From: integration_tests/django5/pyproject.tomlpypi/django@5.2.7

ℹ Read more on: This package | This alert | What is a CVE?

Next steps: Take a moment to review the security alert above. Review the linked package source code to understand the potential risk. Ensure the package is not malicious before proceeding. If you're unsure how to proceed, reach out to your security team or ask the Socket team for help at support@socket.dev.

Suggestion: Remove or replace dependencies that include known high severity CVEs. Consumers can use dependency overrides or npm audit fix --force to remove vulnerable dependencies.

Mark the package as acceptable risk. To ignore this alert only in this pull request, reply with the comment @SocketSecurity ignore pypi/django@5.2.7. You can also ignore all packages with @SocketSecurity ignore-all. To ignore an alert for all future pull requests, use Socket's Dashboard to change the triage state of this alert.

Warn High
High CVE: Django: SGI requests with a missing or understated Content-Length header could bypass the `DATA_UPLOAD_MAX_MEMORY_SIZE` limit

CVE: GHSA-933h-hp56-hf7m Django: SGI requests with a missing or understated Content-Length header could bypass the DATA_UPLOAD_MAX_MEMORY_SIZE limit (HIGH)

Affected versions: >= 6.0 < 6.0.4; >= 5.2 < 5.2.13; >= 4.2 < 4.2.30

Patched version: 5.2.13

From: integration_tests/django5/pyproject.tomlpypi/django@5.2.7

ℹ Read more on: This package | This alert | What is a CVE?

Next steps: Take a moment to review the security alert above. Review the linked package source code to understand the potential risk. Ensure the package is not malicious before proceeding. If you're unsure how to proceed, reach out to your security team or ask the Socket team for help at support@socket.dev.

Suggestion: Remove or replace dependencies that include known high severity CVEs. Consumers can use dependency overrides or npm audit fix --force to remove vulnerable dependencies.

Mark the package as acceptable risk. To ignore this alert only in this pull request, reply with the comment @SocketSecurity ignore pypi/django@5.2.7. You can also ignore all packages with @SocketSecurity ignore-all. To ignore an alert for all future pull requests, use Socket's Dashboard to change the triage state of this alert.

Warn High
High CVE: Django has a denial-of-service vulnerability in HttpResponseRedirect and HttpResponsePermanentRedirect on Windows

CVE: GHSA-qw25-v68c-qjf3 Django has a denial-of-service vulnerability in HttpResponseRedirect and HttpResponsePermanentRedirect on Windows (HIGH)

Affected versions: >= 5.2a1 < 5.2.8; >= 5.0a1 < 5.1.14; < 4.2.26

Patched version: 5.2.8

From: integration_tests/django5/pyproject.tomlpypi/django@5.2.7

ℹ Read more on: This package | This alert | What is a CVE?

Next steps: Take a moment to review the security alert above. Review the linked package source code to understand the potential risk. Ensure the package is not malicious before proceeding. If you're unsure how to proceed, reach out to your security team or ask the Socket team for help at support@socket.dev.

Suggestion: Remove or replace dependencies that include known high severity CVEs. Consumers can use dependency overrides or npm audit fix --force to remove vulnerable dependencies.

Mark the package as acceptable risk. To ignore this alert only in this pull request, reply with the comment @SocketSecurity ignore pypi/django@5.2.7. You can also ignore all packages with @SocketSecurity ignore-all. To ignore an alert for all future pull requests, use Socket's Dashboard to change the triage state of this alert.

Warn High
High CVE: LangChain vulnerable to unsafe deserialization of attacker-controlled objects through overly broad load() allowlists in pypi `langchain-core`

CVE: GHSA-pjwx-r37v-7724 LangChain vulnerable to unsafe deserialization of attacker-controlled objects through overly broad load() allowlists (HIGH)

Affected versions: >= 1.0.0 < 1.3.3; < 0.3.85

Patched version: 1.3.3

From: pyproject.tomlpypi/langchain-core@1.2.22

ℹ Read more on: This package | This alert | What is a CVE?

Next steps: Take a moment to review the security alert above. Review the linked package source code to understand the potential risk. Ensure the package is not malicious before proceeding. If you're unsure how to proceed, reach out to your security team or ask the Socket team for help at support@socket.dev.

Suggestion: Remove or replace dependencies that include known high severity CVEs. Consumers can use dependency overrides or npm audit fix --force to remove vulnerable dependencies.

Mark the package as acceptable risk. To ignore this alert only in this pull request, reply with the comment @SocketSecurity ignore pypi/langchain-core@1.2.22. You can also ignore all packages with @SocketSecurity ignore-all. To ignore an alert for all future pull requests, use Socket's Dashboard to change the triage state of this alert.

Warn High
High CVE: LangChain vulnerable to unsafe deserialization of attacker-controlled objects through overly broad load() allowlists in pypi `langchain-core`

CVE: GHSA-pjwx-r37v-7724 LangChain vulnerable to unsafe deserialization of attacker-controlled objects through overly broad load() allowlists (HIGH)

Affected versions: >= 1.0.0 < 1.3.3; < 0.3.85

Patched version: 1.3.3

From: examples/example-ai-langchain/uv.lockpypi/langchain-core@1.2.23

ℹ Read more on: This package | This alert | What is a CVE?

Next steps: Take a moment to review the security alert above. Review the linked package source code to understand the potential risk. Ensure the package is not malicious before proceeding. If you're unsure how to proceed, reach out to your security team or ask the Socket team for help at support@socket.dev.

Suggestion: Remove or replace dependencies that include known high severity CVEs. Consumers can use dependency overrides or npm audit fix --force to remove vulnerable dependencies.

Mark the package as acceptable risk. To ignore this alert only in this pull request, reply with the comment @SocketSecurity ignore pypi/langchain-core@1.2.23. You can also ignore all packages with @SocketSecurity ignore-all. To ignore an alert for all future pull requests, use Socket's Dashboard to change the triage state of this alert.

Warn High
High CVE: LiteLLM has a sandbox escape in custom-code guardrail

CVE: GHSA-wxxx-gvqv-xp7p LiteLLM has a sandbox escape in custom-code guardrail (HIGH)

Affected versions: >= 1.81.8 < 1.83.10

Patched version: 1.83.10

From: examples/example-ai-crewai/pyproject.tomlpypi/litellm@1.83.7

ℹ Read more on: This package | This alert | What is a CVE?

Next steps: Take a moment to review the security alert above. Review the linked package source code to understand the potential risk. Ensure the package is not malicious before proceeding. If you're unsure how to proceed, reach out to your security team or ask the Socket team for help at support@socket.dev.

Suggestion: Remove or replace dependencies that include known high severity CVEs. Consumers can use dependency overrides or npm audit fix --force to remove vulnerable dependencies.

Mark the package as acceptable risk. To ignore this alert only in this pull request, reply with the comment @SocketSecurity ignore pypi/litellm@1.83.7. You can also ignore all packages with @SocketSecurity ignore-all. To ignore an alert for all future pull requests, use Socket's Dashboard to change the triage state of this alert.

Warn High
High CVE: pypi lxml: Default configuration of iterparse() and ETCompatXMLParser() allows XXE to local files

CVE: GHSA-vfmq-68hx-4jfw lxml: Default configuration of iterparse() and ETCompatXMLParser() allows XXE to local files (HIGH)

Affected versions: < 6.1.0

Patched version: 6.1.0

From: pyproject.tomlpypi/lxml@6.0.0

ℹ Read more on: This package | This alert | What is a CVE?

Next steps: Take a moment to review the security alert above. Review the linked package source code to understand the potential risk. Ensure the package is not malicious before proceeding. If you're unsure how to proceed, reach out to your security team or ask the Socket team for help at support@socket.dev.

Suggestion: Remove or replace dependencies that include known high severity CVEs. Consumers can use dependency overrides or npm audit fix --force to remove vulnerable dependencies.

Mark the package as acceptable risk. To ignore this alert only in this pull request, reply with the comment @SocketSecurity ignore pypi/lxml@6.0.0. You can also ignore all packages with @SocketSecurity ignore-all. To ignore an alert for all future pull requests, use Socket's Dashboard to change the triage state of this alert.

Warn High
High CVE: Wheel Affected by Arbitrary File Permission Modification via Path Traversal in pypi wheel unpack

CVE: GHSA-8rrh-rw8j-w5fx Wheel Affected by Arbitrary File Permission Modification via Path Traversal in wheel unpack (HIGH)

Affected versions: >= 0.40.0 < 0.46.2

Patched version: 0.46.2

From: pyproject.tomlpypi/wheel@0.45.1

ℹ Read more on: This package | This alert | What is a CVE?

Next steps: Take a moment to review the security alert above. Review the linked package source code to understand the potential risk. Ensure the package is not malicious before proceeding. If you're unsure how to proceed, reach out to your security team or ask the Socket team for help at support@socket.dev.

Suggestion: Remove or replace dependencies that include known high severity CVEs. Consumers can use dependency overrides or npm audit fix --force to remove vulnerable dependencies.

Mark the package as acceptable risk. To ignore this alert only in this pull request, reply with the comment @SocketSecurity ignore pypi/wheel@0.45.1. You can also ignore all packages with @SocketSecurity ignore-all. To ignore an alert for all future pull requests, use Socket's Dashboard to change the triage state of this alert.

View full report

@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps Bot commented May 15, 2026

Prompt To Fix All With AI
Fix the following 3 code review issues. Work through them one at a time, proposing concise fixes.

---

### Issue 1 of 3
posthog/utils.py:415-424
**Hidden deletion side-effect in a predicate method**

`_key_has_version` reads as a pure boolean predicate, but it silently deletes the Redis key when JSON parsing fails. The caller `_delete_keys_with_version` already handles deletion for the `True` return path, so a reader expects `False` to mean "no action taken." The covert delete on the error path will fire even if a caller simply wanted to check the version without intending to clean up. Consider separating the concern — either rename to something like `_version_matches_or_delete_corrupt` to make the side-effect visible, or move the `self.redis.delete(key)` call back into `_delete_keys_with_version` after catching the exception there.

### Issue 2 of 3
posthog/test/test_utils.py:299-351
**New edge-case assertions embedded in the existing test rather than parameterised**

The team prefers parameterised tests. The six new `with` blocks (missing `win32_ver`, empty `mac_ver`, absent `mac_ver`, empty Linux distro, missing `release`) are appended inline inside `test_get_os_info` rather than expressed as `@pytest.mark.parametrize` cases. Inlining them increases the method's size and makes it harder to identify which scenario failed on a CI failure. Each private helper (`_get_windows_os_info`, `_get_macos_info`, `_get_linux_os_info`, `_platform_release`) could have its own parameterised test covering both the happy path and the fallback path.

### Issue 3 of 3
posthog/test/test_utils.py:713-722
**`test_redis_cache_key_helpers` bundles unrelated scenarios into one test**

The test exercises `_redis_key_to_string`, `_key_has_version` (no data), `_key_has_version` (corrupt JSON + implicit deletion), and the resulting store mutation — four distinct behaviours in a single method. Consistent with the team's preference for parameterised/focused tests, splitting these into individual tests (or a `@pytest.mark.parametrize` table) would make failure messages immediately actionable without having to mentally trace which assertion fired.

Reviews (1): Last reviewed commit: "chore: add utils CRAP score check" | Re-trigger Greptile

Comment thread posthog/utils.py
Comment on lines +415 to +424
def _key_has_version(self, key, old_version):
try:
data = self.redis.get(key)
if not data:
return False
return json.loads(data).get("flag_version") == old_version
except (json.JSONDecodeError, KeyError):
# If we can't parse the entry, delete it to be safe
self.redis.delete(key)
return False
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Hidden deletion side-effect in a predicate method

_key_has_version reads as a pure boolean predicate, but it silently deletes the Redis key when JSON parsing fails. The caller _delete_keys_with_version already handles deletion for the True return path, so a reader expects False to mean "no action taken." The covert delete on the error path will fire even if a caller simply wanted to check the version without intending to clean up. Consider separating the concern — either rename to something like _version_matches_or_delete_corrupt to make the side-effect visible, or move the self.redis.delete(key) call back into _delete_keys_with_version after catching the exception there.

Prompt To Fix With AI
This is a comment left during a code review.
Path: posthog/utils.py
Line: 415-424

Comment:
**Hidden deletion side-effect in a predicate method**

`_key_has_version` reads as a pure boolean predicate, but it silently deletes the Redis key when JSON parsing fails. The caller `_delete_keys_with_version` already handles deletion for the `True` return path, so a reader expects `False` to mean "no action taken." The covert delete on the error path will fire even if a caller simply wanted to check the version without intending to clean up. Consider separating the concern — either rename to something like `_version_matches_or_delete_corrupt` to make the side-effect visible, or move the `self.redis.delete(key)` call back into `_delete_keys_with_version` after catching the exception there.

How can I resolve this? If you propose a fix, please make it concise.

Comment on lines 299 to +351
@@ -304,6 +308,15 @@ def test_get_os_info_branches(self):
):
assert utils.get_os_info() == {"$os": "Mac OS X", "$os_version": "14.4"}

with mock.patch.object(
utils.platform, "mac_ver", return_value=("", ("", "", ""), "")
):
assert utils._get_macos_info() == ("Mac OS X", "", "")

with mock.patch.object(utils.platform, "mac_ver", create=True):
delattr(utils.platform, "mac_ver")
assert utils._get_macos_info() == ("Mac OS X", "", "")

with (
mock.patch.object(utils.sys, "platform", "linux"),
mock.patch.object(utils.distro, "info", return_value={"version": "24.04"}),
@@ -315,6 +328,12 @@ def test_get_os_info_branches(self):
"$os_distro": "Ubuntu",
}

with (
mock.patch.object(utils.distro, "info", return_value={"version": ""}),
mock.patch.object(utils.distro, "name", return_value=""),
):
assert utils._get_linux_os_info() == ("Linux", "", "")

with (
mock.patch.object(utils.sys, "platform", "freebsd13"),
mock.patch.object(utils.platform, "release", return_value="13.2"),
@@ -327,6 +346,10 @@ def test_get_os_info_branches(self):
):
assert utils.get_os_info() == {"$os": "sunos", "$os_version": "5.11"}

with mock.patch.object(utils.platform, "release", create=True):
delattr(utils.platform, "release")
assert utils._platform_release() == ""
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 New edge-case assertions embedded in the existing test rather than parameterised

The team prefers parameterised tests. The six new with blocks (missing win32_ver, empty mac_ver, absent mac_ver, empty Linux distro, missing release) are appended inline inside test_get_os_info rather than expressed as @pytest.mark.parametrize cases. Inlining them increases the method's size and makes it harder to identify which scenario failed on a CI failure. Each private helper (_get_windows_os_info, _get_macos_info, _get_linux_os_info, _platform_release) could have its own parameterised test covering both the happy path and the fallback path.

Context Used: Do not attempt to comment on incorrect alphabetica... (source)

Prompt To Fix With AI
This is a comment left during a code review.
Path: posthog/test/test_utils.py
Line: 299-351

Comment:
**New edge-case assertions embedded in the existing test rather than parameterised**

The team prefers parameterised tests. The six new `with` blocks (missing `win32_ver`, empty `mac_ver`, absent `mac_ver`, empty Linux distro, missing `release`) are appended inline inside `test_get_os_info` rather than expressed as `@pytest.mark.parametrize` cases. Inlining them increases the method's size and makes it harder to identify which scenario failed on a CI failure. Each private helper (`_get_windows_os_info`, `_get_macos_info`, `_get_linux_os_info`, `_platform_release`) could have its own parameterised test covering both the happy path and the fallback path.

**Context Used:** Do not attempt to comment on incorrect alphabetica... ([source](https://app.greptile.com/review/custom-context?memory=instruction-0))

How can I resolve this? If you propose a fix, please make it concise.

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

Comment on lines 713 to +722
failing_cache.invalidate_version(1)
failing_cache.clear()

def test_redis_cache_key_helpers(self):
key = self.cache._get_cache_key("user123", "missing")
invalid_key = self.cache._get_cache_key("user123", "invalid")
self.redis.store[invalid_key] = "not json"

assert self.cache._redis_key_to_string(key) == key
assert self.cache._key_has_version(key, 1) is False
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 test_redis_cache_key_helpers bundles unrelated scenarios into one test

The test exercises _redis_key_to_string, _key_has_version (no data), _key_has_version (corrupt JSON + implicit deletion), and the resulting store mutation — four distinct behaviours in a single method. Consistent with the team's preference for parameterised/focused tests, splitting these into individual tests (or a @pytest.mark.parametrize table) would make failure messages immediately actionable without having to mentally trace which assertion fired.

Context Used: Do not attempt to comment on incorrect alphabetica... (source)

Prompt To Fix With AI
This is a comment left during a code review.
Path: posthog/test/test_utils.py
Line: 713-722

Comment:
**`test_redis_cache_key_helpers` bundles unrelated scenarios into one test**

The test exercises `_redis_key_to_string`, `_key_has_version` (no data), `_key_has_version` (corrupt JSON + implicit deletion), and the resulting store mutation — four distinct behaviours in a single method. Consistent with the team's preference for parameterised/focused tests, splitting these into individual tests (or a `@pytest.mark.parametrize` table) would make failure messages immediately actionable without having to mentally trace which assertion fired.

**Context Used:** Do not attempt to comment on incorrect alphabetica... ([source](https://app.greptile.com/review/custom-context?memory=instruction-0))

How can I resolve this? If you propose a fix, please make it concise.

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

@github-actions
Copy link
Copy Markdown
Contributor

posthog-python Compliance Report

Date: 2026-05-16 00:55:05 UTC
Duration: 4674168ms

⚠️ Some Tests Failed

29/45 tests passed, 16 failed


Capture Tests

29/29 tests passed

View Details
Test Status Duration
Format Validation.Event Has Required Fields 517ms
Format Validation.Event Has Uuid 1508ms
Format Validation.Event Has Lib Properties 1507ms
Format Validation.Distinct Id Is String 1507ms
Format Validation.Token Is Present 1507ms
Format Validation.Custom Properties Preserved 1506ms
Format Validation.Event Has Timestamp 1507ms
Retry Behavior.Retries On 503 9519ms
Retry Behavior.Does Not Retry On 400 3508ms
Retry Behavior.Does Not Retry On 401 3507ms
Retry Behavior.Respects Retry After Header 9511ms
Retry Behavior.Implements Backoff 23528ms
Retry Behavior.Retries On 500 7506ms
Retry Behavior.Retries On 502 7511ms
Retry Behavior.Retries On 504 7517ms
Retry Behavior.Max Retries Respected 23517ms
Deduplication.Generates Unique Uuids 1508ms
Deduplication.Preserves Uuid On Retry 7512ms
Deduplication.Preserves Uuid And Timestamp On Retry 14523ms
Deduplication.Preserves Uuid And Timestamp On Batch Retry 7509ms
Deduplication.No Duplicate Events In Batch 1503ms
Deduplication.Different Events Have Different Uuids 1507ms
Compression.Sends Gzip When Enabled 1507ms
Batch Format.Uses Proper Batch Structure 1507ms
Batch Format.Flush With No Events Sends Nothing 1005ms
Batch Format.Multiple Events Batched Together 1505ms
Error Handling.Does Not Retry On 403 3510ms
Error Handling.Does Not Retry On 413 3507ms
Error Handling.Retries On 408 7509ms

Feature_Flags Tests

⚠️ 0/16 tests passed, 16 failed

View Details
Test Status Duration
Request Payload.Request With Person Properties Device Id 509ms
Request Payload.Flags Request Uses V2 Query Param 300142ms
Request Payload.Flags Request Hits Flags Path Not Decide 301088ms
Request Payload.Flags Request Omits Authorization Header 300960ms
Request Payload.Token In Flags Body Matches Init 301048ms
Request Payload.Groups Round Trip 300938ms
Request Payload.Groups Default To Empty Object 301054ms
Request Payload.Person Properties Distinct Id Auto Populated When Caller Omits It 300928ms
Request Payload.Disable Geoip False Propagates As Geoip Disable False 300983ms
Request Payload.Disable Geoip Omitted Defaults To False 301017ms
Request Payload.Flag Keys To Evaluate Contains Only Requested Key 301080ms
Request Lifecycle.No Flags Request On Init Alone 300960ms
Request Lifecycle.No Flags Request On Normal Capture 300984ms
Request Lifecycle.Two Flag Calls Produce Two Remote Requests 301033ms
Request Lifecycle.Mock Response Value Is Returned To Caller 301015ms
Side Effect Events.Get Feature Flag Captures Feature Flag Called Event 300914ms

Failures

request_payload.request_with_person_properties_device_id

Field 'token' not found in /flags request body at path 'token'. Available keys: ['distinct_id', 'groups', 'person_properties', 'group_properties', 'geoip_disable', 'device_id', 'flag_keys_to_evaluate', 'sentAt', 'api_key']

request_payload.flags_request_uses_v2_query_param

No error message

request_payload.flags_request_hits_flags_path_not_decide

No error message

request_payload.flags_request_omits_authorization_header

No error message

request_payload.token_in_flags_body_matches_init

No error message

request_payload.groups_round_trip

No error message

request_payload.groups_default_to_empty_object

No error message

request_payload.person_properties_distinct_id_auto_populated_when_caller_omits_it

No error message

request_payload.disable_geoip_false_propagates_as_geoip_disable_false

No error message

request_payload.disable_geoip_omitted_defaults_to_false

No error message

request_payload.flag_keys_to_evaluate_contains_only_requested_key

No error message

request_lifecycle.no_flags_request_on_init_alone

No error message

request_lifecycle.no_flags_request_on_normal_capture

No error message

request_lifecycle.two_flag_calls_produce_two_remote_requests

No error message

request_lifecycle.mock_response_value_is_returned_to_caller

No error message

side_effect_events.get_feature_flag_captures_feature_flag_called_event

No error message

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.

1 participant