Professional Documents
Culture Documents
(c) MLstate
Web
(c) MLstate
Web browser
JS
(c) MLstate
C S S X
JS
F R S c a t At ks
er f f Bu
r e ov
s w o n o i ct
Web browser
HTTP Server
e d o
e j n i
Language Database
DB injection
(c) MLstate
C S S X
JS
F R S c a t At ks
er f f Bu
r e ov
s w o n o i ct
Web browser
HTTP Server
e d o
e j n i
Language Database
DB injection
(c) MLstate
This is JavaScript
> 9 + 5 + customers 14 customers > Customers: + 9 + 5 Customers: 95
(c) MLstate
This is JavaScript
if (x == 0) retry(); else if (x == 1) success(); else error(); switch (x) { case 0: retry(); break; case 1: success(); break; default: error(); }
(c) MLstate
x = 0
if (x == 0) retry(); else if (x == 1) success(); else error(); switch (x) { case 0: retry(); break; case 1: success(); break; default: error(); } error
retry
(c) MLstate
This is JavaScript
[] [] {} {} + + + + [] {} [] {}
(c) MLstate
This is JavaScript
[] [] {} {} + + + + [] = {} = [] = {} = {} 0 NaN
(c) MLstate
Trustworthiness?
(c) MLstate
Complex Systems?
(c) MLstate
(c) MLstate
Built on standards.
Client code
Server code
DB code
Configuration
(c) MLstate
Client code
Server code
DB code
Configuration
(c) MLstate
(c) MLstate
One language for the whole application Glue & checks generated automatically No impedance mismatch
(c) MLstate
One language for the whole application Glue & checks generated automatically No impedance mismatch
Clean-slate design Based on formal methods Safe languages from the bottom up
(c) MLstate
One language for the whole application Glue & checks generated automatically No impedance mismatch
Clean-slate design Based on formal methods Safe languages from the bottom up
Just a distributed system In which not all principals are trusted And communications use web standards Security is (mostly) automatic
(c) MLstate
Clean-slate design Based on formal methods Safe languages from the bottom up
No knowledge required
Just a distributed system In which not all principals are trusted And communications use web standards Security is (mostly) automatic
(c) MLstate
function action(_) { #msg = <>Hello!</>; } function page() { <div class="well"> <h2 id=#msg>Click the button:</h2> <button class="btn" onclick={action}> Click! </button> </div> } Server.start( Server.http, { ~page, title: "Hello, world" } )
(c) MLstate
function action(_) { #msg = <>Hello!</>; } function page() { <div class="well"> <h2 id=#msg>Click the button:</h2> <button class="btn" onclick={action}> Click! </button> </div> } Server.start( Server.http, { ~page, title: "Hello, world" } )
(c) MLstate
Configuration
function action(_) { #msg = <>Hello!</>; } function page() { <div class="well"> <h2 id=#msg>Click the button:</h2> <button class="btn" onclick={action}> Click! </button> </div> } Server.start( Server.http, { ~page, title: "Hello, world" } )
(c) MLstate
View
Configuration
Actions
function action(_) { #msg = <>Hello!</>; } function page() { <div class="well"> <h2 id=#msg>Click the button:</h2> <button class="btn" onclick={action}> Click! </button> </div> } Server.start( Server.http, { ~page, title: "Hello, world" } )
(c) MLstate
View
Configuration
function action(_) { #msg = <>Hello!</>; } function page() { <div class="well"> <h2 id=#msg>Click the button:</h2> <button class="btn" onclick={action}> Click! </button> </div> } Server.start( Server.http, { ~page, title: "Hello, world" } )
(c) MLstate
function action(_) { #msg = <>Hello!</>; } function page() { <div class="well"> <h2 id=#msg>Click the button:</h2> <button class="btn" onclick={action}> Click! </button> </div> } Server.start( Server.http, { ~page, title: "Hello, world" } )
(c) MLstate
JavaScript syntax
function action(_) { #msg = <>Hello!</>; } function page() { <div class="well"> <h2 id=#msg>Click the button:</h2> <button class="btn" onclick={action}> Click! </button> </div> } Server.start( Server.http, { ~page, title: "Hello, world" } )
(c) MLstate
JavaScript syntax
function action(_) { #msg = <>Hello!</>; } function page() { <div class="well"> <h2 id=#msg>Click the button:</h2> <button class="btn" onclick={action}> Click! </button> </div> } Server.start( Server.http, { ~page, title: "Hello, world" } )
(c) MLstate
Type inference
function foo(s) { String.length(s); } function bar(x, y) { foo(x) + y; }
int function foo(string s) { String.length(s); } int function bar(string x, int y) { foo(x) + y; }
(c) MLstate
Type checking
foo = 1 + "bar";
Types int and string are not compatible
(c) MLstate
(c) MLstate
case {some: 13}: callback(get()); case {some: 37}: move({lef}); case {some: 38}: move({up}); case {some: 39}: move({right});
(c) MLstate
No field lenght found. Most probable field: length: string -> int
(c) MLstate
(c) MLstate
Type blocks
int string float { label: type, ... } bool option list set map client / server
type or type
modules
functor
abstract
(c) MLstate
1 2 3 4 5
Code distribution Data protection Impedance mismatch Blocking code Protocol bugs and vulnerabilities
(c) MLstate
(c) MLstate
(c) MLstate
Client or server
client server
(c) MLstate
Secure access
exposed protected
(c) MLstate
Data declaration
type user = { string mail, int age, list(string) comments } database dbname { user /user[{mail}] int /user/age = 18 } // primary key // default value
(c) MLstate
Data queries
/db/col[name == v; order -score; limit 50];
(c) MLstate
Data queries
/db/col[n > 10 and n < 20];
opa
use db db.col.find( {$and : [{ n : { $gt : 10 } }, { n : { $lt : 20 } } ] })
(c) MLstate
mongoDB shell
Data updates
/db/path[id == id] <- { n += 1, l <+ e }
l l l l
(c) MLstate
Blocking?
function fibonacci(n) { if (n == 0) 0 else if (n == 1) 1 else fibonacci(n-1) + fibonacci(n-2) }
(c) MLstate
Blocking? No.
(c) MLstate
Blocking? No.
Clients sockets Scheduler CPS
HTTP Server FTP Server SMTP Server
(c) MLstate
Grammar
Automaton
wait_for_request(hr, timeout): receive | Crlf -> ... | Head (uri, v) -> ... | Get (uri, v) -> ... | Post (uri, v) -> ... | Put (uri, v) -> ... | Del (uri, v) -> ... | Trace (uri, v) -> ... | Conn (uri, v) -> ... catch | exn -> ... after timeout -> ...
(c) MLstate
1 2 3 4 5
Precise control on code distribution Protected data by default Transparent database mapping Non-blocking Safe protocols
(c) MLstate
Transparent protections
(c) MLstate
Transparent protections
user_update(x:mess) = ( line = <div class="opa-line"> <div class="opa-wrap"><div class="opa-user">{x.id}:</div> <div class="opa-message">{x.message}</div></div> </div> do exec([#show +<- line ]) Page.set_scroll_top(#show, Page.get_height(#show) +Page.get_scroll_top(#show)) )
(c) MLstate
Transparent protections
(c) MLstate
Transparent protections
make_broadcaster(id) = _ -> Network.broadcast({~id message=Page.get_value(#entry)}, room) All communications are checked
(c) MLstate
Transparent protections
(c) MLstate
Transparent protections
styled_page("Chat",//Display <script onload={_ -> connect()}/> <div id="header"><div id="logo"></div></div> <div id="show"></div> <input id="entry"/> <div class="opa-button" onclick={broadcast}>Send!</div> )
Per-user capability?*
(c) MLstate
Transparent protections
(c) MLstate
(c) MLstate
A1-Injection A2-Cross Site Scripting (XSS) A3-Broken Authentication and Session Management A4-Insecure Direct Object References A5-Cross Site Request Forgery (CSRF)
A6-Security Misconguration A7-Insecure Cryptographic Storage A8-Failure to Restrict URL Access A9-Insufcient Transport Layer Protection A10-Unvalidated Redirects and Forwards
(c) MLstate
(c) MLstate
(c) MLstate
(c) MLstate
(c) MLstate
Opah (Moonsh)
(c) MLstate
Opa (Language)
(c) MLstate
opalang.org
@opalang
(c) MLstate