Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
research:software:obsec [2017/04/25 18:30] – racruz | research:software:obsec [2017/05/18 03:54] (current) – racruz | ||
---|---|---|---|
Line 2: | Line 2: | ||
ObSec is a simple object-oriented language that supports type-based declassification. ObSec was introduced in the paper | ObSec is a simple object-oriented language that supports type-based declassification. ObSec was introduced in the paper | ||
- | {{bib> | + | {{bib> |
This tutorial covers: | This tutorial covers: | ||
- | * how to install a web interpreter (ObSec Pad) for the ObSec language | + | * how to install a web interpreter (ObSec Pad) for the ObSec language. |
- | * a basic presentation of the language syntax | + | * a basic presentation of the language syntax, |
- | * the type-based declassification examples that appears | + | * the type-based declassification examples that appear |
Line 14: | Line 14: | ||
We provide three ways to access to the ObSec Pad (although we strongly recommend the first one!): | We provide three ways to access to the ObSec Pad (although we strongly recommend the first one!): | ||
- | - **Using the online ObSec Pad** at [[https:// | + | - **Using the online ObSec Pad** at [[https:// |
- | - **With the virtual machine**, which can be downloaded [[https:// | + | - **With the virtual machine**, which can be downloaded [[https:// |
- **Local execution of the ObSec Pad**, which can be downloaded [[https:// | - **Local execution of the ObSec Pad**, which can be downloaded [[https:// | ||
Line 55: | Line 55: | ||
</ | </ | ||
+ | ===== ObSec Pad: Functionality===== | ||
The following screenshot shows how the ObSec Pad looks like | The following screenshot shows how the ObSec Pad looks like | ||
Line 60: | Line 61: | ||
Note that even though we provide some predefined examples, we suggest you finish this tutorial first. It will help you understand the syntax of ObSec and how to define and use type-based declassification policies. | Note that even though we provide some predefined examples, we suggest you finish this tutorial first. It will help you understand the syntax of ObSec and how to define and use type-based declassification policies. | ||
+ | |||
+ | The ObSec Pad has the minimal functionality you expect for an interpreter: | ||
+ | * Details of the language syntax. | ||
+ | * Type checking. It gives you the type of the program or an error if the program is not well-typed or if it has a syntax error. | ||
+ | * Execution. If the program was well-typed (as the result of clicking " | ||
+ | |||
===== Introduction to ObSec : Warm up ===== | ===== Introduction to ObSec : Warm up ===== | ||
Line 94: | Line 101: | ||
{{: | {{: | ||
- | You can define and use object types in different ways. Below, we illustrate by creating an object type with a login method that takes two public strings and returns a public integer: | + | You can define and use object types in different ways. Below, we illustrate |
* Inline structural type definition: the type is defined (anonymously) where it is used < | * Inline structural type definition: the type is defined (anonymously) where it is used < | ||
[{login: String String -> Int}] | [{login: String String -> Int}] | ||
Line 302: | Line 309: | ||
Any method invocation over the '' | Any method invocation over the '' | ||
+ | |||
+ | |||
+ | |||
+ | === Simple Case of Study: Web App with Payment System === | ||
+ | The following program illustrates a more elaborated example where different declassification policies are used in an application that processes user payments. | ||
+ | The application has 4 modules: | ||
+ | * '' | ||
+ | * '' | ||
+ | * '' | ||
+ | * '' | ||
+ | |||
+ | The types '' | ||
+ | |||
+ | The implementation of the method '' | ||
+ | |||
+ | < | ||
+ | let{ | ||
+ | type StringHashEq = [{hash : -> Int<[{== : Int -> Bool}]}] | ||
+ | type CCPolicy = [{last4Digits: | ||
+ | | ||
+ | type CreditCard = [{number: -> String} | ||
+ | | ||
+ | | ||
+ | |||
+ | type UserPolicy = [{name: -> | ||
+ | | ||
+ | | ||
+ | type User = [{name: -> | ||
+ | | ||
+ | | ||
+ | |||
+ | | ||
+ | |||
+ | | ||
+ | type Controller = [{payInternet: | ||
+ | type View = [{show : String -> String}] | ||
+ | type PaymentGateWay = [{pay: String CreditCard< | ||
+ | | ||
+ | type UserManager = [{verifyCredentials: | ||
+ | {getUserCreditCard: | ||
+ | | ||
+ | val paymentGateWay = new {pg: | ||
+ | def pay user cc service | ||
+ | } | ||
+ | val userManager = let{ | ||
+ | type Backend = [{findUser: String -> User< | ||
+ | val backend = new {b:Backend => | ||
+ | def findUser login = | ||
+ | new {u:User => | ||
+ | def name = login | ||
+ | def password = " | ||
+ | def creditCard = | ||
+ | new {cc : CreditCard => | ||
+ | def number = " | ||
+ | def securityNumber = " | ||
+ | def last4Digits = " | ||
+ | } | ||
+ | } | ||
+ | } | ||
+ | | ||
+ | } in | ||
+ | new {z: | ||
+ | def verifyCredentials login password = | ||
+ | let{ | ||
+ | val dbUser = backend.findUser(login) | ||
+ | } | ||
+ | in | ||
+ | if dbUser.password().hash().==(password.hash()) | ||
+ | then true | ||
+ | else false | ||
+ | | ||
+ | def getUserCreditCard login = backend.findUser(login).creditCard() | ||
+ | } | ||
+ | | ||
+ | val view = new {v:View => | ||
+ | def show s = s | ||
+ | } | ||
+ | val controller = new {z : Controller => | ||
+ | def payInternet loginFromWeb | ||
+ | if userManager.verifyCredentials(loginFromWeb, | ||
+ | then | ||
+ | let{ | ||
+ | val cc = userManager.getUserCreditCard(loginFromWeb) | ||
+ | } | ||
+ | in | ||
+ | if paymentGateWay.pay(loginFromWeb, | ||
+ | then | ||
+ | view.show(cc.last4Digits()) | ||
+ | else | ||
+ | view.show(" | ||
+ | else | ||
+ | view.show(" | ||
+ | } | ||
+ | } | ||
+ | in | ||
+ | controller.payInternet(" | ||
+ | </ | ||
+ | |||
+ | Variations to the above program that do not respect the policies and hence are not well-typed: | ||
+ | * change the expression '' | ||
+ | * remove the method '' | ||
+ | * change the signature of the method '' |