Skip to content
Snippets Groups Projects
Unverified Commit 25202443 authored by Bryan Maass's avatar Bryan Maass Committed by GitHub
Browse files

H2 disallow `INIT=...` option using connection string (#25369)

* trim the init option in h2 connection string

- it can be lower or mixed-case, so `(dissoc-by str/lower-case ...)`
  will lowercase the map's keys and the dissoc-keys, and dissoc them when
  they are equal.

* refactor
parent bf8ba13b
No related branches found
No related tags found
No related merge requests found
......@@ -366,8 +366,14 @@
[connection-string]
{:pre [(string? connection-string)]}
(let [[file options] (connection-string->file+options connection-string)]
(file+options->connection-string file (merge options {"IFEXISTS" "TRUE"
"ACCESS_MODE_DATA" "r"}))))
(file+options->connection-string file (merge
(->> options
;; Remove INIT=... from options for security reasons (Metaboat #165)
;; http://h2database.com/html/features.html#execute_sql_on_connection
(remove (fn [[k _]] (= (str/lower-case k) "init")))
(into {}))
{"IFEXISTS" "TRUE"
"ACCESS_MODE_DATA" "r"}))))
(defmethod sql-jdbc.conn/connection-details->spec :h2
[_ details]
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment