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

*: improve redaction #65453

Closed
tbg opened this issue May 19, 2021 · 4 comments
Closed

*: improve redaction #65453

tbg opened this issue May 19, 2021 · 4 comments
Labels
A-cc-enablement Pertains to current CC production issues or short-term projects A-logging In and around the logging infrastructure. C-bug Code not up to spec/doc, specs & docs deemed correct. Solution expected to change code/behavior. N-followup Needs followup. O-postmortem Originated from a Postmortem action item. X-server-triaged-202105

Comments

@tbg
Copy link
Member

tbg commented May 19, 2021

Describe the problem

On customer incidents, we regularly struggle with redacted logs which typically

To Reproduce

Pick any CockroachCloud Zendesk ticket, download the debug zip, and see for yourself.

Expected behavior

Redaction, to the extent that is reasonable, leaves non-PII untouched and allows redacted and unredacted logs to be used more or less interchangeably. In particular, keys could be redacted smartly, by preserving the /Table/descid/idxid part and at least printing the types for everything else (/Table/55/3/<int>/<string>#0 for example.

Lints would make redactability opt-out (a change from today's opt-in), that is, a linter would ensure that any new type added implements redactability. This is not true today. I also believe there are a few ways in which implementing redactability could be simplified, such as cockroachdb/redact#5.

There would clearly need to be some transition, such as adding the linting code but instead of ensuring the absence of non-redactable structs, we'd assert that the number of violations does not increase. This also provides a rough score of how well we are doing in terms of redactability.

Additional data / screenshots

Environment:

Additional context

The below issues deal with aspects of redactability across CRDB:

#58610
#53310
#55862
#50044
#50043

Epic: CRDB-6668

Jira issue: CRDB-7612

@tbg tbg added C-bug Code not up to spec/doc, specs & docs deemed correct. Solution expected to change code/behavior. O-postmortem Originated from a Postmortem action item. labels May 19, 2021
@knz knz added the T-server-and-security DB Server & Security label May 31, 2021
@tbg
Copy link
Member Author

tbg commented Jun 4, 2021

Wasn't able to post this on Wednesday due to GH outage, but here it is:

level 👶🏽:  implement redact.SafeFormatter on one or more simple structs that shows up as redacted during ./cockroach start --logtostderr, following the example, for example, here.
level 🏊🏽:  implement redact.SafeFormatter for roachpb.Key.
level ️🌶️: cockroachdb/redact#5 I think this would be super valuable before we even think about nudging all teams to whittle down their redaction numbers.
level 🌶️: implement the linter above. Some design work upfront would be needed here, but the lint passes in ./pkg/lint/passes are probably a good starting point. We could traverse the syntax trees and to investigate everything that is passed to a logging method (to see whether it implements redactability), but that may be incomplete (redaction might be important outside of logging). The easier, and perhaps also more helpful option, is to check all the types declared by cockroach code (i.e. inside of our repo and not in vendor) directly for whether the implement redaction. To get the linter in without having to boil the ocean, we allow exceptions (type foo struct {} // nomustredact) which would be implemented similar to here or here - I prefer the latter since I understand it; the former seems to misfire sometimes. We want two lint exceptions, nomustredact, and todomustredact. The idea is that to get the lint to pass, we add // todomustredact everywhere and count how many we added. We configure the linter to allow no more than that number of todomustredact tags, and also output the current number. This gives us a metric that we can optimize, and an easy way to find all the types that still need to be retrofitted. Thanks to code ownership (go run ./pkg/cmd/whoownsit), we could break that down on a per-team level as well (i.e. team that owns the file that declares the type owns the redactability of the type), for scheduling this work into the next release.

I bet @knz has ideas on the above and other ideas as well.

With proper mentorship, I think all of the above are suitable for an intern as while of varying complexity, the work is at the library level with clear dependencies + docs, and not a ton of prior context is necessary.

@dhartunian
Copy link
Collaborator

dhartunian commented Jun 7, 2021

@knz
Copy link
Contributor

knz commented Jun 19, 2021

I'm doing the struct and array auto-redaction in cockroachdb/redact#19
Once this is in, the work for the first two points might be slightly simplified: we won't need to implement SafeFormat methods for structs when the "natural" struct representation is sufficient.

@knz knz added A-logging In and around the logging infrastructure. A-cc-enablement Pertains to current CC production issues or short-term projects labels Jul 29, 2021
@jlinder jlinder unassigned kzh Mar 2, 2022
@exalate-issue-sync exalate-issue-sync bot removed the T-server-and-security DB Server & Security label Feb 17, 2023
@tbg tbg closed this as completed Feb 17, 2023
@tbg
Copy link
Member Author

tbg commented Feb 17, 2023

This umbrella issue has outlived its purpose, closing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-cc-enablement Pertains to current CC production issues or short-term projects A-logging In and around the logging infrastructure. C-bug Code not up to spec/doc, specs & docs deemed correct. Solution expected to change code/behavior. N-followup Needs followup. O-postmortem Originated from a Postmortem action item. X-server-triaged-202105
Projects
None yet
Development

No branches or pull requests

5 participants