Add sensitive-data-flow check - #9863
Conversation
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
3450dd8 to
6a2399e
Compare
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
A changed query reads restricted / workgroup-gated data and writes it to a more broadly readable destination that no team owns: This is advisory and does not block merge. |
…uest is best-effort (Actions token can't request org teams)
There was a problem hiding this comment.
Adds bigquery_etl/sensitivity.py, a ./bqetl data_governance sensitivity command, a sensitivity: config block in bqetl_project.yaml describing stable/live ACLs, and a flag-sensitive-flows CI job that requests @mozilla/dataplatform-wg review and comments when a changed query.sql reads gated data and writes somewhere broader. The check is advisory (exit 2, never blocking) and the module has good unit-test coverage across access resolution, gated-dataset lookup, CODEOWNERS matching, and the CLI.
Two things stand out. First, DatasetAccess.sensitive treats an empty reader set as non-sensitive, so every gated_datasets entry written as [] — search_terms, search_terms_derived, account_ecosystem, xfocsp_error_report, client_deduplication — is silently exempt from the check. Second, the CI job reads github.event.pull_request directly, so it does nothing on the workflow_run path that fork PRs take; the workflow already has resolve-pr-base and Determine context solving exactly this. The two sensitivity_ci_probe_* query directories are marked "delete before merge" and still present.
The remaining comments are smaller: silent exception swallowing in check_query, duplicate PR comments on each push, the cost of the new ready_for_review trigger, and two minor cleanups.
|
A changed query reads restricted / workgroup-gated data and writes it to a more broadly readable destination that no team owns: This is advisory and does not block merge. |
…t de-dup, log unanalyzable queries, CODEOWNERS relpath + compile-once
This comment has been minimized.
This comment has been minimized.
| # Datasets/tables whose read access is narrower than the broad_readers above. | ||
| # Omitted/empty means restricted (no broad read access). | ||
| gated_datasets: | ||
| moz-fx-data-shared-prod: |
There was a problem hiding this comment.
suggestion(non-blocking): I think this is fine for a first pass but this will likely become stale. It would be easy to parse the ingestion table permissions from the json file if it wasn't in a private repo. I think that would be better but doesn't need to be solved right now
|
|
||
|
|
||
| # roles that grant the ability to read row-level data | ||
| READ_ROLES = set(_config("read_roles", ["roles/bigquery.dataViewer"])) |
There was a problem hiding this comment.
Not widely used in bigquery-etl, but roles/bigquery.dataEditor would also be a reader role. Probably doesn't change the outcome of this though
Co-authored-by: Ben Wu <12437227+BenWu@users.noreply.github.com>
This comment has been minimized.
This comment has been minimized.
Integration report
|
Description
Related to https://docs.google.com/document/d/1KhWaH-o7EDG1PaOR7JKrGWyP8hmdtodCQRino-PKbA0/edit?tab=t.0
This PR adds a CI step that flags queries that read restricted/workgroup-gated data and write it to a more broadly readable destination the source's readers don't already cover. It's advisory and non-blocking: on an ungated flow, CI flags @mozilla/dataplatform-wg in a PR comment rather than failing (#9863 (comment)).
Marking the team for review isn't currently working with the PAT.
This is a guardrail to prevent users accidentally making restricted data more widely available. I think this could be good to have as we provide write access to this to all of Mozilla. (but open to discussion/feedback)
dataset_metadata.yamlbqetl_project.yaml./bqetl data_governance sensitivity <paths>and CI runs it over changed query.sql files.Reviewer, please follow this checklist