Skip to content
Draft
Show file tree
Hide file tree
Changes from 1 commit
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
3 changes: 2 additions & 1 deletion deps.edn
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
org.slf4j/slf4j-simple {:mvn/version "2.0.7"}
org.owasp/dependency-check-core {:mvn/version "8.4.0"}
rm-hull/table {:mvn/version "0.7.1"}
trptcolin/versioneer {:mvn/version "0.2.0"}}
trptcolin/versioneer {:mvn/version "0.2.0"}
org.clojure/tools.deps {:mvn/version "0.18.1354"}}
:mvn/repos {"central" {:url "https://repo1.maven.org/maven2/"}
"clojars" {:url "https://repo.clojars.org/"}}
:tools/usage {:ns-default nvd.task}
Expand Down
24 changes: 20 additions & 4 deletions src/nvd/task.clj
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,25 @@
(ns nvd.task
"Clojure CLI tool entry points: `check`."
(:require
[nvd.task.check :refer [-main]]))
[clojure.tools.deps :as deps]
[clojure.tools.deps.util.session :as session]
[nvd.task.check :refer [-main]]))

(defn- get-classpath [{:keys [aliases]}]
(let [{:keys [root-edn user-edn project-edn]} (deps/find-edn-maps "deps.edn")
master-edn (deps/merge-edns [root-edn user-edn project-edn])
aliases (or aliases [])
combined-aliases (deps/combine-aliases master-edn aliases)
Comment on lines +31 to +34
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This section, although tiny, represents a duplication of what CLI clojure usage does internally.

Having that duplication of knowledge represents a surface area for bugs/misunderstandings that would not otherwise exist.


...I'm aware that this reasoning might be considered overly cautious in 9 out of 10 projects, but nvd-clojure is the one-in-ten project that does deserve squeezing the last drop of correctness.

I'd want the project to guarantee that it's doing what it says it does - our users deserve no less, if we're promising security.

basis (session/with-session
(deps/calc-basis master-edn {:resolve-args (merge combined-aliases {:trace true})
:classpath-args combined-aliases}))]
(deps/join-classpath (:classpath-roots basis))))

(defn check
"Arguments: `:config-filename` (optional), `:classpath` (required)."
[{:keys [config-filename classpath]}]
(-main (or config-filename "") classpath))
"Arguments:
`:config-filename` (optional),
`:classpath` (optional, defaults to the classpath of deps.edn in the current directory)
`:aliases` (optional, defaults to [])."
[{:keys [config-filename classpath] :as opts}]
(-main (or config-filename "") (or classpath
(get-classpath opts))))