-
Notifications
You must be signed in to change notification settings - Fork 1.5k
add broker config options for sql log redaction #18430
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
base: master
Are you sure you want to change the base?
Changes from 3 commits
99ace8d
7c899e9
cf497a0
77c9c84
871a7e2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -188,8 +188,15 @@ public BaseSingleStageBrokerRequestHandler(PinotConfiguration config, String bro | |
|
|
||
| _enableMultistageMigrationMetric = _config.getProperty(Broker.CONFIG_OF_BROKER_ENABLE_MULTISTAGE_MIGRATION_METRIC, | ||
| Broker.DEFAULT_ENABLE_MULTISTAGE_MIGRATION_METRIC); | ||
| _enableQueryFingerprinting = _config.getProperty(Broker.CONFIG_OF_BROKER_ENABLE_QUERY_FINGERPRINTING, | ||
| boolean fingerprintingConfigured = _config.getProperty(Broker.CONFIG_OF_BROKER_ENABLE_QUERY_FINGERPRINTING, | ||
| Broker.DEFAULT_BROKER_ENABLE_QUERY_FINGERPRINTING); | ||
| boolean redactionNeedsFingerprinting = | ||
| _queryLogger.getSqlRedactionMode() == QueryLogger.SqlRedactionMode.LITERAL_VALUES; | ||
| if (redactionNeedsFingerprinting && !fingerprintingConfigured) { | ||
| LOGGER.warn("SQL redaction mode 'literal_values' requires query fingerprinting. " | ||
| + "Enabling query fingerprinting automatically."); | ||
| } | ||
| _enableQueryFingerprinting = fingerprintingConfigured || redactionNeedsFingerprinting; | ||
| if (_enableMultistageMigrationMetric) { | ||
| _multistageCompileExecutor = Executors.newSingleThreadExecutor(); | ||
| _multistageCompileQueryQueue = new LinkedBlockingQueue<>(1000); | ||
|
|
@@ -317,12 +324,11 @@ protected BrokerResponse handleRequest(long requestId, String query, SqlNodeAndO | |
| JsonNode request, @Nullable RequesterIdentity requesterIdentity, RequestContext requestContext, | ||
| @Nullable HttpHeaders httpHeaders, AccessControl accessControl) | ||
| throws Exception { | ||
| boolean queryWasLogged = _queryLogger.logQueryReceived(requestId, query); | ||
|
|
||
| QueryFingerprint queryFingerprint = null; | ||
| String queryHash = CommonConstants.Broker.DEFAULT_QUERY_HASH; | ||
| if (_enableQueryFingerprinting) { | ||
| try { | ||
| QueryFingerprint queryFingerprint = QueryFingerprintUtils.generateFingerprint(sqlNodeAndOptions); | ||
| queryFingerprint = QueryFingerprintUtils.generateFingerprint(sqlNodeAndOptions); | ||
| if (queryFingerprint != null) { | ||
| queryHash = queryFingerprint.getQueryHash(); | ||
| requestContext.setQueryFingerprint(queryFingerprint); | ||
|
|
@@ -332,6 +338,8 @@ protected BrokerResponse handleRequest(long requestId, String query, SqlNodeAndO | |
| } | ||
| } | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If fingerprint generation failed above, this still hands the raw SQL to the query logger and the request-handler warning path already logged it once. The same pattern also exists on other broker error paths that still log
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. another great catch. From what I initially found, the queries are all being logged from What do you think? |
||
|
|
||
| boolean queryWasLogged = _queryLogger.logQueryReceived(requestId, query, queryFingerprint); | ||
|
|
||
| String cid = extractClientRequestId(sqlNodeAndOptions); | ||
| if (cid == null) { | ||
| cid = Long.toString(requestId); | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This fails open on misconfiguration. If an operator sets an invalid
pinot.broker.query.log.sqlRedactionvalue, we silently fall back toNONEand start emitting raw SQL, which is the exact unsafe behavior this knob is supposed to prevent. For a privacy feature, the safer behavior is to reject startup or fail closed to a redacted mode instead of disabling redaction.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ya, really good point. I've updated this for now while I think about your other comment.