mirror of
https://github.com/logseq/logseq.git
synced 2026-02-01 22:47:36 +00:00
Add :code-block/command-whitelist option
This commit is contained in:
@@ -32,7 +32,7 @@
|
||||
[:div
|
||||
[:h1.title
|
||||
"Input command"]
|
||||
[:div.mt-4.mb-4.relative.rounded-md.shadow-sm.max-w-xs
|
||||
[:div.mt-4.mb-4.relative.rounded-md.shadow-sm
|
||||
[:input#run-command.form-input.font-mono.block.w-full.sm:text-sm.sm:leading-5
|
||||
{:autoFocus true
|
||||
:on-key-down util/stop-propagation
|
||||
|
||||
@@ -306,7 +306,7 @@
|
||||
(when-not (= mode "calc")
|
||||
[:div
|
||||
[:div.extensions__code-lang
|
||||
(if (contains? (shell-handler/get-commands) (string/lower-case mode))
|
||||
(if (contains? (shell-handler/get-code-block-commands) (string/lower-case mode))
|
||||
[:a {:title (str "Run command " mode)
|
||||
:on-click (fn [_e]
|
||||
(let [editor-atom (:editor-atom state)]
|
||||
|
||||
@@ -42,12 +42,21 @@
|
||||
(def dangerous-commands
|
||||
#{"rm" "mv" "rename" "dd" ">" "command" "sudo"})
|
||||
|
||||
(def code-block-commands-whitelist
|
||||
#{"alda"})
|
||||
|
||||
(defn get-commands
|
||||
[]
|
||||
(set/union (map (comp #(remove string/blank? %) string/lower-case str)
|
||||
(:commands-whitelist (state/get-config)))
|
||||
commands-whitelist))
|
||||
|
||||
(defn get-code-block-commands
|
||||
[]
|
||||
(set/union (map (comp #(remove string/blank? %) string/lower-case str)
|
||||
(:code-block/command-whitelist (state/get-config)))
|
||||
code-block-commands-whitelist))
|
||||
|
||||
(defn run-command!
|
||||
[command]
|
||||
(let [[command args] (gp-util/split-first " " command)
|
||||
|
||||
@@ -299,4 +299,7 @@
|
||||
|
||||
;; Commands that are allowed to be invoked from Logseq.
|
||||
:shell/command-whitelist #{}
|
||||
|
||||
;; Commands that could be executed in code blocks, e.g. alda, dot
|
||||
:code-block/command-whitelist #{}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user