# eb-local.secrets ::::{zig:module} eb-local.secrets :file: src/secrets.zig :source: https://github.com/stackhands/eb-local/blob/629c1ef39cdece5bfa2145cc8e2e89ae7583d197/src/secrets.zig Secrets for a build: each names the variable eb receives and where its value comes from. A build reads the ones it gets (config.buildSecrets), after every other check; `config --check` and `doctor` read each one and say only whether it can be read. Values go only into eb's environment and are never printed. A failed read reports why without the value. After the build, logs written during it are scanned and every occurrence of a value is replaced. :::: ## Types ::::{zig:type} eb-local.secrets.Resolved :signature: pub const Resolved = struct :source: https://github.com/stackhands/eb-local/blob/629c1ef39cdece5bfa2145cc8e2e89ae7583d197/src/secrets.zig#L26 A secret's value, read for one build: the variable eb receives, and what it is set to. :::{zig:field} eb-local.secrets.Resolved.name :signature: name: []const u8 :source: https://github.com/stackhands/eb-local/blob/629c1ef39cdece5bfa2145cc8e2e89ae7583d197/src/secrets.zig#L27 ::: :::{zig:field} eb-local.secrets.Resolved.value :signature: value: []const u8 :source: https://github.com/stackhands/eb-local/blob/629c1ef39cdece5bfa2145cc8e2e89ae7583d197/src/secrets.zig#L28 ::: :::: ::::{zig:type} eb-local.secrets.Failure :signature: pub const Failure = struct :source: https://github.com/stackhands/eb-local/blob/629c1ef39cdece5bfa2145cc8e2e89ae7583d197/src/secrets.zig#L33 Why a secret could not be read, filled in when `error.Unavailable` is returned. It names the secret and its source, never a value. :::{zig:field} eb-local.secrets.Failure.message :signature: message: []const u8 = "" :source: https://github.com/stackhands/eb-local/blob/629c1ef39cdece5bfa2145cc8e2e89ae7583d197/src/secrets.zig#L34 ::: :::: ::::{zig:type} eb-local.secrets.Nimvault :signature: pub const Nimvault = struct :source: https://github.com/stackhands/eb-local/blob/629c1ef39cdece5bfa2145cc8e2e89ae7583d197/src/secrets.zig#L42 Which nimvault runs and which vault it reads. :::{zig:field} eb-local.secrets.Nimvault.program :signature: program: []const u8 = "" :source: https://github.com/stackhands/eb-local/blob/629c1ef39cdece5bfa2145cc8e2e89ae7583d197/src/secrets.zig#L44 An absolute path; empty means the first nimvault on PATH. ::: :::{zig:field} eb-local.secrets.Nimvault.vault :signature: vault: []const u8 = "" :source: https://github.com/stackhands/eb-local/blob/629c1ef39cdece5bfa2145cc8e2e89ae7583d197/src/secrets.zig#L47 Passed as --vault; ~/ is HOME. Empty leaves nimvault to find the vault from NIMVAULT_VAULT_REPO or the current directory. ::: :::: ::::{zig:type} eb-local.secrets.Failed :signature: pub const Failed = struct :source: https://github.com/stackhands/eb-local/blob/629c1ef39cdece5bfa2145cc8e2e89ae7583d197/src/secrets.zig#L319 A log that could not be checked or rewritten, and why. :::{zig:field} eb-local.secrets.Failed.path :signature: path: []const u8 :source: https://github.com/stackhands/eb-local/blob/629c1ef39cdece5bfa2145cc8e2e89ae7583d197/src/secrets.zig#L320 ::: :::{zig:field} eb-local.secrets.Failed.why :signature: why: []const u8 :source: https://github.com/stackhands/eb-local/blob/629c1ef39cdece5bfa2145cc8e2e89ae7583d197/src/secrets.zig#L321 ::: :::: ::::{zig:type} eb-local.secrets.RedactReport :signature: pub const RedactReport = struct :source: https://github.com/stackhands/eb-local/blob/629c1ef39cdece5bfa2145cc8e2e89ae7583d197/src/secrets.zig#L326 What `redactTree` did: how many logs it rewrote without the values, and the logs it left as they were, by reason. :::{zig:field} eb-local.secrets.RedactReport.files :signature: files: usize = 0 :source: https://github.com/stackhands/eb-local/blob/629c1ef39cdece5bfa2145cc8e2e89ae7583d197/src/secrets.zig#L327 ::: :::{zig:field} eb-local.secrets.RedactReport.too_large :signature: too_large: std.ArrayList([]const u8) = .empty :source: https://github.com/stackhands/eb-local/blob/629c1ef39cdece5bfa2145cc8e2e89ae7583d197/src/secrets.zig#L328 ::: :::{zig:field} eb-local.secrets.RedactReport.too_deep :signature: too_deep: std.ArrayList([]const u8) = .empty :source: https://github.com/stackhands/eb-local/blob/629c1ef39cdece5bfa2145cc8e2e89ae7583d197/src/secrets.zig#L329 ::: :::{zig:field} eb-local.secrets.RedactReport.unchecked :signature: unchecked: std.ArrayList(Failed) = .empty :source: https://github.com/stackhands/eb-local/blob/629c1ef39cdece5bfa2145cc8e2e89ae7583d197/src/secrets.zig#L331 Logs that could not be read, or decompressed, to check them. ::: :::{zig:field} eb-local.secrets.RedactReport.unchanged :signature: unchanged: std.ArrayList(Failed) = .empty :source: https://github.com/stackhands/eb-local/blob/629c1ef39cdece5bfa2145cc8e2e89ae7583d197/src/secrets.zig#L333 Logs that hold a value and could not be rewritten without it. ::: :::: ::::{zig:type} eb-local.secrets.Tools :signature: pub const Tools = struct :source: https://github.com/stackhands/eb-local/blob/629c1ef39cdece5bfa2145cc8e2e89ae7583d197/src/secrets.zig#L337 Where the programs for compressed logs are found, and their environment. :::{zig:field} eb-local.secrets.Tools.path :signature: path: []const u8 :source: https://github.com/stackhands/eb-local/blob/629c1ef39cdece5bfa2145cc8e2e89ae7583d197/src/secrets.zig#L338 ::: :::{zig:field} eb-local.secrets.Tools.envp :signature: envp: proc.Envp :source: https://github.com/stackhands/eb-local/blob/629c1ef39cdece5bfa2145cc8e2e89ae7583d197/src/secrets.zig#L339 ::: :::: ::::{zig:type} eb-local.secrets.Filter :signature: pub const Filter = enum :source: https://github.com/stackhands/eb-local/blob/629c1ef39cdece5bfa2145cc8e2e89ae7583d197/src/secrets.zig#L435 Which files below a directory `redactTree` checks. :::{zig:field} eb-local.secrets.Filter.all :signature: all :source: https://github.com/stackhands/eb-local/blob/629c1ef39cdece5bfa2145cc8e2e89ae7583d197/src/secrets.zig#L437 Every regular file. ::: :::{zig:field} eb-local.secrets.Filter.easybuild_dirs :signature: easybuild_dirs :source: https://github.com/stackhands/eb-local/blob/629c1ef39cdece5bfa2145cc8e2e89ae7583d197/src/secrets.zig#L440 Only files in a directory named "easybuild": the logs and recipes an installation keeps, not the installed software itself. ::: :::: ## Error sets ::::{zig:errorset} eb-local.secrets.Error :signature: pub const Error = error{Unavailable} || Allocator.Error :source: https://github.com/stackhands/eb-local/blob/629c1ef39cdece5bfa2145cc8e2e89ae7583d197/src/secrets.zig#L39 `error.Unavailable` when a secret's source cannot give its value, with the reason in the `Failure`. :::: ## Functions :::{zig:function} eb-local.secrets.resolve :signature: pub fn resolve( a: Allocator, secrets: []const config.Secret, env: *const std.process.Environ.Map, envp: proc.Envp, nv: Nimvault, f: *Failure) Error![]Resolved :source: https://github.com/stackhands/eb-local/blob/629c1ef39cdece5bfa2145cc8e2e89ae7583d197/src/secrets.zig#L124 The value of every secret, in order. ::: :::{zig:function} eb-local.secrets.placeholder :signature: pub fn placeholder(a: Allocator, name: []const u8) Allocator.Error![]const u8 :source: https://github.com/stackhands/eb-local/blob/629c1ef39cdece5bfa2145cc8e2e89ae7583d197/src/secrets.zig#L149 What stands in for a value in a redacted log. ::: :::{zig:function} eb-local.secrets.redactText :signature: pub fn redactText(a: Allocator, bytes: []const u8, values: []const Resolved) Allocator.Error!?[]u8 :source: https://github.com/stackhands/eb-local/blob/629c1ef39cdece5bfa2145cc8e2e89ae7583d197/src/secrets.zig#L253 Replace every value, in each of its forms, in `bytes`; null when none occurs. The longest form wins where several start at the same byte, so a shorter secret that is a prefix of a longer one does not leave the rest behind. Percent-encoding matches either hex case. ::: :::{zig:function} eb-local.secrets.redactTree :signature: pub fn redactTree(a: Allocator, dir_path: []const u8, since: i64, values: []const Resolved, filter: Filter, tools: Tools, report: *RedactReport) (fsx.Error || Allocator.Error)!void :source: https://github.com/stackhands/eb-local/blob/629c1ef39cdece5bfa2145cc8e2e89ae7583d197/src/secrets.zig#L446 Redact regular files below `dir` (never through a symbolic link) modified at or after `since` (seconds); compressed ones through the program their suffix names, from `tools`. ::: ## Constants :::{zig:constant} eb-local.secrets.value_limit :signature: pub const value_limit = 64 * 1024 :source: https://github.com/stackhands/eb-local/blob/629c1ef39cdece5bfa2145cc8e2e89ae7583d197/src/secrets.zig#L20 Largest secret accepted from any source. ::: :::{zig:constant} eb-local.secrets.nimvault_timeout_ms :signature: pub const nimvault_timeout_ms = 30_000 :source: https://github.com/stackhands/eb-local/blob/629c1ef39cdece5bfa2145cc8e2e89ae7583d197/src/secrets.zig#L22 How long nimvault may take (a GPG agent may ask for a passphrase). ::: :::{zig:constant} eb-local.secrets.min_redacted_len :signature: pub const min_redacted_len = 4 :source: https://github.com/stackhands/eb-local/blob/629c1ef39cdece5bfa2145cc8e2e89ae7583d197/src/secrets.zig#L247 Shorter values would match ordinary text everywhere; they are not redacted, and a build that has one is told so. ::: :::{zig:constant} eb-local.secrets.log_limit :signature: pub const log_limit: usize = 1 << 30 :source: https://github.com/stackhands/eb-local/blob/629c1ef39cdece5bfa2145cc8e2e89ae7583d197/src/secrets.zig#L311 Largest log rewritten; a larger one is reported, not rewritten. ::: :::{zig:constant} eb-local.secrets.max_depth :signature: pub const max_depth = 16 :source: https://github.com/stackhands/eb-local/blob/629c1ef39cdece5bfa2145cc8e2e89ae7583d197/src/secrets.zig#L313 Deepest directory searched; anything deeper is reported. ::: :::{zig:constant} eb-local.secrets.codec_timeout_ms :signature: pub const codec_timeout_ms = 30 * 60_000 :source: https://github.com/stackhands/eb-local/blob/629c1ef39cdece5bfa2145cc8e2e89ae7583d197/src/secrets.zig#L316 How long a decompressor or compressor may take over one log. :::