Home / Docs / Diagnostics
U4004: policy outside a trusted module
Release v0.4.0
A module whose header does not say trusted declares a policy.
Why Una rejects it
A policy lowers labels, so it is part of the trusted computing base. It is allowed only in a module whose header says trusted module and that una.toml lists under [trusted] modules, or from edition 0.4 the trusted section of ita.una (spec/07 §5, §6).
U4004 reports a policy in a module whose header does not say trusted. A header that says trusted without the listing is U7005.
How to fix it
- The repair that keeps the trusted base comes first: move the policy and its
viafunction into a module that is already trusted, as the fixed example does. - Declaring this module trusted in both places is the last repair, marked as an escape (ADR 0095): every line of a trusted module joins the trusted base and is listed in the build report.
The repair at a glance
src/keys.una
trusted module keys
pub pepper() -> Int = 7
+
+ pub policy reveal
+ from secret Text
+ to Text
+ via shown
+ purpose "show a digest"
+ owner privacy
+
+ shown(t: secret Text) -> Text = tsrc/demo.una
module demo
- pub policy reveal
- from secret Text
- to Text
- via shown
- purpose "show a digest"
- owner privacy
-
- shown(t: secret Text) -> Text = t
+ pub one() -> Int = 1Failing example
una.toml
[package]
name = "demo"
version = "0.1.0"
edition = "0.1"
[trusted]
modules = ["keys"]src/keys.una
trusted module keys
pub pepper() -> Int = 7src/demo.una
module demo
pub policy reveal
from secret Text
to Text
via shown
purpose "show a digest"
owner privacy
shown(t: secret Text) -> Text = tFixed example
una.toml
[package]
name = "demo"
version = "0.1.0"
edition = "0.1"
[trusted]
modules = ["keys"]src/keys.una
trusted module keys
pub pepper() -> Int = 7
pub policy reveal
from secret Text
to Text
via shown
purpose "show a digest"
owner privacy
shown(t: secret Text) -> Text = tsrc/demo.una
module demo
pub one() -> Int = 1