osquery_manager: generate ECS section mappings from config#18989
Conversation
Move ECS keep fields into osquery-gen config so parent object mappings such as *.sections are regenerated consistently, and refresh generated artifacts for osquery 5.23.0.
Vale Linting ResultsSummary: 1 warning found
|
| File | Line | Rule | Message |
|---|---|---|---|
| packages/osquery_manager/_dev/scripts/osquery-gen/README.md | 7 | Elastic.Latinisms | Latin terms and abbreviations are a common source of confusion. Use 'for example' instead of 'e.g'. |
The Vale linter checks documentation changes against the Elastic Docs style guide.
To use Vale locally or report issues, refer to Elastic style guide for Vale.
|
Pinging @elastic/sec-windows-platform (Team:Security-Windows Platform) |
This comment has been minimized.
This comment has been minimized.
TL;DRThe failure is configuration-related, not a test/code regression: CI tries to boot Elastic Stack Remediation
Investigation detailsRoot Cause
Buildkite failed while pulling stack images for Evidence
Verification
Follow-upIf Note 🔒 Integrity filter blocked 2 itemsThe following items were blocked because they don't meet the GitHub integrity level.
To allow these resources, lower tools:
github:
min-integrity: approved # merged | approved | unapproved | noneWhat is this? | From workflow: PR Buildkite Detective Give us feedback! React with 🚀 if perfect, 👍 if helpful, 👎 if not. |
💚 Build Succeeded
History
|
tomsonpl
left a comment
There was a problem hiding this comment.
Solid fix for a real bug (#16650 follow-through). The generator refactor is clean and the config-driven model is consistent with the rest of the tool. Left a few comments inline — main ask is (1) a unit test covering the parent-object keep-list path.
| fieldName := joinPath(parent, name) | ||
| typ, _ := m["type"].(string) | ||
| if (inSet(keepFields, fieldName) || isAllowedECSType(typ)) && name != "@timestamp" { | ||
| if !kept && isAllowedECSType(typ) && name != "@timestamp" { |
There was a problem hiding this comment.
nit: the inverted condition (!kept && isAllowedECSType(typ)) reads as "skip the type check when kept," but the actual intent is "kept-list takes priority and also emits the parent object node; the leaf type check still applies to non-kept children." A one-line comment above the kept block on line 538 would save the next reader from re-deriving this.
Also, name != "@timestamp" is now checked on both branches — minor duplication, harmless, but could be lifted to a single guard at the top of the loop body.
| typ, _ := m["type"].(string) | ||
| if (inSet(keepFields, fieldName) || isAllowedECSType(typ)) && name != "@timestamp" { | ||
| if !kept && isAllowedECSType(typ) && name != "@timestamp" { | ||
| *ecsFields = append(*ecsFields, fieldName) |
There was a problem hiding this comment.
Suggest adding a unit test for collectECSFieldNames (or generateECSFieldsYAML) that feeds a synthetic ECS YAML with a file.pe.sections-shaped object node + a keep_fields containing that parent path, and asserts the parent appears in the output.
This is the substance of the fix and right now it's only validated indirectly via the regenerated ecs.yml. The repo already runs go test ./... for this tool, so a generator_test.go would be cheap and lock the contract in.
|
|
||
| log.Printf("Resolved versions: osquery=%s beats=%s ecs=%s", osqueryVersion, beatsRef, ecsVersion) | ||
| if err := generateArtifacts(outputRoot, osqueryVersion, ecsVersion, beatsRef, !*skipPackageCheck); err != nil { | ||
| if err := generateArtifacts(outputRoot, osqueryVersion, ecsVersion, beatsRef, cfg.ECS.KeepFields, !*skipPackageCheck); err != nil { |
There was a problem hiding this comment.
If ecs.keep_fields is omitted from config.yml, cfg.ECS.KeepFields is nil and behavior silently degrades to "leaves + isAllowedECSType only" — i.e. the parent-object fix this PR introduces disappears with no warning.
A log.Printf("ECS keep fields: %d entries", len(cfg.ECS.KeepFields)) line near the existing Resolved versions: log would catch accidental empty configs in CI output.
| link: https://github.com/elastic/integrations/pull/16650 | ||
| - description: Upgrade osquery version to 5.23.0 | ||
| type: enhancement | ||
| link: https://github.com/elastic/integrations/pull/16650 |
There was a problem hiding this comment.
…8989) Move ECS keep fields into osquery-gen config so parent object mappings such as *.sections are regenerated consistently, and refresh generated artifacts for osquery 5.23.0.
Proposed commit message
osquery_manager: generate ECS section mappings from config
Move the osquery-gen ECS keep list into
config.ymland pass it through the generator instead of embedding a separate text file. This lets the generatedecs.ymlinclude object/nested parent mappings such asdll.pe.sections,file.pe.sections, and relatedthreat.*.file.pe.sectionsfields consistently when artifacts are regenerated.Refresh generated osquery artifacts for osquery 5.23.0 and bump the package to 1.29.0 so the changelog captures both the ECS generation fix and osquery version update.
Checklist
changelog.ymlfile.Author's Checklist
*.sectionsfields are generated indata_stream/result/fields/ecs.yml.How to test this PR locally
Also run:
Not run locally: full
elastic-package check.Related issues
Screenshots
N/A