Skip to content

Commit c466d6c

Browse files
authored
osquery_manager 1.26.0: osquery 5.22.1, Kibana ^9.4.0, osquery-gen beats tag/branch (#18305)
- Regenerate schemas and fields for osquery 5.22.1; bump package and Kibana constraint. - Add optional beats.tag and beats.branch in osquery-gen (tag > branch > version).
1 parent 3bf4a55 commit c466d6c

7 files changed

Lines changed: 79 additions & 20 deletions

File tree

packages/osquery_manager/_dev/scripts/osquery-gen/README.md

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22

33
Config-driven generator for osquery_manager field/schema generation.
44

5-
This tool reads `osquery` and `beats` versions from `config.yml`, reads the ECS
6-
git ref from `packages/osquery_manager/_dev/build/build.yml`
5+
This tool reads `osquery` version and `beats` git selection from `config.yml`,
6+
reads the ECS git ref from `packages/osquery_manager/_dev/build/build.yml`
77
(`dependencies.ecs.reference`, e.g. `git@v9.3.0`), resolves the latest matching
8-
patch where applicable, and generates:
8+
patch for osquery/beats when using semver config, and generates:
99

1010
- `packages/osquery_manager/data_stream/result/fields/osquery.yml`
1111
- `packages/osquery_manager/data_stream/result/fields/ecs.yml`
@@ -29,7 +29,15 @@ beats:
2929
version: "9.3"
3030
```
3131
32-
Version values can be:
32+
**Beats** (extension specs under `elastic/beats`): set **either** an explicit git ref **or** a semver-style `version`. Precedence is **tag > branch > version**:
33+
34+
- `tag`: exact ref (for example `v9.4.2`); must contain the osquery extension specs path.
35+
- `branch`: branch name (for example `main`); same validation as `tag`.
36+
- `version`: exact patch or major/minor prefix (for example `9.3`) to auto-select a release tag, then the same ref probing as before.
37+
38+
If both `tag` and `branch` are set, `tag` wins.
39+
40+
**Osquery** `version` values can be:
3341

3442
- exact patch (for example `5.18.1`)
3543
- major/minor prefix (for example `5.18`) to auto-select latest patch
Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
osquery:
22
# Exact patch (5.21.0) or prefix (5.21) to auto-pick latest patch.
3-
version: "5.21"
3+
version: "5.22.1"
44
beats:
5-
# Exact patch (9.3.1) or prefix (9.3) to auto-pick latest patch.
6-
version: "9.3"
5+
# Git ref for elastic/beats osquery extension specs (raw.githubusercontent.com).
6+
# Precedence: tag > branch > version (semver / prefix resolution).
7+
# tag: "v9.4.2"
8+
# branch: "main"
9+
# Exact patch (9.3.1) or prefix (9.3) to auto-pick latest patch when tag/branch unset:
10+
version: "9.4.0"

packages/osquery_manager/_dev/scripts/osquery-gen/main.go

Lines changed: 47 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,18 @@ type versionConfig struct {
2828
Version string `yaml:"version"`
2929
}
3030

31+
type beatsConfig struct {
32+
// Tag is an exact git ref (e.g. v9.4.2). Takes precedence over Branch and Version.
33+
Tag string `yaml:"tag"`
34+
// Branch is a git branch name (e.g. main). Used when Tag is empty.
35+
Branch string `yaml:"branch"`
36+
// Version is a semver or major.minor prefix; used to resolve a tag when Tag and Branch are empty.
37+
Version string `yaml:"version"`
38+
}
39+
3140
type config struct {
3241
Osquery versionConfig `yaml:"osquery"`
33-
Beats versionConfig `yaml:"beats"`
42+
Beats beatsConfig `yaml:"beats"`
3443
}
3544

3645
type packageBuildYAML struct {
@@ -70,13 +79,9 @@ func main() {
7079
if err != nil {
7180
log.Fatalf("resolve osquery version: %v", err)
7281
}
73-
beatsTag, err := resolveLatestPatch("elastic/beats", cfg.Beats.Version)
82+
beatsRef, err := resolveBeatsGitRef(cfg.Beats)
7483
if err != nil {
75-
log.Fatalf("resolve beats version: %v", err)
76-
}
77-
beatsRef, err := resolveBeatsSpecsRef(cfg.Beats.Version, beatsTag)
78-
if err != nil {
79-
log.Fatalf("resolve beats specs ref: %v", err)
84+
log.Fatalf("resolve beats git ref: %v", err)
8085
}
8186
ecsVersionSpec, err := loadECSVersionSpecFromBuildYAML(outputRoot)
8287
if err != nil {
@@ -106,8 +111,8 @@ func loadConfig(path string) (config, error) {
106111
if strings.TrimSpace(cfg.Osquery.Version) == "" {
107112
return cfg, fmt.Errorf("osquery.version is required")
108113
}
109-
if strings.TrimSpace(cfg.Beats.Version) == "" {
110-
return cfg, fmt.Errorf("beats.version is required")
114+
if strings.TrimSpace(cfg.Beats.Tag) == "" && strings.TrimSpace(cfg.Beats.Branch) == "" && strings.TrimSpace(cfg.Beats.Version) == "" {
115+
return cfg, fmt.Errorf("beats: at least one of tag, branch, or version is required")
111116
}
112117
return cfg, nil
113118
}
@@ -264,6 +269,39 @@ func (s semver) String() string {
264269
return fmt.Sprintf("%d.%d.%d", s.Major, s.Minor, s.Patch)
265270
}
266271

272+
// resolveBeatsGitRef picks the elastic/beats ref for extension specs: tag > branch > semver version resolution.
273+
func resolveBeatsGitRef(cfg beatsConfig) (string, error) {
274+
if ref := strings.TrimSpace(cfg.Tag); ref != "" {
275+
ok, err := refHasBeatsSpecs(ref)
276+
if err != nil {
277+
return "", fmt.Errorf("beats tag %q: %w", ref, err)
278+
}
279+
if !ok {
280+
return "", fmt.Errorf("beats tag %q: no osquery extension specs at that ref", ref)
281+
}
282+
return ref, nil
283+
}
284+
if ref := strings.TrimSpace(cfg.Branch); ref != "" {
285+
ok, err := refHasBeatsSpecs(ref)
286+
if err != nil {
287+
return "", fmt.Errorf("beats branch %q: %w", ref, err)
288+
}
289+
if !ok {
290+
return "", fmt.Errorf("beats branch %q: no osquery extension specs at that ref", ref)
291+
}
292+
return ref, nil
293+
}
294+
versionSpec := strings.TrimSpace(cfg.Version)
295+
if versionSpec == "" {
296+
return "", fmt.Errorf("beats version is required when tag and branch are empty")
297+
}
298+
beatsTag, err := resolveLatestPatch("elastic/beats", versionSpec)
299+
if err != nil {
300+
return "", err
301+
}
302+
return resolveBeatsSpecsRef(versionSpec, beatsTag)
303+
}
304+
267305
func resolveBeatsSpecsRef(versionSpec, resolvedPatch string) (string, error) {
268306
candidates := make([]string, 0, 4)
269307
if resolvedPatch != "" {

packages/osquery_manager/changelog.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,13 @@
11
# newer versions go on top
2+
- version: "1.26.0"
3+
changes:
4+
- description: "Add optional beats `tag` and `branch` in osquery-gen config to pin elastic/beats extension specs"
5+
type: enhancement
6+
link: https://github.com/elastic/integrations/pull/18305
7+
- description: "Upgrade osquery version to 5.22.1"
8+
type: enhancement
9+
link: https://github.com/elastic/integrations/pull/18305
10+
211
- version: "1.25.0"
312
changes:
413
- description: Emit schemas/metadata.json from osquery-gen with ecs_version and osquery_version

packages/osquery_manager/manifest.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
format_version: 3.5.8
22
name: osquery_manager
33
title: Osquery Manager
4-
version: 1.25.0
4+
version: 1.26.0
55
description: Deploy Osquery with Elastic Agent, then run and schedule queries in Kibana
66
type: integration
77
categories:
88
- security
99
conditions:
1010
kibana:
11-
version: "^9.3.0"
11+
version: "^9.4.0"
1212
elastic:
1313
capabilities:
1414
- security
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{"ecs_version":"9.3.0","osquery_version":"5.21.0"}
1+
{"ecs_version":"9.3.0","osquery_version":"5.22.1"}

packages/osquery_manager/schemas/osquery.json

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)