diff options
-rw-r--r-- | documentation/research/Security.md | 4 | ||||
-rw-r--r-- | lux-lein/project.clj | 4 | ||||
-rw-r--r-- | lux-lein/src/leiningen/lux/utils.clj | 98 |
3 files changed, 68 insertions, 38 deletions
diff --git a/documentation/research/Security.md b/documentation/research/Security.md index 6ee526434..f583bf12b 100644 --- a/documentation/research/Security.md +++ b/documentation/research/Security.md @@ -1,3 +1,7 @@ +# Return-oriented programming + +1. https://github.com/immunant/selfrando + # Static analysis 1. [Cam Tenny - Beyond the Paper - End-to-End Program Analysis](https://www.youtube.com/watch?v=hmDz0Rv6hKI) diff --git a/lux-lein/project.clj b/lux-lein/project.clj index 114960e23..d81927bb2 100644 --- a/lux-lein/project.clj +++ b/lux-lein/project.clj @@ -3,9 +3,7 @@ :url "https://github.com/LuxLang/lein-luxc" :license {:name "Lux License v0.1" :url "https://github.com/LuxLang/lux/blob/master/license.txt"} - :dependencies [[org.clojure/clojure "1.6.0"] - [com.github.luxlang/luxc-jvm "0.6.0-SNAPSHOT"] - [com.github.luxlang/stdlib "0.6.0-SNAPSHOT"]] + :dependencies [[org.clojure/clojure "1.6.0"]] :deploy-repositories [["releases" {:url "https://oss.sonatype.org/service/local/staging/deploy/maven2/" :creds :gpg}] ["snapshots" {:url "https://oss.sonatype.org/content/repositories/snapshots/" diff --git a/lux-lein/src/leiningen/lux/utils.clj b/lux-lein/src/leiningen/lux/utils.clj index 008f6cd3b..6829f3d96 100644 --- a/lux-lein/src/leiningen/lux/utils.clj +++ b/lux-lein/src/leiningen/lux/utils.clj @@ -25,13 +25,25 @@ (.substring path 1) path)))) -(def ^:private stdlib-id ["com.github.luxlang" "stdlib"]) +(defn ^:private project-id [project] + [(get project :group) (get project :name)]) -(defn ^:private all-jars-in-classloader [] - (->> ^java.net.URLClassLoader (ClassLoader/getSystemClassLoader) - (.getURLs) - (map #(.getFile ^java.net.URL %)) - (filter #(.endsWith ^String % ".jar")))) +(def ^:private lux-group "com.github.luxlang") +(def ^:private compiler-id [lux-group "luxc-jvm"]) +(def ^:private stdlib-id [lux-group "stdlib"]) + +(defn ^:private id-path + "(-> Project-ID Text)" + [[group name]] + (str (.replace group "." "/") "/" name)) + +(def ^:private compiler-path (id-path compiler-id)) +(def ^:private stdlib-path (id-path stdlib-id)) + +(defn ^:private project-jars [project] + (->> project + classpath/get-classpath + (filter #(.endsWith % ".jar")))) (do-template [<name> <path>] (defn <name> [jar-paths] @@ -42,54 +54,70 @@ nil)) jar-paths)) - ^:private find-compiler-path (sanitize-path "com/github/luxlang/luxc-jvm") - ^:private find-stdlib-path (sanitize-path "com/github/luxlang/stdlib") + ^:private find-compiler-path (sanitize-path compiler-path) + ^:private find-stdlib-path (sanitize-path stdlib-path) ) -(defn ^:private filter-deps [jar-paths] - (filter (fn [^:private path] - (or (.contains path (sanitize-path "org/ow2/asm/asm-all")) - (.contains path (sanitize-path "org/clojure/core.match")) - (.contains path (sanitize-path "org/clojure/clojure")))) - jar-paths)) +(defn ^:private compiler-dependency? [path] + (or (.contains path (sanitize-path "org/ow2/asm/asm-all")) + (.contains path (sanitize-path "org/clojure/core.match")) + (.contains path (sanitize-path "org/clojure/clojure")) + (.contains path (sanitize-path compiler-path)))) + +(defn ^:private filter-compiler-dependencies [jar-paths] + (filter compiler-dependency? jar-paths)) (defn ^:private java-command [project] (str (get project :java-cmd "java") " " (->> (get project :jvm-opts) (interpose " ") (reduce str "")) " " vm-options)) -(defn ^:private lux-command [project mode source-paths] +(defn ^:private join-paths [paths] + (->> paths + (interpose unit-separator) + (apply str) + (str unit-separator))) + +(defn ^:private lux-command [project mode program-dependencies source-paths] (str "lux " mode - " " (->> (get project :resource-paths (list)) (interpose unit-separator) (apply str)) - " " (->> source-paths (interpose unit-separator) (apply str)) + " " (join-paths program-dependencies) + " " (join-paths source-paths) " " (get project :target-path default-target-dir))) (do-template [<name> <mode>] (defn <name> [project module source-paths] - (let [is-stdlib? (= stdlib-id [(get project :group) (get project :name)]) - jar-paths (all-jars-in-classloader) - compiler-path (prepare-path (find-compiler-path jar-paths)) - stdlib-path (prepare-path (find-stdlib-path jar-paths)) + (let [is-stdlib? (= stdlib-id + (project-id project)) + raw-paths (project-jars project) + compiler-path (prepare-path (find-compiler-path raw-paths)) + stdlib-path (when (not is-stdlib?) + (prepare-path (find-stdlib-path raw-paths))) sdk-path (get-in project [:lux :android :sdk]) - android-path (str sdk-path java.io.File/separator "platforms" java.io.File/separator "android-" (get-in project [:lux :android :version]) java.io.File/separator "android.jar") - deps-paths (let [deps (map prepare-path - (filter-deps jar-paths)) - with-android (if (.exists (new File android-path)) - (cons android-path deps) - deps) - with-stdlib (if is-stdlib? - with-android - (list* stdlib-path with-android))] - with-stdlib) - class-path (->> (classpath/get-classpath project) - (filter #(.endsWith % ".jar")) - (concat deps-paths) + android-path (str sdk-path + java.io.File/separator "platforms" + java.io.File/separator "android-" + (get-in project [:lux :android :version]) + java.io.File/separator "android.jar") + compiler-dependencies (let [compiler-dependencies (->> raw-paths + (filter compiler-dependency?) + (map prepare-path)) + with-android (if (.exists (new File android-path)) + (cons android-path compiler-dependencies) + compiler-dependencies)] + with-android) + program-dependencies (let [deps (->> raw-paths + (filter (complement compiler-dependency?)) + (map prepare-path))] + (if is-stdlib? + deps + (list* stdlib-path deps))) + class-path (->> compiler-dependencies (list* compiler-path) (interpose java.io.File/pathSeparator) (reduce str "") sanitize-path)] (str (java-command project) " -cp " class-path - " " (lux-command project <mode> source-paths)))) + " " (lux-command project <mode> program-dependencies source-paths)))) compile-path (str "release " module) repl-path "repl" |