Home / Docs / Language guide

Information flow

Release v0.4.0

8.1 Labels

Every type can carry a label: secret[PII] Phone, internal Hashed. A type without a label is public.

8.2 Explicit and implicit flows

una
module demo

pub kind Person
  name: Text
  age: secret Int

--- The branch is on secret data, so the result is secret too.
pub adult_flag(r: Person) -> secret Int = if r.age > 17 then 1 else 0

8.3 Failing and calling under a raised pc

una
-- fails with U4002
module demo

pub kind PinError = | Rejected

pub check(pin: secret Int) -> secret Int
  fails PinError
=
  if pin == 1234
    1
  else
    fail Rejected

8.4 Sinks

una
-- fails with U4003
module demo

pub show(phone: secret Text) -> Unit
  uses @console: Console[print]
=
  @console.print("phone {phone}")

8.5 Declassification: policies in trusted modules

Labels are lowered only through a declared policy, inside a trusted module:

una.tomltoml
[package]
name = "events"
version = "0.1.0"
edition = "0.2"

[labels]
categories = ["PII"]

[trusted]
modules = ["events.keys"]
src/events/types.unauna
module events.types

pub kind Phone = Text where valid_phone(it)

pub predicate opaque valid_phone(t: Text) -> Bool = t.len == 11 and is_digits(t)
src/events/keys.unauna
trusted module events.keys

import events.types (Phone)

pub policy attendee_key
  from secret[PII] Phone
  to internal Hashed
  via hmac_phone
  purpose "registration lookup and audit correlation"
  owner privacy

hmac_phone(phone: secret[PII] Phone) -> internal Hashed
  uses @keys: Keys[hmac]
  fails KeyError
=
  @keys.hmac(key_name: "phone_pepper", data: phone)
    if error pass

8.6 What the guarantee covers

Una guarantees termination-insensitive noninterference up to declassification. The channels in the model are values, failures, operation arguments and the occurrence of effects. Timing, termination and resource usage are outside the model, and so is the relative order of the effects of concurrent tasks (§5.7); the build report says so.


Constructs