Skip to content

Commit c413670

Browse files
authored
Merge pull request #22 from zloeber/cursor/lockfile-sync-identity-provider-token-info
Cursor/lockfile sync identity provider token info
2 parents f91caa9 + d01d8be commit c413670

75 files changed

Lines changed: 2241 additions & 583 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.mex/ROUTER.md

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ edges:
1414
condition: when setting up the dev environment or running the project for the first time
1515
- target: patterns/INDEX.md
1616
condition: when starting a task — check the pattern index for a matching pattern file
17-
last_updated: 2026-04-12
17+
last_updated: 2026-04-13
1818
---
1919

2020
# Session Bootstrap
@@ -31,6 +31,18 @@ Then read this file fully before doing anything else in this session.
3131
- Policy/status/drift/terraform command families and comprehensive pytest suite.
3232
- Task-based verification workflow (`lint:fix`, `format`, `schema:update`, `test`, `security:scan`, `test:validations`).
3333
- **`secretzero web`:** one-shot, bindable FastAPI UI over the network (bootstrap token, session + CSRF, optional TLS): dashboard with manifest/lock metadata, per-secret sync/rotate, **per-target “Force to target”** when multiple targets exist and another lane is already synced (`SyncEngine.sync(..., force_targets=...)`), static value edit (forces target writes), optional `--debug` sync log panel, sync-all, logout, shutdown. CLI parity: `secretzero sync -s <name> --force-target <target_id>` (repeatable). See `.mex/patterns/secretzero-web.md`.
34+
- **Lockfile sync identity:** On each non–dry-run sync that updates secretfile tracking, `.gitsecrets.lock``secretfile.sync_identity` records client surface (`cli`, `api`, `agent`, `network_web`), OS user/host/platform, git `user.*` + short `HEAD` at the Secretfile directory, optional env label (`SZ_SYNC_ENVIRONMENT`, `ENVIRONMENT`, `ENV`), and detected CI actor/repo/run URL when present. Each successful target write also appends to `target_provenance` (same snapshot, last 3 per target). See `.mex/patterns/lockfile-sync-identity.md`.
35+
- **Secretfile manifest versioning:** Root `version` is no longer required in `Secretfile.yml`; lockfile tracking now records `secretfile.manifest_spec_version` (currently `1`) in `.gitsecrets.lock` for future manifest migration compatibility.
36+
- **Provider token introspection:** All built-in providers now implement `ProviderAuth.get_token_info()` (or `InfisicalProvider.get_token_info()`) where the upstream API supports it—AWS STS, Azure JWT claims, Vault `lookup-self`, GitLab user, Jenkins `get_whoami`, Kubernetes kubeconfig host/context, Ansible Vault password *mode* (never the password), plus existing GitHub. `BaseProvider.get_actor_info()` merges this into sync `actor` metadata on target writes.
37+
- **Provider identity UI:** `collect_provider_identity_rows()` (`src/secretzero/provider_identity.py`) resolves each `providers:` entry via `get_actor_info()`; shown as a Rich table before `secretzero sync` / `secretzero status` (text), `provider_identity` in JSON, and a **Provider identity** table on the `secretzero web` dashboard manifest header.
38+
- **Agent skill guidance refreshed:** `skills/secretzero/SKILL.md` now includes explicit Secretfile authoring rules that prioritize whole-secret modeling and straightforward template usage.
39+
- **Lockfile write guard:** sync/agent/API flows no longer persist empty skeleton lockfiles; `Lockfile.save()` now skips (and removes) files when state is semantically empty.
40+
- **Provider kind fallback:** When a `providers:` entry omits top-level `kind`, sync and `secretzero init` now treat the YAML key as the provider kind (e.g. `providers.aws``aws`). Previously `model_dump()` produced `kind: null` and AWS never registered (`Provider not initialized`).
41+
- **Structured secret hashing:** Lockfile hashing now accepts non-string secret payloads (e.g. JSON objects for multi-field static secrets) via canonical JSON normalization before SHA-256, preventing `'dict' object has no attribute 'encode'` during sync.
42+
- **Example manifest:** `examples/azure-appreg-to-aws-sm.yml` uses a structured static `value` map with YAML `null` leaves so interactive `secretzero sync` prompts once per missing field (sorted keys); `.szvar` / `--var-file` can pre-fill those leaves to skip prompts.
43+
- **Static dict prompting:** `StaticGenerator` now fills dict/object static secrets by prompting for each scalar leaf that is `null`, blank, or a lone `${VAR}` placeholder (nested leaves only; top-level empty string remains a deliberate value). `static_payload_needs_prompt()` drives agent auto-sync classification for structured static secrets.
44+
- **Variable context / lockfile:** `variables_hash` was never persisted, so `variable_context_changed` was always true for manifests with `variables:` (vs `null` in the lock), forcing `ignore_foreign_context_targets` and spurious re-prompts. Missing baseline now means “not changed”; `secretzero sync` calls `track_variable_context` before saving the lockfile so real variable / `.szvar` changes are detected on subsequent runs.
45+
- **CLI rotate filtering:** `secretzero rotate --secret <name>` / `-s` (repeatable) limits rotation to those manifest secrets; same as optional positional `SECRET_NAME`, but do not combine `-s` with the positional.
3446

3547
**Not yet built:**
3648
- Autonomous/scheduled secret rotation service (rotation is operator-invoked).

.mex/patterns/INDEX.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,6 @@ Lookup table for all pattern files in this directory. Check here before starting
1010
| [add-secret.md#task-add-a-simple-secret](add-secret.md#task-add-a-simple-secret) | Adding a standard secret definition to `Secretfile.yml` |
1111
| [add-secret.md#task-add-a-template-secret](add-secret.md#task-add-a-template-secret) | Adding a template-backed multi-field secret |
1212
| [debug-sync.md](debug-sync.md) | Diagnosing sync failures across config/provider/generator/target boundaries |
13+
| [lockfile-sync-identity.md](lockfile-sync-identity.md) | Extending lockfile operator/CI identity metadata or sync provenance |
1314
| [secretzero-web.md](secretzero-web.md) | Changing `secretzero web` (network seeding UI, TLS, templates, auth) |
1415
| [secretfile-authoring.md](secretfile-authoring.md) | Editing Secretfile structure, variables, provider mappings, and interpolation usage |
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Lockfile sync identity
2+
3+
Use when extending **who / where / CI** metadata persisted on sync (not secret values).
4+
5+
## Where it lives
6+
7+
- **Schema:** `LockfileSyncIdentity` and `SecretfileMetadata.sync_identity` in `src/secretzero/lockfile.py`
8+
- **Collection:** `collect_lockfile_sync_identity()` in `src/secretzero/sync_identity.py` (host, user, git config/HEAD at Secretfile parent, CI env — **no tokens**)
9+
- **Wiring:** `SyncEngine` (`sync_client`, optional `sync_identity` override, `sync_identity_cwd`) calls `Lockfile.track_secretfile(..., sync_identity=...)` once per run and passes the same snapshot into `record_target_update` for per-target provenance
10+
11+
## Verify
12+
13+
- `task test` (includes `tests/test_sync_identity.py`)
14+
- Spot-check `.gitsecrets.lock``secretfile.sync_identity` and `secrets[*].target_provenance` after a real sync

.mex/patterns/secretfile-authoring.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ edges:
1313
condition: when command usage or environment setup is needed
1414
- target: patterns/add-secret.md
1515
condition: when authoring includes adding/changing secret entries
16-
last_updated: 2026-04-10
16+
last_updated: 2026-04-13
1717
---
1818

1919
# Secretfile Authoring
@@ -32,6 +32,9 @@ This pattern covers edits to `Secretfile.yml` structure (`variables`, `providers
3232
- `${VAR}` interpolation is based on merged variable context in config flow, not implicit shell env substitution.
3333
- Var-file ordering matters; later `--var-file` overrides earlier values.
3434
- A typo in interpolated key paths can silently produce wrong/empty rendered values in downstream config.
35+
- Secretfile root `version` is no longer required; manifest spec versioning is tracked in `.gitsecrets.lock` under `secretfile.manifest_spec_version`.
36+
- Prefer defining whole secrets first; use templates only for stable multi-field credentials that are consumed together.
37+
- Prefer template-level targets over per-field targets unless a field must go to a different destination.
3538

3639
## Verify
3740
- [ ] Render output contains expected provider paths and secret target config.

Secretfile.example.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
# yaml-language-server: $schema=./Secretfile.schema.json
22
# Secretfile.yml
3-
version: '1.0'
43

54
# Composable env block that can be overridden at runtime to provide dynamic values for generators and targets. This allows for flexibility in how secrets are generated and where they are stored without needing to change the Secretfile.
65
variables:

Secretfile.schema.json

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -917,10 +917,6 @@
917917
},
918918
"description": "Root configuration model for Secretfile.yml.",
919919
"properties": {
920-
"version": {
921-
"title": "Version",
922-
"type": "string"
923-
},
924920
"variables": {
925921
"additionalProperties": true,
926922
"title": "Variables",
@@ -998,9 +994,6 @@
998994
"description": "Defaults for unified agent sync (CLI and API): mode and optional web UI port range"
999995
}
1000996
},
1001-
"required": [
1002-
"version"
1003-
],
1004997
"title": "Secretfile",
1005998
"type": "object"
1006999
}

Secretfile.test.lock

Lines changed: 0 additions & 6 deletions
This file was deleted.

Secretfile.test.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
# Test configuration using localstack for local development and testing
44
# Updated: Feb 2026
55

6-
version: '1.0'
76

87
variables:
98
aws_region: us-east-1
@@ -101,4 +100,4 @@ secrets:
101100
kind: file
102101
config:
103102
path: ./local_secret.json
104-
format: json
103+
format: json

Secretfile.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
# yaml-language-server: $schema=Secretfile.schema.json
2-
version: '1.0'
32

43
variables:
54
github_org: zloeber

docs/api-getting-started.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,6 @@ curl -X POST http://localhost:8000/config/validate \
7676
-H "X-API-Key: your-api-key-here" \
7777
-d '{
7878
"config": {
79-
"version": "1.0",
8079
"secrets": [
8180
{
8281
"name": "example",

0 commit comments

Comments
 (0)