The easy-to-use open source Business Intelligence and Embedded Analytics tool that lets everyone work with data :bar_chart:
TypeScript analyticsbibusiness-intelligencebusinessintelligenceclojuredashboarddatadata-analysisdata-visualizationdatabasemetabasemysqlpostgrespostgresqlreportingslacksql-editorvisualization
Check for VolumeOperationAllowedLocalPaths connecting to databricks. (#74375)
technomancy0726c322099f
diff --git a/modules/drivers/databricks/src/metabase/driver/databricks.clj b/modules/drivers/databricks/src/metabase/driver/databricks.cljindex 8916bc62c25..c83acb84c62 100644--- a/modules/drivers/databricks/src/metabase/driver/databricks.clj+++ b/modules/drivers/databricks/src/metabase/driver/databricks.clj@@ -66,6 +66,12 @@((get-method sql-jdbc.sync/database-type->base-type :hive-like)driver database-type)))+(defmethod driver/validate-db-details! :databricks+ [_driver details]+ (when-let [opts (not-empty (:additional-options details))]+ (when (re-find #"(?i)VolumeOperationAllowedLocalPaths" opts)+ (throw (Exception. "Potentially dangerous keys in connection details")))))+(defn- catalog-present?[jdbc-spec catalog](let [sql "select 0 from `system`.`information_schema`.`catalogs` where catalog_name = ?"]@@ -73,6 +79,7 @@(defmethod driver/can-connect? :databricks[driver details]+ (driver/validate-db-details! driver details)(sql-jdbc.conn/with-connection-spec-for-testing-connection [jdbc-spec [driver details]](and (catalog-present? jdbc-spec (:catalog details))(sql-jdbc.conn/can-connect-with-spec? jdbc-spec))))diff --git a/modules/drivers/databricks/test/metabase/driver/databricks_test.clj b/modules/drivers/databricks/test/metabase/driver/databricks_test.cljindex 4958da89a56..0da13aa43b7 100644--- a/modules/drivers/databricks/test/metabase/driver/databricks_test.clj+++ b/modules/drivers/databricks/test/metabase/driver/databricks_test.clj@@ -18,6 +18,7 @@[metabase.sync.core :as sync][metabase.test :as mt][metabase.test.data.interface :as tx]+ [metabase.util :as u][toucan2.core :as t2]))(defn- maybe-qualify-schema@@ -474,7 +475,17 @@(testing "Can connect returns true for catalog that is present on the instance"(is (true? (driver/can-connect? :databricks (:details (mt/db))))))(testing "Can connect returns false for catalog that is NOT present on the instance (#49444)"- (is (false? (driver/can-connect? :databricks (assoc (:details (mt/db)) :catalog "xixixix")))))))+ (is (false? (driver/can-connect? :databricks (assoc (:details (mt/db)) :catalog "xixixix")))))+ (testing "Disallows unsafe connection parameters"+ (let [details (assoc (:details (mt/db)) :additional-options "VolumeOperationAllowedLocalPaths=/etc/hosts")]+ (is (thrown-with-msg? Exception #"Potentially dangerous keys"+ (driver/can-connect? :databricks details)))+ (is (thrown-with-msg? Exception #"Potentially dangerous keys"+ (driver/can-connect? :databricks (update details+ :additional-options+ u/lower-case-en))))+ (is (thrown-with-msg? Exception #"Potentially dangerous keys"+ (driver/validate-db-details! :databricks details)))))))(deftest can-connect-using-m2m-test(mt/test-driver