ci(check-file-contents): exclude OAuth scope URLs from endpoint scan#4
Merged
Merged
Conversation
The "Check for hardcoded googleapis.com endpoints" step in .github/workflows/check-file-contents.yml uses grep -lE 'https?://[a-zA-Z0-9.-]+\.googleapis\.com' to find files that should also declare an `.mtls.googleapis.com` counterpart for dynamic endpoint selection. The regex matches any googleapis.com URL — including OAuth 2.0 scope URLs like https://www.googleapis.com/auth/cloud-platform and .../auth/bigquery — which are identity strings, not API endpoints. They don't have mTLS counterparts and never will. Any file that legitimately declares an OAuth scope (very common for ADK plugins integrating Google APIs) trips the gate even when no real endpoint is hardcoded. Fix: add a second pass that filters the candidate set down to files that have at least one googleapis.com URL OUTSIDE the OAuth scope namespace (i.e. not matching `googleapis.com/auth/`). The mTLS check runs only against that filtered set. Verified against four synthesized cases: only_oauth.py (only OAuth scopes) → ignored ✓ real_endpoint.py (endpoint, no mTLS) → flagged ✓ real_endpoint_with_mtls (endpoint + mTLS) → passes ✓ mixed.py (OAuth + endpoint, no mTLS)→ flagged ✓ No effect on the surrounding `logger`, `from __future__`, or `cli` import checks. CI policy intent unchanged: real hardcoded googleapis.com endpoints still must declare their `.mtls` counterpart. Refs: - #2 (the BQAA Storage Write regional routing fix that surfaced this false positive) - GoogleCloudPlatform/BigQuery-Agent-Analytics-SDK#262
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The "Check for hardcoded googleapis.com endpoints" step in
.github/workflows/check-file-contents.ymluses```bash
grep -lE 'https?://[a-zA-Z0-9.-]+.googleapis.com'
```
to find files that should also declare an `.mtls.googleapis.com` counterpart for dynamic endpoint selection. The regex matches any `googleapis.com` URL — including OAuth 2.0 scope URLs like `https://www.googleapis.com/auth/cloud-platform\` and `.../auth/bigquery` — which are identity strings, not API endpoints. They don't have mTLS counterparts and never will. Any file that legitimately declares an OAuth scope (very common for ADK plugins integrating Google APIs) trips the gate even when no real endpoint is hardcoded.
Surfaced on #2 (the BQAA Storage Write regional routing fix): the plugin file already declares
https://www.googleapis.com/auth/bigqueryfor the BigQuery API scope. A one-line bug fix touching that file triggers the whole-file scan, which then demands a fake `.mtls.` URL be added to a place where it doesn't belong.Fix
Add a second pass that filters the candidate set down to files that have at least one `googleapis.com` URL outside the OAuth scope namespace (i.e. not matching `googleapis.com/auth/`). The mTLS check runs only against that filtered set.
Verification
Ran the patched logic against four synthesized test files locally and confirmed the truth table above. The intent of the check (real hardcoded endpoints must declare their `.mtls` counterpart) is preserved; only the false-positive case is silenced.
Scope
Workflow-only. No source-code changes. No effect on the sibling checks (logger pattern, `from future import annotations`, cli imports) — all three live in separate steps with independent regexes.
Why this is its own PR
Splitting per #2 review feedback — keep the bug fix and the workflow-policy fix on independent commits so each can be reviewed on its own merits, and so the workflow fix can land first and unblock #2 cleanly.
Refs
Test plan