Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sql: anonymize schema names, owner names, and enum values #55473

Merged
merged 2 commits into from
Oct 13, 2020

Conversation

solongordon
Copy link
Contributor

@solongordon solongordon commented Oct 12, 2020

Schema and owner names were improperly being represented by strings
rather than tree.Names in the AST. This meant they would not be
properly anonymized in telemetry.

ENUM values had the same problem, but we cannot use tree.Name in
this case because we need the values to be quoted. I created a custom AST
node for this case.

Fixes #55385

Release note: None

@solongordon solongordon requested review from knz and thoszhang October 12, 2020 23:26
@cockroach-teamcity
Copy link
Member

This change is Reviewable

@solongordon
Copy link
Contributor Author

On further inspection I think ENUMs are not properly anonymized either. I'll circle back to fix that.

@thoszhang
Copy link
Contributor

I see that #55398 deals with owner names by using the newly introduced security.SQLUsername type (and I thought there were plans underway to backport part of it). Is using tree.Name an intermediate stage to fix the immediate problem?

Copy link
Contributor

@knz knz left a comment

Choose a reason for hiding this comment

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

:lgtm: This fixes the case of schema and role names very nicely. Thanks for the quick turnaround 💯

For enum values unfortunately we can't use tree.Name, because it doesn't quote properly upon pretty-printing.
However we can define a custom AST node type and add a Format() method that does the anonymization for them.

Reviewed 20 of 20 files at r1.
Reviewable status: :shipit: complete! 1 of 0 LGTMs obtained (waiting on @lucy-zhang)

@solongordon solongordon changed the title sql: anonymize schema and owner names sql: anonymize schema names, owner names, and enum values Oct 13, 2020
@solongordon
Copy link
Contributor Author

@knz I added a second commit to handle enum values. Would you please take another look?

@lucy-zhang I wasn't sure whether #55398 would be backported so I wanted to put in a simple fix for owner names. When that is merged it can replace my owner changes here.

@solongordon solongordon requested a review from knz October 13, 2020 14:06
Copy link
Contributor

@thoszhang thoszhang left a comment

Choose a reason for hiding this comment

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

Changes LGTM. Should this have formatting tests?

Reviewed 19 of 20 files at r1, 1 of 1 files at r2, 8 of 8 files at r3.
Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (and 1 stale)

@solongordon
Copy link
Contributor Author

Simple formatting has pre-existing tests in parse_test.go, but let me augment with a few tests for anonymized formatting.

@solongordon
Copy link
Contributor Author

Added anonymization tests.

Copy link
Contributor

@thoszhang thoszhang left a comment

Choose a reason for hiding this comment

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

Reviewed 9 of 9 files at r4, 9 of 9 files at r5.
Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (and 1 stale)

Schema and owner names were improperly being represented by strings
rather than `tree.Name`s in the AST. This meant they would not be
properly anonymized in telemetry.

Fixes cockroachdb#55385

Release note: None
ENUM values were improperly being represented as strings in the AST,
which meant that they were not anonymized in telemetry. I created a new
AST node type for them which respects anonymization.

Fixes cockroachdb#55385

Release note: None
@solongordon
Copy link
Contributor Author

bors r+

@craig
Copy link
Contributor

craig bot commented Oct 13, 2020

Build succeeded:

@craig craig bot merged commit a842328 into cockroachdb:master Oct 13, 2020
Copy link
Contributor

@knz knz left a comment

Choose a reason for hiding this comment

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

Reviewed 1 of 1 files at r2, 9 of 9 files at r7.
Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (and 1 stale)

@solongordon solongordon deleted the string-to-name branch October 15, 2020 12:00
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.

sql/tree: the schema names and role/user names are not properly anonymized
4 participants