Secret and configuration commands
The secret and configuration commands manage the full lifecycle of fnox data. They create and inspect configuration, change secret declarations, move values between formats and providers, manage stored files, and check that the resulting setup is safe to use. These commands share the active configuration and profile rules described in Command-line interface; provider setup and diagnostics are covered in Provider and diagnostic commands, activity review is covered in Audit commands, and downstream publication is covered in Push target integrations.
Command context
Configuration context
Every command that reads or changes secrets works from an effective configuration. With the default fnox.toml selection, fnox searches upward through the current directory and merges project files with the global file. An explicit path such as -c ./ci.toml selects that file and its imports instead of the upward search. The global file remains a base layer in both cases.
The config-files command shows the paths that this process will load. During discovery, it walks upward until it finds a configuration level marked as the project root and reports existing imported files. With an explicit path, it validates the selected file and its imports before reporting them. It also checks the global file and its imports, even when a project import already names the global file. This makes errors visible when the load plan cannot complete.
fnox config-files
fnox -c ./ci.toml config-files
Configuration files can also mark a level as the project root. This stops the parent walk but does not remove the global layer. Use the command when a result depends on file location or imports and the load order is not clear.
References: crates/…/config.rs• L619-670 crates/…/config.rs• L709-792 src/…/config_files.rs• L21-79 src/…/config_files.rs• L84-139
Profile context
A profile is a named set of environment-specific providers and secrets. The default profile uses the top-level configuration. Named profiles add an overlay, and multiple active profiles overlay in the order given. Top-level secrets normally remain the base; --no-defaults removes that base for non-default profiles.
Profile selection comes from repeated or comma-separated --profile values, then from FNOX_PROFILE, and finally from the default profile. Read commands can use the complete active stack. A write command must know one target profile. With one active profile it uses that profile; with several active profiles it requires --write-profile.
fnox --profile staging list
fnox --profile aws,prod --write-profile prod set DATABASE_URL
References: src/…/mod.rs• L45-86 crates/…/config.rs• L1321-1381 crates/…/config.rs• L1418-1440
Configuration lifecycle
The main configuration flow moves from creating a file to reviewing its effective content and then changing individual declarations. The commands write to the selected local, profile-specific, or global source instead of asking the engineer to rebuild the whole file by hand.
Configuration initialization
fnox init creates a new configuration file at the selected path. In an interactive terminal it can run a setup wizard for the first provider and an example secret. In non-interactive use or with --skip-wizard, it creates a minimal configuration. --global targets the per-user configuration, and an existing file needs --force before fnox replaces it. The command creates missing parent directories for an explicit project path or the global path.
The wizard asks whether to configure a provider, then guides provider category and provider selection, collects the provider fields, and lets the user choose the provider name. It tests the provider connection before saving. A failed test or provider creation step does not prevent the configuration from being saved, so setup can finish before access details are corrected. The wizard can also add an example secret declaration without a value; the value can be added later with fnox set.
fnox init
fnox init --global
fnox init --skip-wizard
References: src/…/init.rs• L8-16 src/…/init.rs• L39-101 src/…/init.rs• L103-178 src/…/init.rs• L282-313
Secret inspection
fnox list gives a safe view of the effective secret set. It shows each key, its source kind, provider key, and description. --sources adds the defining file, while --values resolves and displays values for deliberate inspection. Provider keys are shortened unless --full is used. Shell completion uses a hidden completion mode that prints keys only.
fnox get KEY resolves one secret and prints its value. --refresh asks fnox to fetch the value again instead of using a cached daemon result. A configured lease-produced key can also be resolved through its lease workflow. A secret marked as file-based produces a restricted temporary file and prints that file path instead of the value. --base64-decode decodes a secret after resolution.
fnox get --file PATH resolves a managed file and prints its content instead of a secret value. The file mode does not use secret-only options such as --refresh or --base64-decode. Missing-value policy still applies to secret reads, so a permitted missing secret can produce no output rather than an error.
fnox list --sources
fnox get DATABASE_URL
fnox get DATABASE_URL --refresh
fnox get CERTIFICATE --base64-decode
fnox get --file ~/.kube/config
Treat list --values and get as secret-revealing operations. They are useful for diagnosis, but they should not be placed in logs or shared terminal output.
References: src/…/list.rs• L12-30 src/…/list.rs• L88-149 src/…/get.rs• L9-18 src/…/get.rs• L32-49 src/…/get.rs• L58-97 src/…/get.rs• L99-131 src/…/get.rs• L132-267 src/…/get.rs• L287-412
Secret changes
Secret setting
fnox set KEY creates or updates one secret declaration in the write target. The value can come from a command argument, piped standard input, a hidden prompt, a file, or the built-in random generator. The command can also update metadata without changing the value, such as a description, a URL, a default, or missing-value behavior.
The selected provider determines what is stored. An encryption provider stores protected data in the configuration. A remote storage provider stores the remote key and writes the value to that provider. Without a provider, fnox keeps a plain value and uses it as the default. --base64-encode transforms the input before this provider step, and --dry-run reports the planned target without writing. With the default fnox.toml argument, the write target is found from the current directory and write profile. A different --config value is treated as the explicitly selected file.
When a secret already exists in the target source, set keeps its remote key only when the selected provider is the same. An inherited secret is copied into a local override with its existing settings before the update, but its remote key is not treated as belonging to the new target file. If the provider changes, the command uses the environment key unless --key-name supplies a new remote name. This avoids carrying a key that belongs to a different provider or source. A generated value still refuses to replace an existing secret unless --force is present, and writing a new value clears any stale sync cache for that secret.
The --open option uses the secret URL before the hidden value prompt. An explicit --url takes priority; otherwise fnox uses the URL on the write-target secret and then the active secret. It prints the URL even when a browser cannot open it, and a missing URL produces a warning before the prompt continues. This mode requires an interactive terminal. A URL can also be recorded as metadata without changing the value when --url is used by itself.
Generated values use the normal provider path and do not print unless --show is used. Use standard input or the prompt for sensitive values. Passing a value as an argument can expose it through shell history and process listings.
printf '%s' "$TOKEN" | fnox set API_TOKEN --provider age
fnox set SSH_KEY --from-file ~/.ssh/id_ed25519
fnox set API_TOKEN --description "Token for the API"
fnox set API_TOKEN --url https://vault.example.test/api-token --open
fnox set API_TOKEN --generate --length 48
fnox set API_TOKEN --dry-run
References: src/…/set.rs• L9-23 src/…/set.rs• L32-113 src/…/set.rs• L119-133 src/…/set.rs• L242-268 src/…/set.rs• L271-325 src/…/set.rs• L349-668 src/…/set.rs• L671-707 src/…/set.rs• L710-792
Configuration editing
fnox edit opens the selected configuration in an editor with available secret values shown in a temporary file. It has three related modes. Without a key or file, it exposes the decrypted values for all top-level and named-profile secrets. With a key, it exposes only that secret's raw value. With --file PATH, it edits the content of a managed file rather than a secret. Each mode writes a changed value back through its provider while preserving the other configuration settings.
The full-file mode keeps the user's comments, formatting, and non-secret changes. It restores unchanged encrypted values to avoid needless ciphertext changes. New or changed entries use their explicit or profile default provider when one is available; entries without a provider remain plain. Providers from the edited file and its imports are available for the save, while providers from outer configuration layers remain available when needed. Removing a provider from the edited file does not silently restore it from that same file's old state.
The single-secret mode edits the full stored value, not a selected JSON path, line, or sync cache. It writes to the file that defines the secret when possible. If the secret is a local sync cache, the command updates the shared source and removes the old cache entry so the cache cannot shadow the new value. Read-only remote secrets cannot be changed through either secret edit mode.
The managed-file mode resolves the file content, opens it in the same editor, and stores the changed content through the file's declaring profile. A file is a stored payload keyed by its path; it is not an environment variable.
The temporary file contains plaintext and uses restrictive file access. It must be treated as sensitive. The command removes its temporary header before it saves the final configuration. The editor command comes from EDITOR, then VISUAL, and then the platform default; editor arguments are supported when quoted correctly.
EDITOR=vi fnox edit
fnox --profile staging edit
fnox --profile staging edit KUBECONFIG
fnox edit --file ~/.kube/config
References: src/…/edit.rs• L21-47 src/…/edit.rs• L125-264 src/…/edit.rs• L266-421 src/…/edit.rs• L424-551 src/…/files.rs• L389-433
Secret removal
fnox remove KEY deletes one declaration from the chosen source file. It checks the write-target profile rather than deleting an inherited value from a parent file. This preserves the layered model: removing a local override can reveal a value from a lower-priority file.
Use --global for the per-user file and --dry-run to inspect the target before making the change. The command preserves the rest of the file and reports an error when the key is not present in the selected source. Removing a declaration does not delete or revoke the value already stored at a remote provider.
With --file PATH, the command removes the managed-file entry from the configuration that declares it. The file on disk and its stored content remain in place.
fnox remove OLD_TOKEN
fnox remove OLD_TOKEN --global --dry-run
fnox remove --file ~/.kube/config
References: src/…/remove.rs• L5-11 src/…/remove.rs• L43-81 src/…/remove.rs• L83-152 src/…/files.rs• L435-497
Managed file lifecycle
Managed files let fnox protect file content and later restore it at a known path. The file commands use the same profile, provider, sync, and write-target rules as secrets, but they keep the content associated with a path instead of exposing it as an environment variable.
Managed file storage
fnox set --file PATH stores the current content of PATH, or the content of --from-file, under the file declaration. The provider can encrypt the content or store it remotely. A source setting can keep the protected content in a separate file relative to the global configuration directory. New content clears an old sync cache so the stored content remains the source of truth until the next sync.
fnox files lists the managed files for the active profiles without reading their content. fnox files write resolves and writes selected files back to their declared paths. It gives each restored file restrictive permissions and replaces the destination rather than following a symlink.
References: src/…/set.rs• L202-208 src/…/set.rs• L277-307 src/…/files.rs• L13-18 src/…/files.rs• L41-151 src/…/files.rs• L223-365
Secret transfer
The transfer commands connect fnox configuration to other representations or providers. Import brings values into protected configuration. Export creates values for another tool or process. Sync creates a protected local copy of values that come from a different provider.
Secret import
fnox import reads a flat set of key/value secrets from standard input or a file. It accepts environment assignment, JSON, YAML, or TOML input. Environment input can use export assignments, quoted values, escaped characters, and multiline single-quoted values. The command can filter names with a regular expression and add a common prefix before storing them.
Import validates the resulting names before it looks up the provider or writes a file. It requires an encryption-capable provider; remote storage providers are not valid import targets. It encrypts each value before writing the selected profile and keeps existing metadata when a key already exists. In default configuration discovery, the write target follows the selected profile's local configuration. File input normally gets a confirmation prompt. Standard-input import requires --force or --dry-run because the input has already been consumed when confirmation would occur.
fnox import --provider age --input .env env
cat secrets.json | fnox import json --provider age --force
fnox import env --provider age --filter '^APP_' --prefix DEV_
References: src/…/import.rs• L64-174 src/…/import.rs• L176-274 src/…/import.rs• L277-417 src/…/import.rs• L472-499 src/…/import.rs• L502-551
Secret export
fnox export resolves the active secret set and writes it to standard output or a file. It supports dotenv-style environment output, sourceable POSIX shell output, JSON, YAML, and TOML. --header adds context comments to environment and shell output.
By default, export includes only secrets allowed in the shell. Secrets marked as exec-only or never-injected stay out of the result unless --all is used. File-based secrets become paths to temporary files so consumers receive the expected file interface. Use --dry-run with an output path to see the keys without writing it.
fnox export --format shell
fnox export --format json --output secrets.json
fnox export --all --dry-run --output /tmp/export.env
Source shell output with care. It is intended to create environment assignments, so the output itself is sensitive and can affect the receiving shell.
References: src/…/export.rs• L13-52 src/…/export.rs• L67-175 src/…/export.rs• L177-215
Provider synchronization
fnox sync copies current raw values from configured source providers into a local encryption provider. It is useful when a team or service reads from a remote system but needs a protected local snapshot for a different use. The target defaults to the active default_provider, or can be named with --provider; the target must support encryption.
Only secrets with a configured source provider that differs from the target are candidates. Secrets that have only an environment value or only the default provider are skipped. Keys, source provider, and a regular expression can narrow the set. The command resolves current raw source values before encrypting them, so a later sync can pick up source changes without using an old local cache or a processed view of the value. It may resolve provider dependencies, but it caches only the selected keys. Unresolved values are skipped. It asks for confirmation unless forced and supports dry-run output.
The same flow can cache managed files. Secret caches go to the selected config, the global config, or an adjacent local override file with --local-file; file caches remain with the configuration that declares the file. Local-file mode requires the bare discovered config name. A full local-file sync removes stale secret caches that no longer have a matching source and removes stale managed-file caches when their source now matches the target. Personal entries remain in the local file, but an obsolete sync cache is cleared when that entry no longer needs a remote source. A marker distinguishes a personal source from a cache copy so cleanup does not remove the personal declaration.
fnox sync --provider age --source aws --force
fnox sync DATABASE_URL --local-file
fnox sync --filter '^APP_' --dry-run
References: src/…/sync.rs• L14-29 src/…/sync.rs• L126-203 src/…/sync.rs• L205-275 src/…/sync.rs• L303-435 src/…/sync.rs• L445-557 src/…/sync.rs• L560-731 src/…/sync.rs• L741-779
Secret safety checks
Plaintext secret scanning
fnox scan searches a directory for likely plaintext credentials before they enter source control or logs. It reports the file, position, detector, severity, and a redacted match. It honors common ignore sources such as version-control ignore rules and also accepts repeated --ignore globs.
Human output explains findings. JSON output supports other tools, while --quiet emits only affected paths. Any finding gives the command a failure result, which makes it suitable as a CI gate. The scan skips binary and very large files and does not print the full matched secret.
fnox scan .
fnox scan --format json --quiet
fnox scan . --ignore '*.example' --ignore vendor/
References: src/…/scan.rs• L17-43 src/…/scan.rs• L160-179 src/…/scan.rs• L182-267 src/…/scan.rs• L364-413
Configuration checking
fnox check tests whether the active configuration has usable providers and secret sources. It reports missing values, unknown providers, and provider resolution failures as errors or warnings according to each secret's if_missing policy. By default it checks required secrets; --all also checks secrets marked as warn or ignore.
An error produces a non-zero result. Warnings still produce an OK result with a warning note, which lets teams distinguish a broken required setup from an intentionally optional value.
fnox check
fnox check --all
References: src/…/check.rs• L8-14 src/…/check.rs• L16-141 src/…/check.rs• L143-176
Encryption refresh
fnox reencrypt refreshes stored encrypted values with the current encryption provider settings. Use it after changing recipients or other provider settings so existing ciphertext matches the new access policy.
The command considers only secrets backed by encryption-capable providers and can narrow the work by key, provider, or regular expression. It shows the planned set in dry-run mode and asks for confirmation unless forced. It reads current plaintext values, writes new ciphertext back to each original source file, and clears stale sync data for the refreshed secrets.
fnox reencrypt --provider age --force
fnox reencrypt DATABASE_URL --dry-run
References: src/…/reencrypt.rs• L13-39 src/…/reencrypt.rs• L41-171 src/…/reencrypt.rs• L173-224 src/…/reencrypt.rs• L252-321
Profile and file management
Profile inventory
fnox profiles lists the default profile and every named profile known to the effective configuration. Normal output includes the number of secrets visible in each profile. Its hidden completion mode emits one profile name per line for shell completion.
Use this command before a write operation when the active profile stack is not obvious. It describes available profiles; it does not switch the active profile. Selection still comes from --profile or FNOX_PROFILE.
fnox profiles
fnox profiles --complete
References: src/…/profiles.rs• L6-12 src/…/profiles.rs• L14-37
Configuration file inventory
fnox config-files is the file-level companion to fnox profiles. It prints the configuration files that contribute to the current load. This includes discovered project files, existing imports, and the global file with its imports when present. With an explicit --config, it validates and reports that file and its imports instead of pretending that the parent search will run. It also validates the global file and its imports because they remain part of the load plan.
Use it to answer “which file owns this effective value?” before editing, setting, removing, or syncing a secret. The output is a load plan, not a merged configuration dump.
References: src/…/config_files.rs• L21-79 src/…/config_files.rs• L84-139 crates/…/config.rs• L20-58
Command flow
The commands form a safe lifecycle in which configuration chooses the profile and provider, a read or write action resolves the needed values, and a check or scan validates the result.
This diagram shows how setup leads to secret changes, use, transfer, and safety checks.
flowchart LR
A[init] --> B[configuration files]
B --> C[profiles and providers]
C --> D[set or import]
D --> E[list or get]
E --> F[export or sync]
B --> G[edit or remove]
C --> H[check]
B --> I[scan]
C --> J[reencrypt]
The normal read path is non-destructive. The change paths write only after their target profile and provider rules are known. Import, sync, edit, and re-encrypt add an extra protection step because they handle several values or temporarily expose plaintext during the operation.
Change checklist
When these files or sections are changed, remember to consider these:
- Changes to file names, imports, root behavior, or merge order must stay aligned across configuration loading,
config-files, and all write-target commands. - Changes to profile overlays or write-target rules must be checked in
set,remove,import,sync, and provider write commands. - Changes to secret fields such as provider, value,
env,as_file, URL, or missing-value policy must be reflected in inspection, import, export, check, sync, re-encrypt, and theset --openURL lookup. - Changes to provider capabilities must preserve the encryption requirements for import, sync, and re-encrypt.
- Changes to generated-value replacement or remote key selection must preserve provider writes and the rule that stale sync data is cleared on forced replacement.
- Changes to local target-path selection must preserve the difference between default-file discovery and an explicitly selected configuration path.
- Changes to edit-time provider loading must preserve the boundary between providers removed from the edited file and providers inherited from outer layers.
- Changes to edit-time source selection must preserve writes to the defining file and removal of a stale local sync cache after a single-secret edit.
- Changes to editor selection or command parsing must preserve support for quoted editor arguments and platform-specific path handling.
- Changes to managed-file source paths, provider ownership, or destination replacement must preserve the separation between stored file content and the file's restore path.
- Changes to scan findings or output must preserve redaction and the non-zero result used by CI callers.
- Changes to local-file sync naming, raw-source resolution, source markers, or stale-cache rules must keep the discovered config path and local override files aligned.
- Changes to dotenv parsing must preserve quoted-value handling and the safety rule for consumed standard input.
- Changes to configuration discovery or global-file loading must keep
config-filesaligned with the runtime load plan, including validation and reporting of global imports. - Changes to initialization paths must preserve parent-directory creation for explicit project files and the global configuration.
- Changes to initialization wizard behavior must preserve the distinction between interactive setup and minimal non-interactive creation, and must keep provider connection failure non-blocking after the configuration is built.
- Changes to
set --openmust preserve the interactive-terminal requirement, URL precedence, printed fallback URL, and continued prompt when no URL exists.
Important failure modes
| Trigger | Consequence | Guard |
|---|---|---|
Several profiles are active without --write-profile | A mutating command stops before choosing a file or profile | Set one explicit write profile for set, remove, import, or sync |
| An explicit config path is expected to include parent files | The command loads only the explicit file, its imports, and the global layer | Use the bare default config name for discovery or list the needed files in import |
| An explicit config file or one of its imports is missing or invalid | config-files fails instead of reporting a load plan that runtime loading cannot use | Fix the selected file or its imports before relying on the reported paths |
| A global config import is missing or invalid | config-files fails because the global layer cannot complete its load | Fix or remove the broken global import |
init targets a path whose parent cannot be created | Initialization stops before the configuration is saved | Check the parent path and its permissions |
init targets an existing file without --force | Initialization stops and leaves the existing configuration unchanged | Use a new path or add --force only when replacement is intended |
| The interactive wizard cannot resolve or test the selected provider | fnox warns about the provider, but still saves the new configuration | Correct provider access after setup, then run provider diagnostics |
--local-file is used with an explicit config path | Sync stops because the adjacent local override cannot be selected through discovery | Use the bare fnox.toml or .fnox.toml config name |
| Import uses a provider without encryption capability | No imported values are written | Select an encryption-capable provider |
Import receives standard input without --force or --dry-run | The command stops after consuming input instead of asking for confirmation | Use --force for a write or --dry-run to inspect the import |
Generated set targets an existing secret without --force | The command refuses to replace the existing value | Add --force only when replacement is intended |
| A remote secret keeps an inherited or old key after its provider changes | The new provider receives a key that belongs to the previous provider or source | Set --key-name or let the new provider use the environment key |
A metadata-only set changes an inherited secret | The command creates a local override instead of changing the parent value | Target the defining profile or file when the shared declaration must change |
set --open runs without an interactive terminal | The command stops before it prompts for a value | Run it from an interactive terminal or set the URL without --open |
set --open has no URL | No browser opens, but the command warns and still prompts | Add --url or configure a URL when browser navigation is needed |
| An edit changes a read-only remote secret | The configuration is not saved | Leave the read-only value unchanged and update it in its source provider |
| An edit cannot resolve a value needed for the temporary file | The edit stops instead of replacing the value with empty text | Fix the source or provider before editing |
| Removing a secret or managed-file declaration is expected to delete its provider value or disk file | The declaration is removed but the remote item or file remains | Revoke the remote value or remove the disk file through its owning system when required |
Export includes shell-hidden secrets with --all | Values marked exec-only or never-injected become part of the output | Use the default export filter unless the wider exposure is deliberate |
| A scan finds a likely plaintext secret | The command fails even though it redacts the finding in output | Remove or protect the value, then scan again |
| An encrypted secret is left under old provider recipients | New authorized users may not decrypt it, or removed users may retain access | Run fnox reencrypt after provider access changes |
Sync has no named target and no active default_provider | No local cache can be created | Set default_provider or pass --provider |
| Sync targets a provider without encryption capability | The cache cannot be created | Select an encryption-capable target provider |
Key files
| File | Why to read it |
|---|---|
| src/…/mod.rs | Defines the CLI-wide flags, command groups, and the split between config-free and config-backed commands. |
| crates/…/config.rs | Defines configuration discovery, profile overlays, write-target rules, and source-file writes used by the command workflows. |
| src/…/init.rs | Shows project and global configuration creation, parent-directory setup, the interactive provider wizard, provider testing, and the non-blocking save path after provider test failures. |
| src/…/set.rs | Shows the single-secret and managed-file write flows from input selection through provider handling, generated values, URL-assisted prompting, remote key selection, inherited overrides, and source-file update. |
| src/…/edit.rs | Shows the full-file, single-secret, and managed-file editing flows, provider scope used for re-encryption, defining-file writes, sync-cache removal, and the protection boundary around temporary plaintext values. |
| src/…/remove.rs and src/…/files.rs | Show declaration removal and the separate lifecycle for file content and file restore paths. |
| src/…/import.rs and src/…/export.rs | Show the supported interchange formats and the different safety rules for bringing values in or sending them out. |
| src/…/sync.rs and src/…/reencrypt.rs | Show the two maintenance flows that resolve current values and write protected replacements, including managed-file caches and local-cache cleanup. |
| src/…/scan.rs and src/…/check.rs | Show the source scan and configuration health checks that turn unsafe or incomplete state into actionable command results. |
| src/…/profiles.rs and src/…/config_files.rs | Show how engineers inspect the active profile set and the files that form the effective configuration. |