lib.ec.secret_store: Add and use framework #146

Merged
Jan Lindemann merged 1 commit from jan/feature/20261017-lib-ec-secret-store-add-and-use-framework into master 2026-10-17 13:02:24 +02:00 AGit
Owner

lib.ec.secret_store: Add and use framework

jw-pkg secrets install copies secret material from a GPG-encrypted tar archive to dotenv .jw-secret files on a target host. This commit refactors the underlying code and adds hooks for the inverse copy direction, and for more secret sources and targets.

The peers between which secrets are copied are represented by the new abstract secret_store.Base class, and the existing tar blob and host storages, inheriting from that class, are TarGpg and KvFile. Moreover, secret_store.Base is inheriting from FileContext, so all of jw-pkg's file-like operations are available as hooks.

Secrets inside instances of two file contexts are addressable as (targpg|kvfile)://target.host.com/path/to/file.conf.jw-secret. The on-host KvFile will look either locally or via SSH for that file, and TarGpg will look inside a tar archive specified in the JW_SECRETS_TARGPG_TAR environment variable.

Uris with these schemas can be passed to FileContext.create(), which will return a chrooted file context of the correct type.

KvFile.stat(``/path/to/file.conf.jw-secret).ftype is FT_SECRET which inherits from FT_COMPOUND - which means that readdir() works on such animals. Not entirely sure if that's a good idea, but it feels pretty generic. Let's see where that takes us.

DistroContext.install() after this refactor reads its source through the store interface and writes the landing through the KvFile store.

Both secret stores are exercised through the existing unit test of jw-pkg secrets install, and unit tests for both stores are also added by this commit.

#### lib.ec.secret_store: Add and use framework `jw-pkg secrets install` copies secret material from a GPG-encrypted tar archive to dotenv `.jw-secret` files on a target host. This commit refactors the underlying code and adds hooks for the inverse copy direction, and for more secret sources and targets. The peers between which secrets are copied are represented by the new abstract `secret_store`.Base class, and the existing tar blob and host storages, inheriting from that class, are TarGpg and KvFile. Moreover, `secret_store`.Base is inheriting from FileContext, so all of `jw-pkg`'s file-like operations are available as hooks. Secrets inside instances of two file contexts are addressable as (targpg|kvfile)://target.host.com/path/to/file.conf.jw-secret. The on-host KvFile will look either locally or via SSH for that file, and TarGpg will look inside a tar archive specified in the `JW_SECRETS_TARGPG_TAR` environment variable. Uris with these schemas can be passed to `FileContext.create()`, which will return a chrooted file context of the correct type. `KvFile.stat(``/path/to/file.conf.jw-secret`).ftype is `FT_SECRET` which inherits from `FT_COMPOUND` - which means that `readdir()` works on such animals. Not entirely sure if that's a good idea, but it feels pretty generic. Let's see where that takes us. `DistroContext.install()` after this refactor reads its source through the store interface and writes the landing through the KvFile store. Both secret stores are exercised through the existing unit test of `jw-pkg` secrets install, and unit tests for both stores are also added by this commit.
lib.ec.secret_store: Add and use framework
All checks were successful
CI / Packaging - Kali Linux (pull_request) Successful in 4m48s
CI / Packaging - OpenSUSE Tumbleweed (pull_request) Successful in 5m12s
CI / Packaging test (pull_request) Successful in 0s
CI / Packaging - Kali Linux (push) Successful in 4m35s
CI / Packaging - OpenSUSE Tumbleweed (push) Successful in 4m49s
CI / Packaging test (push) Successful in 0s
f08f658d33
"jw-pkg secrets install" copies secret material from a GPG-encrypted tar
archive to dotenv .jw-secret files on a target host. This commit refactors
the underlying code and adds hooks for the inverse copy direction, and for
more secret sources and targets.

The peers between which secrets are copied are represented by the new
abstract secret_store.Base class, and the existing tar blob and host
storages, inheriting from that class, are TarGpg and KvFile. Moreover,
secret_store.Base is inheriting from FileContext, so all of jw-pkg's
file-like operations are available as hooks.

Secrets inside instances of two file contexts are addressable as
(targpg|kvfile)://target.host.com/path/to/file.conf.jw-secret. The on-host
KvFile will look either locally or via SSH for that file, and TarGpg will
look inside a tar archive specified in the JW_SECRETS_TARGPG_TAR
environment variable.

Uris with these schemas can be passed to FileContext.create(), which will
return a chrooted file context of the correct type.

KvFile.stat("/path/to/file.conf.jw-secret").ftype is FT_SECRET which
inherits from FT_COMPOUND - which means that readdir() works on such
animals. Not entirely sure if that's a good idea, but it feels pretty
generic. Let's see where that takes us.

DistroContext.install() after this refactor reads its source through the
store interface and writes the landing through the KvFile store.

Both secret stores are exercised through the existing unit test of jw-pkg
secrets install, and unit tests for both stores are also added by this
commit.

Signed-off-by: Jan Lindemann <jan@janware.com>
Jan Lindemann scheduled this pull request to auto merge when all checks succeed 2026-10-17 12:52:22 +02:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
janware/jw-pkg!146
No description provided.