Skip to content

feat(pam): add KCM database connector for pam project import#1889

Open
jlima8900 wants to merge 5 commits intoKeeper-Security:releasefrom
jlima8900:feat/pam-kcm-import
Open

feat(pam): add KCM database connector for pam project import#1889
jlima8900 wants to merge 5 commits intoKeeper-Security:releasefrom
jlima8900:feat/pam-kcm-import

Conversation

@jlima8900
Copy link

@jlima8900 jlima8900 commented Mar 23, 2026

Summary

Adds pam project kcm-import command for migrating KCM/Guacamole connections into Keeper PAM.

  • Connects to MySQL or PostgreSQL KCM database
  • Maps 150+ KCM parameters to PAM record fields
  • Creates pamMachine/pamDatabase/pamRemoteBrowser resources + pamUser records
  • Interactive gateway selection (existing or new)
  • Supports --dry-run, --output, --docker-detect, --db-ssl, --db-password-record

Test plan

  • 40 tests passing on Python 3.7 and 3.12
  • E2E verified against real database + live vault import

@jlima8900 jlima8900 force-pushed the feat/pam-kcm-import branch 2 times, most recently from 6ee680b to f01cab6 Compare March 23, 2026 12:24
@jlima8900 jlima8900 changed the title feat(pam): add kcm-import subcommand for KCM/Guacamole database migration feat(pam): add KCM database connector for pam project import Mar 23, 2026
…tion

Adds `pam project kcm-import` command that connects to a KCM/Guacamole
database, extracts connections/users/groups, maps 150+ parameters, and
imports into Keeper PAM via the existing import/extend engine.

Features: --db-ssl, --docker-detect, --db-password-record, --gateway
(interactive selection), --max-instances (pool sizing), --dry-run,
--output, --folder-mode, --skip-users, --include-disabled.

Prints Docker/K8s deploy commands after gateway creation.
@jlima8900 jlima8900 force-pushed the feat/pam-kcm-import branch from f01cab6 to 588d1d4 Compare March 25, 2026 11:54
Same pattern as Keeper-Security#1873 — os.open mode only applies on creation, not
existing files. Add os.fchmod(fd, 0o600) to ensure owner-only
permissions regardless.
Security improvements:
- Block remote connections without SSL by default (require --db-ssl or
  --allow-cleartext to override)
- Clear connector.password and db_password after use
- Clear docker inspect stdout after parsing (contains all container
  env vars including other secrets)
- Remove db username from docker detect log output
- Add os.fchmod for existing output files
- Use e.__class__.__name__ instead of type(e).__name__ for consistency

Add 8 tests for SSL enforcement, credential cleanup, and log
sanitization.
Live E2E tests (skip when DB offline):
- Real DB connection, schema validation, data extraction
- Parameter mapping with real KCM data (SSH + RDP connections)
- All 3 folder modes (ksm/exact/flat) against real groups
- Docker detect against real guacamole-postgres container
- Full execute() pipeline: dry-run, output file, skip-users,
  include-disabled, custom project name, all folder modes
- Error paths: wrong password, wrong db name, wrong port
- Remote SSL enforcement, nonexistent Docker container

Unit tests:
- Gateway resolution: not found, found by name, offline warning
- _find_config_for_gateway: match and no-match paths
- Deploy instructions output verification
- _is_local_host: localhost, IPv4/IPv6, RFC1918, public IPs
- Docker container name passthrough (custom + default)
- DB flag passthrough: port, db_name, db_user, default ports
- Error paths: connection failure, schema failure, invalid port,
  Docker timeout, Docker not installed
Bugs found during live E2E testing against real vault:
- PAMController protobuf has no `isOnline` attribute — replaced with
  router_get_connected_gateways() cross-reference to determine online
  status
- PAMController has no `version` attribute — removed from display
- Unused import (pam_configurations_get_all) replaced with
  router_helper

Verified full E2E: DB connect → extract → transform → vault import →
gateway creation → folder structure → shared folders → PAM config →
KSM app. 8 records created successfully (3 resources, 3 users,
1 config, 1 app).
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.

1 participant