Home / Docs / Configure a package

[labels] categories

Release v0.4.0Edition 0.1 and laterU1002U1005U4007U7002

What it does

A label marks how sensitive a value is, so the checker can keep it from reaching a place that must not see it, such as the console. A label is a level, one of public, internal, confidential, secret and restricted from least to most sensitive, and a set of categories, names that say what kind of data it is, such as PII for personal data. categories declares the categories the package's code may use, as in secret[PII]. A value flows only to labels at least as high in both.

Learn more: Categories and Labels and how they follow data.

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

[labels]
categories = ["PII", "Location"]
src/shop.unauna
module shop

pub tagged(birth_year: secret[PII] Int) -> secret[PII] Int = birth_year

pub wider(birth_year: secret[PII] Int) -> restricted[PII, Location] Int = birth_year

Forms

toml
[labels]
categories = ["<UpperCamelCase name>", ...]

An array of category names, each in UpperCamelCase (words run together, each starting with a capital letter, as PII or ShippingAddress) and unique. Without the table, a package declares no categories.

Examples

A label may name only declared categories:

una.tomltoml
[package]
name = "shop"
version = "0.1.0"
edition = "0.2"
src/shop.unauna
-- fails with U4007
module shop

pub tagged(birth_year: secret[PII] Int) -> secret[PII] Int = birth_year

Edge cases

Names are UpperCamelCase:

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

[labels]
categories = ["pii"]
src/shop.unauna
-- fails with U1005
module shop

pub price(cents: Int) -> Int = cents

Each name once:

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

[labels]
categories = ["PII", "PII"]
src/shop.unauna
-- fails with U1002
module shop

pub price(cents: Int) -> Int = cents

Each name is a string:

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

[labels]
categories = [1]
src/shop.unauna
-- fails with U7002
module shop

pub price(cents: Int) -> Int = cents

Further rules:

Diagnostics

Edition

Categories are the same in editions 0.1 and 0.2. From edition 0.4 they are written in the labels section of ita.una, one category per line (see ita.una).

Normative source