Skip to content

Finish #294: value sampling, validators, Spanish names, corpus, roles, threat model - #315

Merged
jmmana merged 3 commits into
mainfrom
feat/data-classes-rest
Dec 3, 2026
Merged

jmmana merged 3 commits into
mainfrom
feat/data-classes-rest

Conversation

@jmmana

@jmmana jmmana commented Dec 3, 2026 •

Copy link
Copy Markdown
Owner

Closes #294.

Everything left in #294 after #309 (classes) and #313 (explanations, protocol and clients).

What it adds

  • classify --sample N (1–1000, off by default): also checks up to N values per column with an email shape, Luhn (cards), CURP, RFC, US SSN, the CLABE check digit and the IBAN mod-97. A class is proposed when ≥80% of at least 3 sampled values pass. Each proposal says whether name, values or both support it, so network_docs.rfc_number shows as name only (values did not confirm it) and customers.contact is found as values only.
  • Safety, each tested: no statement touches a data table without --sample; one SELECT … WHERE col IS NOT NULL LIMIT N per column, never more than 1000 values (the CLI rejects more, and the function clips as a second defence) and 500 columns; the transaction is read-only (PRAGMA query_only on SQLite is verified to block an INSERT; PostgreSQL and MySQL also set a 5 s timeout) and rolled back; sampled values are never printed, in YAML or JSON; columns the --policy already decides are not sampled.
  • Spanish and Mexican names (tarjeta, numero_cuenta, pasaporte, imss…). Found by the tests: Spanish puts the descriptive word first (tipo_tarjeta, estado_tarjeta, fecha_curp), so the rule that only looked at the last word flagged them; fixed and tested.
  • 130 corpus cases (tests/corpus/data_classes.yaml) for every class action in PostgreSQL, MySQL, T-SQL, SQLite and Snowflake: alias, LOWER, CONCAT, CAST, COALESCE, CASE, window, CTE, UNION, and leaks through WHERE, GROUP BY, ORDER BY and JOIN. Their expectations come from the explicit-policy equivalent, which the generator asserts is identical to the class policy. conformance/cases.json is regenerated, so the Node.js (66) and .NET (67) conformance suites run them too, locally green.
  • Per-role overrides in policy sets already worked; they are now tested (add: to change a class action, a role replacing the classes) and the docs warn that a role setting column_classes replaces the inherited ones.
  • Threat model row for sensitive data the policy does not name, and the guide (EN/ES) states what sampling can and cannot see.
  • Docs correction for Exclude active red-team modules from default CI #308. docs/REDTEAM.md (EN/ES) said the dbhub test runs in CI. The owner excluded the active red-team modules from default CI in Exclude active red-team modules from default CI #308 (a decision I respect and did not touch), so the docs now say how to run it by naming the file.

Tested

New tests in tests/test_data_classes.py (validators, thresholds, Spanish names with false positives, the five sampling guarantees, role overrides) plus the corpus. Full suite, ruff, mypy and a strict docs build pass locally, as do the Node.js and .NET conformance suites. tests/engines/test_classify_engines.py runs the sampler on a real PostgreSQL (checked locally on PostgreSQL 17 and in the Engines job): values are classified, transaction_read_only is on, statement_timeout is 5 s, a DELETE is refused and the CLI prints no value or password.

Not done

  • The MySQL read-only and timeout statements are not run against a real server (PostgreSQL and SQLite are).
  • Phone numbers and credentials have no value check (too ambiguous); they stay name-only, and the docs say so.

🤖 Generated with Claude Code

…, threat model

classify --sample N checks bounded, read-only samples of values (never printed) with
email, Luhn, CURP, RFC, SSN, CLABE and IBAN checks. 130 corpus cases pin each class
action in five dialects, role overrides are tested, and docs are corrected for #308.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Copilot AI balanced review requested due to automatic review settings December 3, 2026 16:40

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

jmmana and others added 2 commits December 3, 2026 11:41
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@jmmana
jmmana merged commit d563d89 into main Dec 3, 2026
31 checks passed
@jmmana
jmmana deleted the feat/data-classes-rest branch December 3, 2026 18:38
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.

FEAT-015 — Sensitive data classes: classify columns once, enforce by class

2 participants