: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
chore(devex): run the orphaned github-egress semgrep rule (#98123)
Julian Bezf7000b42303c
diff --git a/.semgrep/devex-rules/github-api-calls-go-through-egress.py b/.semgrep/rules/devex/github-api-calls-go-through-egress.pysimilarity index 100%rename from .semgrep/devex-rules/github-api-calls-go-through-egress.pyrename to .semgrep/rules/devex/github-api-calls-go-through-egress.pydiff --git a/.semgrep/devex-rules/github-api-calls-go-through-egress.yaml b/.semgrep/rules/devex/github-api-calls-go-through-egress.yamlsimilarity index 92%rename from .semgrep/devex-rules/github-api-calls-go-through-egress.yamlrename to .semgrep/rules/devex/github-api-calls-go-through-egress.yamlindex 0567e2221dc1..8f348958e4f0 100644--- a/.semgrep/devex-rules/github-api-calls-go-through-egress.yaml+++ b/.semgrep/rules/devex/github-api-calls-go-through-egress.yaml@@ -36,9 +36,9 @@ rules:regex: .*(api|uploads)\.github\.com.*paths:include:- - common/**/*.py- - ee/**/*.py- - posthog/**/*.py- - products/**/*.py+ - /common/**/*.py+ - /ee/**/*.py+ - /posthog/**/*.py+ - /products/**/*.pyexclude:- - posthog/egress/**+ - /posthog/egress/**diff --git a/posthog/egress/README.md b/posthog/egress/README.mdindex 0d2b1f18d309..4877be26c87e 100644--- a/posthog/egress/README.md+++ b/posthog/egress/README.md@@ -166,7 +166,8 @@ It's **token-agnostic** (installation token, user token, PAT, or PostHog's shareThe generic `EgressClient` base owns the gate → request → record algorithm and the priority-based denial semantics (CRITICAL proceeds even when the budget is spent — GitHub's own 429 is the backstop; sheddable lanes raise `EgressBudgetExhausted`); `GitHubClient` fills the domain hooks.Response handling — what to do on a 403/429 — stays with the caller: `raise_if_github_rate_limited` / `GitHubRateLimitError` (GitHub's own 429, the reactive twin of our `EgressBudgetExhausted`) live in `github/transport.py` for callers that want to raise-and-retry.The model-coupled `GitHubIntegrationBase.api_request` layers the installation-token lifecycle (proactive refresh, 401 refresh-retry, rate-limit raising, per-instance `source` attribution) on top — hold an integration, call that; hold a bare token, call `github_request`.-Raw `requests` calls against `api.github.com` are blocked by the `github-api-calls-go-through-egress` semgrep rule (`.semgrep/devex-rules/`), so new callers land on one of these two paths by construction.+The `github-api-calls-go-through-egress` semgrep rule (`.semgrep/rules/devex/`) fails CI on a raw `requests` call that names `api.github.com` in the URL argument, so a new caller written that way lands on one of these two paths.+The rule reads that argument only. A call that binds the URL to a variable first gets through, which is why `posthog/plugins/utils.py` still calls `requests.get` directly. Keep the URL inline at the call site.Firecrawl callers go through `firecrawl/client.py` rather than `firecrawl_request` directly: `scrape(url, source=...)` returns a typed `FirecrawlScrape` (markdown, summary, plus the page title, description, status code and credits used) and raises `FirecrawlScrapeFailed` when Firecrawl answers with anything but a successful scrape, including the 200 responses that carry `success: false`.Only `POST /v2/scrape` is wired up, and the client reads `FIRECRAWL_API_KEY` from settings so the transport stays token-agnostic like the others.