Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 15 additions & 10 deletions src/clj_ssh/ssh.clj
Original file line number Diff line number Diff line change
Expand Up @@ -430,21 +430,26 @@ keys. All other option key pairs will be passed as SSH config options."
(finally
(disconnect session#)))))

(defn clean-sensitive-data [hosts]
"Remove password from hosts vector"
(map #(dissoc % :password) hosts))

;;; Jump Hosts
(defn- jump-connect [agent hosts sessions timeout]
(let [host (first hosts)
s (session agent (:hostname host) (dissoc host :hostname))
throw-e (fn [e s]
(throw
(ex-info
(str "Failed to connect "
(.getUserName s) "@"
(.getHost s) ":"
(.getPort s)
" " (pr-str (into [] (.getIdentityNames agent)))
" " (pr-str hosts))
{:hosts hosts}
e)))]
(let [clear-hosts (clean-sensitive-data hosts)]
(throw
(ex-info
(str "Failed to connect "
(.getUserName s) "@"
(.getHost s) ":"
(.getPort s)
" " (pr-str (into [] (.getIdentityNames agent)))
" " (pr-str clear-hosts))
{:hosts clear-hosts}
e))))]
(swap! sessions (fnil conj []) s)
(try
(connect s timeout)
Expand Down
6 changes: 6 additions & 0 deletions test/clj_ssh/ssh_test.clj
Original file line number Diff line number Diff line change
Expand Up @@ -636,3 +636,9 @@
":channel not connected")
(is (zero? (exit-status (:channel proc)))
"zero exit status")))))))

(deftest clean-sensitive-data-test
(are [?in ?out]
(= ?out (clean-sensitive-data ?in))
[{:hostname "host", :username "user", :password "pass123"}] [{:hostname "host", :username "user"}]
[{:hostname "host"}] [{:hostname "host"}]))