Home / Docs / Configure a package
[labels] categories
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.
[package]
name = "shop"
version = "0.1.0"
edition = "0.2"
[labels]
categories = ["PII", "Location"]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_yearForms
[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:
[package]
name = "shop"
version = "0.1.0"
edition = "0.2"-- fails with U4007
module shop
pub tagged(birth_year: secret[PII] Int) -> secret[PII] Int = birth_yearEdge cases
Names are UpperCamelCase:
[package]
name = "shop"
version = "0.1.0"
edition = "0.2"
[labels]
categories = ["pii"]-- fails with U1005
module shop
pub price(cents: Int) -> Int = centsEach name once:
[package]
name = "shop"
version = "0.1.0"
edition = "0.2"
[labels]
categories = ["PII", "PII"]-- fails with U1002
module shop
pub price(cents: Int) -> Int = centsEach name is a string:
[package]
name = "shop"
version = "0.1.0"
edition = "0.2"
[labels]
categories = [1]-- fails with U7002
module shop
pub price(cents: Int) -> Int = centsFurther rules:
- Order. A label is below another when its level is not higher and its categories are a subset. See labels.
Diagnostics
- U1002: a category listed twice.
- U1005: a category name that is not UpperCamelCase.
- U4007: a label that names an undeclared category.
- U7002: a
categoriesthat is not an array of strings.
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
- spec/13 §7:
[labels]. - spec/07 §2: labels and categories.