Skip to content

feat: kbagent encrypt command + sync push plaintext fix - #117

Merged
padak merged 2 commits into
mainfrom
feature/encrypt-command
Apr 11, 2026
Merged

feat: kbagent encrypt command + sync push plaintext fix#117
padak merged 2 commits into
mainfrom
feature/encrypt-command

Conversation

@padak

@padak padak commented Apr 11, 2026

Copy link
Copy Markdown
Member

Summary

Implements #116 (Parts A + B, skipping Part C per discussion).

  • New kbagent encrypt values command -- exposes Keboola Encryption API as a standalone CLI primitive for MCP tool call workflows where ciphertext must exist before update_config/create_config
  • Security fix in sync push -- _encrypt_secrets_in_config() now fails hard on Encryption API errors instead of silently pushing plaintext secrets

Changes

Part A -- kbagent encrypt values

File Change
services/encrypt_service.py New service: validation, KBC:: passthrough, API call
commands/encrypt.py New command: --input (JSON/@file/stdin), --output-file (0600)
cli.py Wiring: encrypt_app + EncryptService
permissions.py "encrypt.values": "write"

Part B -- Sync push fail-closed

File Change
services/sync_service.py _encrypt_secrets_in_config() raises KeboolaApiError by default
commands/sync.py New --allow-plaintext-on-encrypt-failure escape hatch flag

Documentation

  • context.py -- encrypt section + sync push flag docs
  • CLAUDE.md -- All CLI Commands updated
  • SKILL.md -- regenerated via make skill-gen

Part C -- Skipped

encrypt_values() signature stays as-is (project + component scope = ComponentSecure). Adding config_id/branch_type would break config cloning and branch merging.

Test plan

  • 7 service tests (validation, passthrough, API errors)
  • 9 CLI tests (JSON/file/stdin input, output file, error codes)
  • 7 sync encrypt tests (fail-hard default, fallback flag, success paths)
  • make check passes (1378 tests, lint, format, SKILL.md freshness)

Closes #116

padak added 2 commits April 11, 2026 13:30
#116)

Part A - New encrypt command:
- encrypt values --project ALIAS --component-id ID --input JSON|@file|-
- Validates #-prefix keys, string values, KBC:: passthrough
- Supports inline JSON, file input, stdin pipe, and --output-file
- Registered in permissions.py (write), wired in cli.py

Part B - Security fix in sync push:
- _encrypt_secrets_in_config() now raises KeboolaApiError on failure
  instead of silently falling back to plaintext
- New --allow-plaintext-on-encrypt-failure escape hatch flag
- Parameter flows through push -> push_all -> _push_create/_push_update

Documentation:
- context.py updated with encrypt section and sync push flag
- CLAUDE.md All CLI Commands section updated
- SKILL.md regenerated via make skill-gen

Tests: 23 new tests (7 encrypt service, 9 encrypt CLI, 7 sync encrypt)
- New encrypt-workflow.md: pipe workflow, input formats, scope rules,
  common errors, sync push interaction
- commands-reference.md: add encrypt section, sync push flag
- SKILL.md: add triggers, workflow reference, description update
@padak
padak merged commit 5482b2f into main Apr 11, 2026
1 check passed
@padak
padak deleted the feature/encrypt-command branch April 11, 2026 11:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat: kbagent encrypt command for MCP tool call workflows

1 participant