You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@kudu.apache.org by "Todd Lipcon (Code Review)" <ge...@cloudera.org> on 2016/12/21 11:04:29 UTC

[kudu-CR] WIP: KUDU-1812. Redaction using thread-local boolean approach

Hello Dan Burkert, Adar Dembo,

I'd like you to do a code review.  Please visit

    http://gerrit.cloudera.org:8080/5557

to review the following change.

Change subject: WIP: KUDU-1812. Redaction using thread-local boolean approach
......................................................................

WIP: KUDU-1812. Redaction using thread-local boolean approach

This takes a different approach to redaction compared to
https://gerrit.cloudera.org/#/c/5555/2 as follows:

- there's a new thread-local boolean which indicates whether ToString
  functions should redact user data in the current thread. This defaults
  to 'true', but it is always also combined with the configuration flag
  to determine whether redaction will actually happen.

- A utility macro KUDU_DISABLE_REDACTION(...) can disable redaction
  while evaluating a particular expression or block, useful in contexts
  such as the web UI or tools where we don't want to redact.

- Like the other patch, a macro KUDU_REDACT(expr) replaces its argument
  with '<redacted>' if redaction is enabled.

The main advantages of this approach is that we're now able to apply
KUDU_REDACT() at a very low level (the stringification functions in
types.cc which are used for stringifying all user data). This means that
we are by-default redacted anywhere that stringifies a row, rather than
having to look for all cases that may lead to this stringification.
Instead, we only have to find the places that explicitly want to disable
redaction, which should be the exception rather than the rule.

This patch is likely incomplete: there are probably some more tests that
need to inherit from KuduTest in order to gain the "disable redaction by
default in tests" behavior. Additionally, there are probably a few more
non-test code paths that need to have redaction disabled. But, I wanted
to post this for an early review on the approach.

In addition, there are a few cases where we log various buffers that may
encode user data. Dan's patch covered many of those, but this one
doesn't. If we decide to go this direction, we'll need to port over
those KUDU_REDACT calls from his patch.

Change-Id: I75392ae36e96c1742e478e82671fd1eac3a0edee
---
M src/kudu/common/column_predicate-test.cc
M src/kudu/common/partition-test.cc
M src/kudu/common/partition.cc
M src/kudu/common/partition.h
M src/kudu/common/scan_spec-test.cc
M src/kudu/common/schema-test.cc
M src/kudu/common/types.cc
M src/kudu/integration-tests/external_mini_cluster.cc
M src/kudu/util/flag_tags-test.cc
M src/kudu/util/logging-test.cc
M src/kudu/util/logging.cc
M src/kudu/util/logging.h
M src/kudu/util/test_util.cc
13 files changed, 187 insertions(+), 22 deletions(-)


  git pull ssh://gerrit.cloudera.org:29418/kudu refs/changes/57/5557/1
-- 
To view, visit http://gerrit.cloudera.org:8080/5557
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I75392ae36e96c1742e478e82671fd1eac3a0edee
Gerrit-PatchSet: 1
Gerrit-Project: kudu
Gerrit-Branch: master
Gerrit-Owner: Todd Lipcon <to...@apache.org>
Gerrit-Reviewer: Adar Dembo <ad...@cloudera.com>
Gerrit-Reviewer: Dan Burkert <da...@apache.org>

[kudu-CR] WIP: KUDU-1812. Redaction using thread-local boolean approach

Posted by "Adar Dembo (Code Review)" <ge...@cloudera.org>.
Adar Dembo has posted comments on this change.

Change subject: WIP: KUDU-1812. Redaction using thread-local boolean approach
......................................................................


Patch Set 2:

(5 comments)

http://gerrit.cloudera.org:8080/#/c/5557/2/src/kudu/common/column_predicate-test.cc
File src/kudu/common/column_predicate-test.cc:

Line 1012:   ASSERT_EQ("`a` = <redacted>", ColumnPredicate::Equality(column_i32, &one_32).ToString());
I believe Dan's approach redacts the operator of the predicate as well as the predicate values, but IIRC, this was done for expediency, not because the operator is considered sensitive.

Just wanted to point that out.


http://gerrit.cloudera.org:8080/#/c/5557/2/src/kudu/util/flags-test.cc
File src/kudu/util/flags-test.cc:

Line 45:     // command line flags and fails if an unsafe flag is set.
Nit: or experimental


http://gerrit.cloudera.org:8080/#/c/5557/2/src/kudu/util/logging.cc
File src/kudu/util/logging.cc:

Line 68: TAG_FLAG(log_redact_user_data, experimental);
Why experimental?


Line 82: __thread bool tls_redact_user_data = true;
Would be nice to add a comment here justifying the default policy.


http://gerrit.cloudera.org:8080/#/c/5557/2/src/kudu/util/logging.h
File src/kudu/util/logging.h:

Line 78: class ScopedDisableRedaction {
I think it'd be nice to also enforce that there aren't nested calls to KUDU_DISABLE_REDACTION().


-- 
To view, visit http://gerrit.cloudera.org:8080/5557
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-MessageType: comment
Gerrit-Change-Id: I75392ae36e96c1742e478e82671fd1eac3a0edee
Gerrit-PatchSet: 2
Gerrit-Project: kudu
Gerrit-Branch: master
Gerrit-Owner: Todd Lipcon <to...@apache.org>
Gerrit-Reviewer: Adar Dembo <ad...@cloudera.com>
Gerrit-Reviewer: Dan Burkert <da...@apache.org>
Gerrit-Reviewer: Kudu Jenkins
Gerrit-Reviewer: Tidy Bot
Gerrit-HasComments: Yes

[kudu-CR] WIP: KUDU-1812. Redaction using thread-local boolean approach

Posted by "Dan Burkert (Code Review)" <ge...@cloudera.org>.
Dan Burkert has posted comments on this change.

Change subject: WIP: KUDU-1812. Redaction using thread-local boolean approach
......................................................................


Patch Set 2:

(4 comments)

http://gerrit.cloudera.org:8080/#/c/5557/2/src/kudu/util/flags-test.cc
File src/kudu/util/flags-test.cc:

Line 45:     // command line flags and fails if an unsafe flag is set.
> Nit: or experimental
Done


http://gerrit.cloudera.org:8080/#/c/5557/2/src/kudu/util/logging.cc
File src/kudu/util/logging.cc:

Line 68: TAG_FLAG(log_redact_user_data, experimental);
> Why experimental?
I think it's a wise policy for all new flags to start out as experimental.


Line 82: __thread bool tls_redact_user_data = true;
> Would be nice to add a comment here justifying the default policy.
Done


http://gerrit.cloudera.org:8080/#/c/5557/2/src/kudu/util/logging.h
File src/kudu/util/logging.h:

Line 78: class ScopedDisableRedaction {
> I think it'd be nice to also enforce that there aren't nested calls to KUDU
That's a valid scenario - for instance the web UI calling into a partition schema pretty printer.


-- 
To view, visit http://gerrit.cloudera.org:8080/5557
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-MessageType: comment
Gerrit-Change-Id: I75392ae36e96c1742e478e82671fd1eac3a0edee
Gerrit-PatchSet: 2
Gerrit-Project: kudu
Gerrit-Branch: master
Gerrit-Owner: Todd Lipcon <to...@apache.org>
Gerrit-Reviewer: Adar Dembo <ad...@cloudera.com>
Gerrit-Reviewer: Dan Burkert <da...@apache.org>
Gerrit-Reviewer: Kudu Jenkins
Gerrit-Reviewer: Tidy Bot
Gerrit-HasComments: Yes

[kudu-CR] WIP: KUDU-1812. Redaction using thread-local boolean approach

Posted by "Dan Burkert (Code Review)" <ge...@cloudera.org>.
Dan Burkert has posted comments on this change.

Change subject: WIP: KUDU-1812. Redaction using thread-local boolean approach
......................................................................


Patch Set 2:

(1 comment)

http://gerrit.cloudera.org:8080/#/c/5557/2/src/kudu/common/column_predicate-test.cc
File src/kudu/common/column_predicate-test.cc:

Line 1012:   ASSERT_EQ("`a` = <redacted>", ColumnPredicate::Equality(column_i32, &one_32).ToString());
> I believe Dan's approach redacts the operator of the predicate as well as t
I wasn't sure, so erred on the side of over-redaction.  If exposing the operator is fine, let's keep it as is.


-- 
To view, visit http://gerrit.cloudera.org:8080/5557
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-MessageType: comment
Gerrit-Change-Id: I75392ae36e96c1742e478e82671fd1eac3a0edee
Gerrit-PatchSet: 2
Gerrit-Project: kudu
Gerrit-Branch: master
Gerrit-Owner: Todd Lipcon <to...@apache.org>
Gerrit-Reviewer: Adar Dembo <ad...@cloudera.com>
Gerrit-Reviewer: Dan Burkert <da...@apache.org>
Gerrit-Reviewer: Kudu Jenkins
Gerrit-Reviewer: Tidy Bot
Gerrit-HasComments: Yes

[kudu-CR] WIP: KUDU-1812. Redaction using thread-local boolean approach

Posted by "Todd Lipcon (Code Review)" <ge...@cloudera.org>.
Hello Dan Burkert, Adar Dembo, Kudu Jenkins,

I'd like you to reexamine a change.  Please visit

    http://gerrit.cloudera.org:8080/5557

to look at the new patch set (#2).

Change subject: WIP: KUDU-1812. Redaction using thread-local boolean approach
......................................................................

WIP: KUDU-1812. Redaction using thread-local boolean approach

This takes a different approach to redaction compared to
https://gerrit.cloudera.org/#/c/5555/2 as follows:

- there's a new thread-local boolean which indicates whether ToString
  functions should redact user data in the current thread. This defaults
  to 'true', but it is always also combined with the configuration flag
  to determine whether redaction will actually happen.

- A utility macro KUDU_DISABLE_REDACTION(...) can disable redaction
  while evaluating a particular expression or block, useful in contexts
  such as the web UI or tools where we don't want to redact.

- Like the other patch, a macro KUDU_REDACT(expr) replaces its argument
  with '<redacted>' if redaction is enabled.

The main advantages of this approach is that we're now able to apply
KUDU_REDACT() at a very low level (the stringification functions in
types.cc which are used for stringifying all user data). This means that
we are by-default redacted anywhere that stringifies a row, rather than
having to look for all cases that may lead to this stringification.
Instead, we only have to find the places that explicitly want to disable
redaction, which should be the exception rather than the rule.

This patch is likely incomplete: there are probably some more tests that
need to inherit from KuduTest in order to gain the "disable redaction by
default in tests" behavior. Additionally, there are probably a few more
non-test code paths that need to have redaction disabled. But, I wanted
to post this for an early review on the approach.

In addition, there are a few cases where we log various buffers that may
encode user data. Dan's patch covered many of those, but this one
doesn't. If we decide to go this direction, we'll need to port over
those KUDU_REDACT calls from his patch.

Change-Id: I75392ae36e96c1742e478e82671fd1eac3a0edee
---
M src/kudu/client/batcher.cc
M src/kudu/client/client.cc
M src/kudu/client/client.h
M src/kudu/client/scanner-internal.h
M src/kudu/client/session-internal.cc
M src/kudu/client/write_op.h
M src/kudu/common/column_predicate-test.cc
M src/kudu/common/partial_row.cc
M src/kudu/common/partial_row.h
M src/kudu/common/partition-test.cc
M src/kudu/common/partition.cc
M src/kudu/common/partition.h
M src/kudu/common/row_operations.h
M src/kudu/common/scan_spec-test.cc
M src/kudu/common/schema-test.cc
M src/kudu/common/types-test.cc
M src/kudu/common/types.cc
M src/kudu/integration-tests/external_mini_cluster.cc
M src/kudu/tools/tool_main.cc
M src/kudu/util/flag_tags-test.cc
M src/kudu/util/flags-test.cc
M src/kudu/util/logging-test.cc
M src/kudu/util/logging.cc
M src/kudu/util/logging.h
M src/kudu/util/test_util.cc
25 files changed, 245 insertions(+), 54 deletions(-)


  git pull ssh://gerrit.cloudera.org:29418/kudu refs/changes/57/5557/2
-- 
To view, visit http://gerrit.cloudera.org:8080/5557
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-MessageType: newpatchset
Gerrit-Change-Id: I75392ae36e96c1742e478e82671fd1eac3a0edee
Gerrit-PatchSet: 2
Gerrit-Project: kudu
Gerrit-Branch: master
Gerrit-Owner: Todd Lipcon <to...@apache.org>
Gerrit-Reviewer: Adar Dembo <ad...@cloudera.com>
Gerrit-Reviewer: Dan Burkert <da...@apache.org>
Gerrit-Reviewer: Kudu Jenkins
Gerrit-Reviewer: Tidy Bot

[kudu-CR] WIP: KUDU-1812. Redaction using thread-local boolean approach

Posted by "Dan Burkert (Code Review)" <ge...@cloudera.org>.
Dan Burkert has abandoned this change.

Change subject: WIP: KUDU-1812. Redaction using thread-local boolean approach
......................................................................


Abandoned

This has been rolled into https://gerrit.cloudera.org/#/c/5555.

-- 
To view, visit http://gerrit.cloudera.org:8080/5557
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-MessageType: abandon
Gerrit-Change-Id: I75392ae36e96c1742e478e82671fd1eac3a0edee
Gerrit-PatchSet: 2
Gerrit-Project: kudu
Gerrit-Branch: master
Gerrit-Owner: Todd Lipcon <to...@apache.org>
Gerrit-Reviewer: Adar Dembo <ad...@cloudera.com>
Gerrit-Reviewer: Dan Burkert <da...@apache.org>
Gerrit-Reviewer: Kudu Jenkins
Gerrit-Reviewer: Tidy Bot