This is an automated email from the ASF dual-hosted git repository.
alexpl pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/ignite.git
The following commit(s) were added to refs/heads/master by this push:
new bb4dc197c98 IGNITE-23676 SQL Calcite: Fix sensitive information
removal failure for JOINs and other SQL nodes - Fixes #11663.
bb4dc197c98 is described below
commit bb4dc197c98d5f6a4ca68491aff643cb5c60274d
Author: Aleksey Plekhanov <[email protected]>
AuthorDate: Fri Nov 29 09:49:43 2024 +0300
IGNITE-23676 SQL Calcite: Fix sensitive information removal failure for
JOINs and other SQL nodes - Fixes #11663.
Signed-off-by: Aleksey Plekhanov <[email protected]>
---
.../processors/query/calcite/CalciteQueryProcessor.java | 11 ++++++++++-
.../calcite/integration/SqlDiagnosticIntegrationTest.java | 8 ++++++--
2 files changed, 16 insertions(+), 3 deletions(-)
diff --git
a/modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/CalciteQueryProcessor.java
b/modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/CalciteQueryProcessor.java
index 8dbaf85ba70..c845efd27e3 100644
---
a/modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/CalciteQueryProcessor.java
+++
b/modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/CalciteQueryProcessor.java
@@ -43,6 +43,7 @@ import org.apache.calcite.sql.SqlNode;
import org.apache.calcite.sql.SqlNodeList;
import org.apache.calcite.sql.parser.SqlParser;
import org.apache.calcite.sql.parser.SqlParserPos;
+import org.apache.calcite.sql.type.SqlTypeName;
import org.apache.calcite.sql.util.SqlOperatorTables;
import org.apache.calcite.sql.util.SqlShuttle;
import org.apache.calcite.sql.validate.SqlValidator;
@@ -550,7 +551,15 @@ public class CalciteQueryProcessor extends
GridProcessorAdapter implements Query
return qry.accept(
new SqlShuttle() {
@Override public SqlNode visit(SqlLiteral literal) {
- return new SqlDynamicParam(-1,
literal.getParserPosition());
+ // Process only certain data types, where it's
justified to hide information.
+ // Don't touch enums and boolean literals, since
they can be used as internal field values
+ // for some SQL nodes.
+ if
(SqlTypeName.STRING_TYPES.contains(literal.getTypeName())
+ ||
SqlTypeName.NUMERIC_TYPES.contains(literal.getTypeName())
+ ||
SqlTypeName.DATETIME_TYPES.contains(literal.getTypeName()))
+ return new SqlDynamicParam(-1,
literal.getParserPosition());
+
+ return literal;
}
@Override public SqlNode visit(SqlCall call) {
diff --git
a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/SqlDiagnosticIntegrationTest.java
b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/SqlDiagnosticIntegrationTest.java
index d5d72a1d677..b24e8e66d3d 100644
---
a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/SqlDiagnosticIntegrationTest.java
+++
b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/SqlDiagnosticIntegrationTest.java
@@ -676,6 +676,10 @@ public class SqlDiagnosticIntegrationTest extends
AbstractBasicIntegrationTest {
sql(grid(0), "CREATE USER test WITH PASSWORD 'sensitive'");
sql(grid(0), "ALTER USER test WITH PASSWORD 'sensitive'");
+ // Test JOIN.
+ sql(grid(0),
+ "SELECT * FROM test_sens t1 JOIN test_sens t2 ON t1.id = t2.id
WHERE t1.val like 'sensitive%'");
+
AtomicInteger qryCnt = new AtomicInteger();
AtomicInteger planCnt = new AtomicInteger();
@@ -708,8 +712,8 @@ public class SqlDiagnosticIntegrationTest extends
AbstractBasicIntegrationTest {
}
});
- assertEquals(12, qryCnt.get()); // CREATE AS SELECT counts as two
queries.
- assertEquals(7, planCnt.get()); // DDL queries don't produce
plans, except CREATE AS SELECT.
+ assertEquals(13, qryCnt.get()); // CREATE AS SELECT counts as two
queries.
+ assertEquals(8, planCnt.get()); // DDL queries don't produce
plans, except CREATE AS SELECT.
}
finally {
QueryUtils.INCLUDE_SENSITIVE = true;