diff options
author | Eduardo Julian | 2019-02-07 20:06:45 -0400 |
---|---|---|
committer | Eduardo Julian | 2019-02-07 20:06:45 -0400 |
commit | 5f15b52079bd4ce7638cbfbc1c63cea53e4ffec7 (patch) | |
tree | fe3b794f287614fa8005258ebbe4d7b448d0a86e /stdlib/source | |
parent | ee70d1af74a295b41f01770c269d72ee2d990c27 (diff) |
- Removed the current usage of data-integrity measures.
- TBD: New measures.
Diffstat (limited to '')
-rw-r--r-- | stdlib/source/lux/world/console.lux | 9 | ||||
-rw-r--r-- | stdlib/source/lux/world/environment.jvm.lux | 8 | ||||
-rw-r--r-- | stdlib/source/lux/world/file.lux | 5 | ||||
-rw-r--r-- | stdlib/source/lux/world/net/http.lux | 6 | ||||
-rw-r--r-- | stdlib/source/lux/world/net/http/request.lux | 110 | ||||
-rw-r--r-- | stdlib/source/lux/world/net/http/route.lux | 57 | ||||
-rw-r--r-- | stdlib/source/lux/world/net/tcp.jvm.lux | 8 | ||||
-rw-r--r-- | stdlib/source/lux/world/net/udp.jvm.lux | 8 | ||||
-rw-r--r-- | stdlib/source/test/lux/world/file.lux | 12 | ||||
-rw-r--r-- | stdlib/source/test/lux/world/net/udp.lux | 8 |
10 files changed, 95 insertions, 136 deletions
diff --git a/stdlib/source/lux/world/console.lux b/stdlib/source/lux/world/console.lux index dedf3603f..8f58b0266 100644 --- a/stdlib/source/lux/world/console.lux +++ b/stdlib/source/lux/world/console.lux @@ -6,7 +6,6 @@ [concurrency ["." promise (#+ Promise)]] [security - ["." integrity (#+ Dirty)] [capability (#+ Capability)]]] [data ["." error (#+ Error)] @@ -27,7 +26,7 @@ ) (type: #export (Can-Read ! o) - (Capability [] (! (Error (Dirty o))))) + (Capability [] (! (Error o)))) (type: #export (Can-Write ! i) (Capability i (! (Error Any)))) @@ -87,12 +86,10 @@ (def: (read _) (|> jvm-input InputStream::read - (:: (error.with-error io.functor) map (|>> .nat integrity.taint)))) + (:: (error.with-error io.functor) map .nat))) (def: (read-line _) - (|> jvm-console - java/io/Console::readLine - (:: (error.with-error io.functor) map integrity.taint))) + (java/io/Console::readLine jvm-console)) (def: (write message) (PrintStream::print message jvm-output)) diff --git a/stdlib/source/lux/world/environment.jvm.lux b/stdlib/source/lux/world/environment.jvm.lux index 3d1181614..8ad10f1f9 100644 --- a/stdlib/source/lux/world/environment.jvm.lux +++ b/stdlib/source/lux/world/environment.jvm.lux @@ -1,8 +1,5 @@ (.module: [lux #* - [control - [security - ["." integrity (#+ Dirty)]]] [data ["." text] [format @@ -47,10 +44,9 @@ (Map$Entry::getValue entry)]) (def: #export read - (IO (Dirty Context)) + (IO Context) (io (|> (System::getenv) Map::entrySet Set::iterator (consume-iterator entry-to-kv) - (dictionary.from-list text.hash) - integrity.taint))) + (dictionary.from-list text.hash)))) diff --git a/stdlib/source/lux/world/file.lux b/stdlib/source/lux/world/file.lux index 32adc204c..1dd29acfe 100644 --- a/stdlib/source/lux/world/file.lux +++ b/stdlib/source/lux/world/file.lux @@ -6,7 +6,6 @@ [concurrency ["." promise (#+ Promise)]] [security - ["." integrity (#+ Dirty)] ["!" capability (#+ capability:)]]] [data ["." maybe] @@ -51,7 +50,7 @@ [size Nat] [last-modified Instant] [can-execute? Bit] - [content (Dirty Binary)] + [content Binary] )) (: (Can-Open ! File) @@ -257,7 +256,7 @@ bytes-read (InputStream::read data stream) _ (AutoCloseable::close stream)] (if (i/= size bytes-read) - (wrap (integrity.taint data)) + (wrap data) (io.io (ex.throw cannot-read-all-data path))))))) (def: size diff --git a/stdlib/source/lux/world/net/http.lux b/stdlib/source/lux/world/net/http.lux index d063d75ac..e84472710 100644 --- a/stdlib/source/lux/world/net/http.lux +++ b/stdlib/source/lux/world/net/http.lux @@ -3,9 +3,7 @@ [control [concurrency [promise (#+ Promise)] - [frp (#+ Channel)]] - [security - [integrity (#+ Dirty)]]] + [frp (#+ Channel)]]] [data [format [context (#+ Context)]]] @@ -73,4 +71,4 @@ [Status Message]) (type: #export Server - (-> (Dirty Request) (Promise Response))) + (-> Request (Promise Response))) diff --git a/stdlib/source/lux/world/net/http/request.lux b/stdlib/source/lux/world/net/http/request.lux index 6025571f5..ad8a2e450 100644 --- a/stdlib/source/lux/world/net/http/request.lux +++ b/stdlib/source/lux/world/net/http/request.lux @@ -5,15 +5,12 @@ ["." monad (#+ do)] [concurrency ["." promise (#+ Promise)] - ["." frp]] - [security - ["." integrity (#+ Dirty)]]] + ["." frp]]] [data ["." maybe] ["." error (#+ Error)] ["." number] ["." text - format ["." encoding]] [format ["." json (#+ JSON)] @@ -52,80 +49,75 @@ (def: failure (//response.bad-request "")) (def: #export (json server) - (-> (-> (Dirty JSON) Server) Server) - (function (_ request) - (let [[identification protocol resource message] (integrity.trust request)] - (do promise.monad - [?raw (read-text-body (get@ #//.body message))] - (case (do error.monad - [raw ?raw] - (:: json.codec decode raw)) - (#error.Success content) - (server (integrity.taint content) request) - - (#error.Failure error) - (promise.resolved ..failure)))))) + (-> (-> JSON Server) Server) + (function (_ (^@ request [identification protocol resource message])) + (do promise.monad + [?raw (read-text-body (get@ #//.body message))] + (case (do error.monad + [raw ?raw] + (:: json.codec decode raw)) + (#error.Success content) + (server content request) + + (#error.Failure error) + (promise.resolved ..failure))))) (def: #export (text server) - (-> (-> (Dirty Text) Server) Server) - (function (_ request) - (let [[identification protocol resource message] (integrity.trust request)] - (do promise.monad - [?raw (read-text-body (get@ #//.body message))] - (case ?raw - (#error.Success content) - (server (integrity.taint content) request) - - (#error.Failure error) - (promise.resolved ..failure)))))) + (-> (-> Text Server) Server) + (function (_ (^@ request [identification protocol resource message])) + (do promise.monad + [?raw (read-text-body (get@ #//.body message))] + (case ?raw + (#error.Success content) + (server content request) + + (#error.Failure error) + (promise.resolved ..failure))))) (def: #export (query property server) - (All [a] (-> (Property a) (-> (Dirty a) Server) Server)) - (function (_ request) - (let [[identification protocol resource message] (integrity.trust request) - full (get@ #//.uri resource) + (All [a] (-> (Property a) (-> a Server) Server)) + (function (_ [identification protocol resource message]) + (let [full (get@ #//.uri resource) [uri query] (|> full (text.split-with "?") (maybe.default [full ""]))] (case (do error.monad [query (//query.parameters query) input (context.run query property)] - (wrap [(integrity.taint [identification protocol (set@ #//.uri uri resource) message]) + (wrap [[identification protocol (set@ #//.uri uri resource) message] input])) (#error.Success [request input]) - (server (integrity.taint input) request) + (server input request) (#error.Failure error) (promise.resolved ..failure))))) (def: #export (form property server) - (All [a] (-> (Property a) (-> (Dirty a) Server) Server)) - (function (_ request) - (let [[identification protocol resource message] (integrity.trust request)] - (do promise.monad - [?body (read-text-body (get@ #//.body message))] - (case (do error.monad - [body ?body - form (//query.parameters body)] - (context.run form property)) - (#error.Success input) - (server (integrity.taint input) request) - - (#error.Failure error) - (promise.resolved ..failure)))))) - -(def: #export (cookies property server) - (All [a] (-> (Property a) (-> (Dirty a) Server) Server)) - (function (_ request) - (let [[identification protocol resource message] (integrity.trust request)] + (All [a] (-> (Property a) (-> a Server) Server)) + (function (_ (^@ request [identification protocol resource message])) + (do promise.monad + [?body (read-text-body (get@ #//.body message))] (case (do error.monad - [cookies (|> (get@ #//.headers message) - (dictionary.get "Cookie") - (maybe.default "") - //cookie.get)] - (context.run cookies property)) + [body ?body + form (//query.parameters body)] + (context.run form property)) (#error.Success input) - (server (integrity.taint input) request) + (server input request) (#error.Failure error) (promise.resolved ..failure))))) + +(def: #export (cookies property server) + (All [a] (-> (Property a) (-> a Server) Server)) + (function (_ (^@ request [identification protocol resource message])) + (case (do error.monad + [cookies (|> (get@ #//.headers message) + (dictionary.get "Cookie") + (maybe.default "") + //cookie.get)] + (context.run cookies property)) + (#error.Success input) + (server input request) + + (#error.Failure error) + (promise.resolved ..failure)))) diff --git a/stdlib/source/lux/world/net/http/route.lux b/stdlib/source/lux/world/net/http/route.lux index d7b674366..c15972ca6 100644 --- a/stdlib/source/lux/world/net/http/route.lux +++ b/stdlib/source/lux/world/net/http/route.lux @@ -3,9 +3,7 @@ [control [monad (#+ do)] [concurrency - ["." promise]] - [security - ["." integrity]]] + ["." promise]]] [data ["." maybe] ["." text ("text/." equivalence)]]] @@ -16,14 +14,13 @@ (do-template [<scheme> <name>] [(def: #export (<name> server) (-> Server Server) - (function (_ request) - (let [[identification protocol resource message] (integrity.trust request)] - (case (get@ #//.scheme protocol) - <scheme> - (server request) + (function (_ (^@ request [identification protocol resource message])) + (case (get@ #//.scheme protocol) + <scheme> + (server request) - _ - (promise.resolved //response.not-found)))))] + _ + (promise.resolved //response.not-found))))] [#//.HTTP http] [#//.HTTPS https] @@ -32,14 +29,13 @@ (do-template [<method> <name>] [(def: #export (<name> server) (-> Server Server) - (function (_ request) - (let [[identification protocol resource message] (integrity.trust request)] - (case (get@ #//.method resource) - <method> - (server request) + (function (_ (^@ request [identification protocol resource message])) + (case (get@ #//.method resource) + <method> + (server request) - _ - (promise.resolved //response.not-found)))))] + _ + (promise.resolved //response.not-found))))] [#//.Get get] [#//.Post post] @@ -54,24 +50,15 @@ (def: #export (uri path server) (-> URI Server Server) - (function (_ request) - (let [[identification protocol resource message] (integrity.trust request)] - (if (text/= path (get@ #//.uri resource)) - (server request) - (promise.resolved //response.not-found))))) - -(def: #export (sub path server) - (-> URI Server Server) - (function (_ request) - (let [[identification protocol resource message] (integrity.trust request)] - (if (text.starts-with? path (get@ #//.uri resource)) - (server (integrity.taint [identification - protocol - (update@ #//.uri - (|>> (text.clip' (text.size path)) maybe.assume) - resource) - message])) - (promise.resolved //response.not-found))))) + (function (_ [identification protocol resource message]) + (if (text.starts-with? path (get@ #//.uri resource)) + (server [identification + protocol + (update@ #//.uri + (|>> (text.clip' (text.size path)) maybe.assume) + resource) + message]) + (promise.resolved //response.not-found)))) (def: #export (or primary alternative) (-> Server Server Server) diff --git a/stdlib/source/lux/world/net/tcp.jvm.lux b/stdlib/source/lux/world/net/tcp.jvm.lux index bc8468c6b..bd911f95a 100644 --- a/stdlib/source/lux/world/net/tcp.jvm.lux +++ b/stdlib/source/lux/world/net/tcp.jvm.lux @@ -5,9 +5,7 @@ [concurrency ["." promise (#+ Promise promise)] [task (#+ Task)] - ["." frp]] - [security - ["." integrity (#+ Dirty)]]] + ["." frp]]] [data ["." error (#+ Error)]] [world @@ -45,7 +43,7 @@ ############################################################ (signature: #export (TCP !) - (: (Can-Read ! [Nat (Dirty Binary)]) + (: (Can-Read ! [Nat Binary]) read) (: (Can-Write ! Binary) @@ -73,7 +71,7 @@ [#let [data (binary.create size)] bytes-read (InputStream::read data +0 (.int size) input)] (wrap [(.nat bytes-read) - (integrity.taint data)]))) + data]))) (def: (write data) (do (error.with-error io.monad) diff --git a/stdlib/source/lux/world/net/udp.jvm.lux b/stdlib/source/lux/world/net/udp.jvm.lux index 231593de0..2d4ac82a1 100644 --- a/stdlib/source/lux/world/net/udp.jvm.lux +++ b/stdlib/source/lux/world/net/udp.jvm.lux @@ -5,9 +5,7 @@ ["ex" exception (#+ exception:)] [concurrency ["." promise (#+ Promise)] - [task (#+ Task)]] - [security - ["." integrity (#+ Dirty)]]] + [task (#+ Task)]]] [data ["." error (#+ Error)] ["." maybe] @@ -56,7 +54,7 @@ (ex.report ["Address" address])) (signature: #export (UDP !) - (: (Can-Read ! [Nat Location (Dirty Binary)]) + (: (Can-Read ! [Nat Location Binary]) read) (: (Can-Write ! [Location Binary]) @@ -94,7 +92,7 @@ (wrap [bytes-read {#//.address (|> packet DatagramPacket::getAddress InetAddress::getHostAddress) #//.port (.nat (DatagramPacket::getPort packet))} - (integrity.taint data)])))) + data])))) (def: (write [location data]) (do (error.with-error io.monad) diff --git a/stdlib/source/test/lux/world/file.lux b/stdlib/source/test/lux/world/file.lux index b3693f207..4beb4fd69 100644 --- a/stdlib/source/test/lux/world/file.lux +++ b/stdlib/source/test/lux/world/file.lux @@ -2,9 +2,7 @@ [lux #* ["." io (#+ IO)] [control - [monad (#+ do)] - [security - ["." integrity (#+ Dirty)]]] + [monad (#+ do)]] [concurrency ["." promise]] [data @@ -58,7 +56,7 @@ _ (:: file over-write data) content (:: file content []) _ (:: file delete [])] - (wrap (:: binary.equivalence = data (integrity.trust content)))))] + (wrap (:: binary.equivalence = data content))))] (assert "Can write/read files." (error.default #0 result))))) @@ -98,12 +96,10 @@ (wrap (and (n/= (n/* 2 file-size) read-size) (:: binary.equivalence = dataL - (error.assume (binary.slice 0 (dec file-size) - (integrity.trust content)))) + (error.assume (binary.slice 0 (dec file-size) content))) (:: binary.equivalence = dataR - (error.assume (binary.slice file-size (dec read-size) - (integrity.trust content))))))))] + (error.assume (binary.slice file-size (dec read-size) content)))))))] (assert "Can append to files." (error.default #0 result)))) (wrap (do promise.monad diff --git a/stdlib/source/test/lux/world/net/udp.lux b/stdlib/source/test/lux/world/net/udp.lux index 2b85958fa..d3d2531f9 100644 --- a/stdlib/source/test/lux/world/net/udp.lux +++ b/stdlib/source/test/lux/world/net/udp.lux @@ -1,9 +1,7 @@ (.module: [lux #* [control - [monad (#+ do)] - [security - ["." integrity]]] + [monad (#+ do)]] [concurrency ["." promise]] [data @@ -45,12 +43,12 @@ _ (:: client write [[localhost port] from]) [bytes-from [from-address from-port] temp] (:: server read size) #let [from-worked? (and (n/= size bytes-from) - (:: binary.equivalence = from (integrity.trust temp)))] + (:: binary.equivalence = from temp))] #################### _ (:: server write [[from-address from-port] to]) [bytes-to [to-address to-port] temp] (:: client read size) #let [to-worked? (and (n/= size bytes-to) - (:: binary.equivalence = to (integrity.trust temp)) + (:: binary.equivalence = to temp) (n/= port to-port))] #################### _ (:: client close []) |