Skip to content

Commit b288b88

Browse files
committed
SQL: Use field caps inside DESCRIBE TABLE as well (#41377)
Thanks to #34071, there is enough information in field caps to infer the table structure and thus use the same API consistently across the IndexResolver. (cherry picked from commit f999469)
1 parent f65a86c commit b288b88

File tree

5 files changed

+235
-198
lines changed

5 files changed

+235
-198
lines changed

x-pack/plugin/sql/qa/security/src/test/java/org/elasticsearch/xpack/sql/qa/security/JdbcSecurityIT.java

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -234,12 +234,14 @@ public void checkNoMonitorMain(String user) throws Exception {
234234
expectUnauthorized("cluster:monitor/main", user, () -> es(userProperties(user)));
235235
expectUnauthorized("cluster:monitor/main", user, () -> es(userProperties(user)).getMetaData().getDatabaseMajorVersion());
236236
expectUnauthorized("cluster:monitor/main", user, () -> es(userProperties(user)).getMetaData().getDatabaseMinorVersion());
237-
expectUnauthorized("cluster:monitor/main", user,
238-
() -> es(userProperties(user)).createStatement().executeQuery("SELECT * FROM test"));
239-
expectUnauthorized("cluster:monitor/main", user,
240-
() -> es(userProperties(user)).createStatement().executeQuery("SHOW TABLES LIKE 'test'"));
241-
expectUnauthorized("cluster:monitor/main", user,
242-
() -> es(userProperties(user)).createStatement().executeQuery("DESCRIBE test"));
237+
238+
// by moving to field caps these calls do not require the monitor permission
239+
// expectUnauthorized("cluster:monitor/main", user,
240+
// () -> es(userProperties(user)).createStatement().executeQuery("SELECT * FROM test"));
241+
// expectUnauthorized("cluster:monitor/main", user,
242+
// () -> es(userProperties(user)).createStatement().executeQuery("SHOW TABLES LIKE 'test'"));
243+
// expectUnauthorized("cluster:monitor/main", user,
244+
// () -> es(userProperties(user)).createStatement().executeQuery("DESCRIBE test"));
243245
}
244246

245247
private void expectUnauthorized(String action, String user, ThrowingRunnable r) {

x-pack/plugin/sql/qa/src/main/resources/single-node-only/command-sys.csv-spec

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ x-pack_plugin_sql_qa_single-node_integTestCluster |null |test_emp
107107
x-pack_plugin_sql_qa_single-node_integTestCluster |null |test_emp |salary |4 |INTEGER |11 |4 |null |10 |1 |null |null |4 |0 |null |11 |YES |null |null |null |null |NO |NO
108108
x-pack_plugin_sql_qa_single-node_integTestCluster |null |test_emp_copy |birth_date |93 |DATETIME |29 |8 |null |null |1 |null |null |9 |3 |null |1 |YES |null |null |null |null |NO |NO
109109
x-pack_plugin_sql_qa_single-node_integTestCluster |null |test_emp_copy |emp_no |4 |INTEGER |11 |4 |null |10 |1 |null |null |4 |0 |null |3 |YES |null |null |null |null |NO |NO
110+
x-pack_plugin_sql_qa_single-node_integTestCluster |null |test_emp_copy |extra.info.gender |12 |KEYWORD |32766 |2147483647 |null |null |1 |null |null |12 |0 |2147483647 |6 |YES |null |null |null |null |NO |NO
110111
x-pack_plugin_sql_qa_single-node_integTestCluster |null |test_emp_copy |extra_gender |12 |KEYWORD |32766 |2147483647 |null |null |1 |null |null |12 |0 |2147483647 |7 |YES |null |null |null |null |NO |NO
111112
x-pack_plugin_sql_qa_single-node_integTestCluster |null |test_emp_copy |extra_no |4 |INTEGER |11 |4 |null |10 |1 |null |null |4 |0 |null |8 |YES |null |null |null |null |NO |NO
112113
x-pack_plugin_sql_qa_single-node_integTestCluster |null |test_emp_copy |first_name |12 |TEXT |2147483647 |2147483647 |null |null |1 |null |null |12 |0 |2147483647 |9 |YES |null |null |null |null |NO |NO

0 commit comments

Comments
 (0)