Преглед изворни кода

Add :shell/command-whitelist option

Tienson Qin пре 3 година
родитељ
комит
fff33b3ccb
2 измењених фајлова са 7 додато и 2 уклоњено
  1. 3 1
      src/main/frontend/handler/shell.cljs
  2. 4 1
      templates/config.edn

+ 3 - 1
src/main/frontend/handler/shell.cljs

@@ -55,7 +55,9 @@
           (= "git" command)
           (wrap-notification! command (fn [_ args] (run-git-command! args)) args)
 
-          (contains? commands-whitelist command)
+          (contains? (merge (map (comp #(remove string/blank? %) string/lower-case str)
+                              (:commands-whitelist (state/get-config)))
+                            commands-whitelist) command)
           (run-cli-command! command args)
 
           :else

+ 4 - 1
templates/config.edn

@@ -284,7 +284,7 @@
  ;; Decide the way to escape the special characters in the page title.
  ;; Warning:
  ;;   This is a dangerous operation. If you want to change the setting,
- ;;   should access the setting `Filename format` and follow the instructions. 
+ ;;   should access the setting `Filename format` and follow the instructions.
  ;;   Or you have to rename all the affected files manually then re-index on all
  ;;   clients after the files are synced. Wrong handling may cause page titles
  ;;   containing special characters to be messy.
@@ -296,4 +296,7 @@
  ;;     ;use Percent-encoding for slash and other invalid characters
  ;;     ;parse `.` in file name as slash `/` in page title
  :file/name-format :triple-lowbar
+
+ ;; Commands that are allowed to be invoked from Logseq.
+ :shell/command-whitelist #{}
  }