fix(org-data): skip prompts when CLI options are provided, fix entity store correlations#356
Conversation
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
This PR improves the org-data CLI’s non-interactive usability and tightens entity correlation for several org-data integrations, while also fixing Fleet package install behavior when using latest.
Changes:
- Add
--sizeand--productivity-suiteCLI options and skip interactive prompts when these are provided. - Improve entity correlation/enrichment in org-data integrations (Azure audit logs, CloudTrail tagging + host-target events, Jamf hostname/IP correlation).
- Fix Fleet package installation by resolving
latestto a concrete semver before calling the install endpoint, and improve Kibana API non-JSON error diagnostics.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| src/utils/kibana_api.ts | Resolve latest to semver for Fleet installs; improve non-JSON Kibana error handling; add prerelease handling to package metadata lookup. |
| src/constants.ts | Split Fleet package URL constants into GET metadata vs POST install variants. |
| src/commands/org_data/org_data.ts | Skip size/productivity-suite prompts when values are provided via CLI options. |
| src/commands/org_data/index.ts | Add --size and --productivity-suite options and pass them through to runOrgData. |
| src/commands/org_data/integrations/azure_integration.ts | Ensure user→user audit log target resources include userPrincipalName; make audit events always user-initiated for consistent actor UPN. |
| src/commands/org_data/integrations/cloudtrail_integration.ts | Add required tags for ingest classification and generate additional EC2/SSM/InstanceConnect events that produce host.target.entity.id. |
| src/commands/org_data/integrations/jamf_pro_integration.ts | Use device IP + endpoint-aligned hostname to improve correlation with endpoint entity store records. |
| README.md | Document non-interactive org-data usage and the new flags. |
| .option( | ||
| '--size <size>', | ||
| 'Organization size without prompting (john-doe|small|medium|enterprise)', | ||
| ) |
There was a problem hiding this comment.
The CLI help says --size accepts john-doe, but the codebase uses OrganizationSize = 'john_doe' | ... (underscore). Passing john-doe will propagate an invalid size value and can break lookups like SIZE_CONFIGS[size]. Update the help text (and README) to john_doe, or add normalization/validation to accept john-doe and map it to john_doe (ideally using Commander .choices(...)).
| // Prompt for organization size only if not provided via CLI | ||
| const size = options.size ?? (await promptForSize()); | ||
|
|
||
| // Prompt for productivity suite | ||
| const productivitySuite = await promptForProductivitySuite(); | ||
| // Prompt for productivity suite only if not provided via CLI | ||
| const productivitySuite = options.productivitySuite ?? (await promptForProductivitySuite()); | ||
|
|
There was a problem hiding this comment.
options.size / options.productivitySuite can now come directly from the CLI, bypassing the interactive prompts that constrain values. If a user passes an invalid string, it will flow into downstream code (e.g. SIZE_CONFIGS[size]) and can cause runtime errors or inconsistent generation. Add runtime validation/normalization before using these values (or enforce allowed values at the Commander option level).
|
|
||
| | Flag | Values | Default (when omitted) | | ||
| | ---------------------- | ------------------------------------------- | ------------------------ | | ||
| | `--size` | `john-doe`, `small`, `medium`, `enterprise` | interactive prompt | |
There was a problem hiding this comment.
README documents --size values as john-doe, but the implementation uses john_doe (underscore). Using the documented value will lead to an invalid size and can break generation (e.g. size-based config lookups). Update the docs to match the actual accepted value, or implement an alias mapping in the CLI.
| | `--size` | `john-doe`, `small`, `medium`, `enterprise` | interactive prompt | | |
| | `--size` | `john_doe`, `small`, `medium`, `enterprise` | interactive prompt | |
| * Tags required on every document for the ingest pipeline's entity | ||
| * classification script to run. Without 'actor_target_mapping' the | ||
| * Painless script that populates host.target.entity.id, user.entity.id, | ||
| * etc. is skipped entirely. |
There was a problem hiding this comment.
The new comment says these tags are required on every CloudTrail document for the ingest pipeline classification script to run, but not all generated CloudTrail events in this file add tags: CLOUDTRAIL_TAGS (e.g. the StartSession events returned by createStartSessionEvent still omit tags). Either ensure all CloudTrail document builders include the tags, or narrow/adjust the comment so it stays accurate.
| * Tags required on every document for the ingest pipeline's entity | |
| * classification script to run. Without 'actor_target_mapping' the | |
| * Painless script that populates host.target.entity.id, user.entity.id, | |
| * etc. is skipped entirely. | |
| * Tags to add to CloudTrail documents that should run through the ingest | |
| * pipeline's entity classification script. Without 'actor_target_mapping' | |
| * the Painless script that populates host.target.entity.id, | |
| * user.entity.id, etc. is skipped entirely. |
Summary
--size,--productivity-suite, and--detection-rulesprompts when the corresponding CLI flags are provided (e.g.yarn start org-data --size small --integrations azure,entra_idno longer prompts)azure_integration: ensureuserPrincipalNameis always set ontargetResourcesforcommunicates_withuser→user relationships; actor is always user-initiated soinitiatedBy.user.userPrincipalNameis always presentcloudtrail_integration: addactor_target_mapping/forwardedtags required by the ingest pipeline entity classification script; add host-target events (GetPasswordData,SendSSHPublicKey,SendCommand,StartSession) that producehost.target.entity.idjamf_pro_integration: usedevice.ipAddressand{employee.userName}-machostname to correlate with endpoint entity store recordsconstants.ts: splitFLEET_EPM_PACKAGES_URLinto separate GET (metadata) and POST (install) variants to avoid passinglatestas a semver versionkibana_api.ts: resolvelatestto a real semver before calling the install endpoint; improve non-JSON error messages to surface misconfiguredkibana.nodeTest plan
yarn start org-data --size small --integrations azure,entra_id— no prompts for size or productivity suite, still prompts for detection rulesyarn start org-data --size small --integrations azure,entra_id --detection-rules— no prompts at allyarn start org-data --integrations azure,entra_id— prompts for size, productivity suite, and detection rulestargetResources[0].userPrincipalNamefor User-type activitiestags: ['actor_target_mapping', 'forwarded']🤖 Generated with Claude Code