KC-1398: Add cspm-report command for CSPM/SSPM/GRC posture snapshots - #2274
Open
jpkeepersecurity wants to merge 1 commit into
Open
KC-1398: Add cspm-report command for CSPM/SSPM/GRC posture snapshots#2274jpkeepersecurity wants to merge 1 commit into
jpkeepersecurity wants to merge 1 commit into
Conversation
Introduces a new enterprise CLI command callable via Commander Service Mode's existing executecommand endpoint. Exports user status, MFA, roles, enforcements, devices, last login (RMD-sourced), and security scores. Supplemental API calls run concurrently; device fetches are scoped to the current page to avoid full-enterprise scans on paginated requests.
jpkeepersecurity
force-pushed
the
KC-1398
branch
from
August 27, 2026 18:53
ecc06e1 to
856916e
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
cspm-reportenterprise CLI command (keepercommander/commands/cspm.py)callable via Commander Service Mode's existing
POST /api/v1/executecommandendpoint —no new HTTP infrastructure required.
register_enterprise_commands()inbase.py.What it exports
Core fields (zero extra API calls — sourced entirely from
params.enterprise):user status, auth method, MFA state, roles, teams, admin permissions, role enforcements,
and subscription/license data.
Optional enrichment via flags:
--include-last-loginlast_loginrmd/get_enterprise_stat_details--include-has-recordshas_records,last_logged_in--include-security-auditsecurity_scoreenterprise/get_security_report_data--include-devicesdevices[]dm/device_admin_list+params.enterprise--page/--page-sizeFiles changed
keepercommander/commands/cspm.pykeepercommander/commands/base.pyregister_enterprise_commands()Performance
ThreadPoolExecutordm/device_admin_list, 100 users/batch) also fire concurrently (up to 10 workers)API calls from
ceil(total/100)toceil(page_size/100)per page requestTest plan
cspm-report --format jsonreturns valid JSON withtotal,page,has_more,subscription,users--include-last-loginpopulateslast_loginon all non-invited users--include-last-loginand--include-has-recordstogether issue only one RMD call--include-devicesreturnsdevices[]only for users in the current pagepage=1andpage=2return non-overlapping user sets; last page hashas_more: false--commandsallow-list returns403 Forbiddenauth_method: "pending"andstatus: "invited"status: "locked"orstatus: "locked_by_idp"depending onlockvalueauth_method: "sso"Output Examples for Reviewers
1. Minimal call — no optional flags
Request:
Response:
{ "status": "success", "command": "cspm-report", "data": { "total": 7, "page": 1, "page_size": 3, "has_more": true, "subscription": { "seats_purchased": 25, "seats_allocated": 7, "seats_pending": 1, "expiration": "2027-01-15T00:00:00", "add_ons": [ { "name": "enterprise_breachwatch", "enabled": true, "seats": 25, "expiration": "2027-01-15T00:00:00" } ] }, "users": [ { "email": "admin@company.com", "user_id": 100001, "status": "active", "is_admin": true, "auth_method": "master_password", "tfa_enabled": true, "roles": ["Administrators"], "teams": [], "admin_permissions": ["manage_users", "manage_teams", "run_reports", "manage_roles"], "role_enforcements": { "master_password_minimum_length": "12", "master_password_restrict_reuse": "5" } }, { "email": "alice@company.com", "user_id": 100002, "status": "active", "is_admin": false, "auth_method": "sso", "tfa_enabled": true, "roles": ["Standard Users", "Security Team"], "teams": ["Engineering", "Platform"], "admin_permissions": [], "role_enforcements": { "master_password_minimum_length": "10" } }, { "email": "bob@company.com", "user_id": 100003, "status": "invited", "is_admin": false, "auth_method": "pending", "tfa_enabled": false, "roles": [], "teams": [], "admin_permissions": [], "role_enforcements": {} } ] } }2. Full call — all optional flags enabled
Request:
Response:
{ "status": "success", "command": "cspm-report", "data": { "total": 7, "page": 1, "page_size": 3, "has_more": true, "subscription": { "seats_purchased": 25, "seats_allocated": 7, "seats_pending": 1, "expiration": "2027-01-15T00:00:00", "add_ons": [ { "name": "enterprise_breachwatch", "enabled": true, "seats": 25, "expiration": "2027-01-15T00:00:00" } ] }, "users": [ { "email": "admin@company.com", "user_id": 100001, "status": "active", "is_admin": true, "auth_method": "master_password", "tfa_enabled": true, "roles": ["Administrators"], "teams": [], "admin_permissions": ["manage_users", "manage_teams", "run_reports", "manage_roles"], "role_enforcements": { "master_password_minimum_length": "12", "master_password_restrict_reuse": "5" }, "last_login": "2026-08-07T09:14:32", "has_records": true, "last_logged_in": "2026-08-07T09:14:32", "security_score": 98, "devices": [ { "device_name": "Admin's MacBook Pro", "client_version": "16.11.2", "device_platform": "macOS", "device_category": "Desktop", "device_status": "APPROVED", "login_state": "LOGGED_IN", "last_modified": "2026-08-07T09:14:32", "ip_address": null, "location": null } ] }, { "email": "alice@company.com", "user_id": 100002, "status": "active", "is_admin": false, "auth_method": "sso", "tfa_enabled": true, "roles": ["Standard Users", "Security Team"], "teams": ["Engineering", "Platform"], "admin_permissions": [], "role_enforcements": { "master_password_minimum_length": "10" }, "last_login": "2026-08-06T14:32:11", "has_records": true, "last_logged_in": "2026-08-06T14:32:11", "security_score": 94, "devices": [ { "device_name": "Alice's iPhone 15 Pro", "client_version": "16.11.0", "device_platform": "iOS", "device_category": "Mobile", "device_status": "APPROVED", "login_state": "LOGGED_IN", "last_modified": "2026-08-06T14:32:11", "ip_address": null, "location": null }, { "device_name": "Alice's MacBook Pro", "client_version": "16.11.2", "device_platform": "macOS", "device_category": "Desktop", "device_status": "APPROVED", "login_state": "LOGGED_IN", "last_modified": "2026-07-30T10:00:00", "ip_address": null, "location": null } ] }, { "email": "bob@company.com", "user_id": 100003, "status": "invited", "is_admin": false, "auth_method": "pending", "tfa_enabled": false, "roles": [], "teams": [], "admin_permissions": [], "role_enforcements": {}, "last_login": "N/A", "has_records": false, "last_logged_in": null, "security_score": null, "devices": [] } ] } }3. Locked user example
A user locked by an IdP (e.g. deprovisioned from Okta):
{ "email": "charlie@company.com", "user_id": 100004, "status": "locked_by_idp", "is_admin": false, "auth_method": "sso", "tfa_enabled": false, "roles": ["Standard Users"], "teams": ["Sales"], "admin_permissions": [], "role_enforcements": {}, "last_login": "2026-05-12T16:44:00", "has_records": true, "last_logged_in": "2026-05-12T16:44:00", "security_score": 61, "devices": [ { "device_name": "Charlie's Android", "client_version": "16.9.1", "device_platform": "Android", "device_category": "Mobile", "device_status": "APPROVED", "login_state": "LOGGED_OUT", "last_modified": "2026-05-12T16:44:00", "ip_address": null, "location": null } ] }4. Device pending approval example
A device submitted for approval that has not yet been confirmed by an admin:
{ "device_name": "Dave's iPad Pro", "client_version": "16.10.0", "device_platform": null, "device_category": "tablet", "device_status": "NEEDS_APPROVAL", "login_state": null, "last_modified": "2026-08-07T08:01:55", "ip_address": "203.0.113.45", "location": "São Paulo, BR" }5. Pagination — second page
Request:
Response (last page):
{ "status": "success", "command": "cspm-report", "data": { "total": 7, "page": 2, "page_size": 3, "has_more": false, "subscription": { "...": "same as page 1" }, "users": [ { "email": "dave@company.com", "user_id": 100004, "...": "..." }, { "email": "eve@company.com", "user_id": 100005, "...": "..." }, { "email": "frank@company.com","user_id": 100006, "...": "..." } ] } }6. Error responses
Missing or invalid API key (401):
{ "status": "error", "error": "Please provide a valid api key" }Command not in allow-list (403):
{ "status": "error", "error": "Not permitted to perform this function" }Expired API key (401):
{ "status": "error", "error": "API key has expired" }