Skip to content

[Security Solution] Fix "unbounded array" code scanner warning for prebuilt rule assets#255741

Merged
nikitaindik merged 3 commits intoelastic:mainfrom
nikitaindik:fix/unbounded-array-schema-prebuilt-rules
Mar 6, 2026
Merged

[Security Solution] Fix "unbounded array" code scanner warning for prebuilt rule assets#255741
nikitaindik merged 3 commits intoelastic:mainfrom
nikitaindik:fix/unbounded-array-schema-prebuilt-rules

Conversation

@nikitaindik
Copy link
Copy Markdown
Contributor

@nikitaindik nikitaindik commented Mar 3, 2026

Resolves: https://github.com/elastic/kibana/security/code-scanning/2072

Summary

Adds a maxSize constraint to the tags field in the security-rule saved object schema (prebuilt_rule_assets_type.ts), resolving CodeQL alert #2072 (unbounded-array-in-schema).

  • Introduced a MAX_TAGS_PER_RULE constant (100) to bound the schema.arrayOf() call
  • Prebuilt rules typically have fewer than 15 tags, so 100 is a generous safe limit
  • No model version bump needed since this is a validation-only change with no structural/mapping impact

Adds a maxSize constraint to the tags field in the prebuilt rule
assets saved object schema to resolve CodeQL alert elastic#2072
(unbounded-array-in-schema).

Made-with: Cursor
@nikitaindik nikitaindik requested a review from a team as a code owner March 3, 2026 11:12
@nikitaindik nikitaindik added the release_note:skip Skip the PR/issue when compiling release notes label Mar 3, 2026
@nikitaindik nikitaindik requested a review from maximpn March 3, 2026 11:12
@nikitaindik nikitaindik self-assigned this Mar 3, 2026
@nikitaindik nikitaindik added backport:skip This PR does not require backporting Team:Detections and Resp Security Detection Response Team Team: SecuritySolution Security Solutions Team working on SIEM, Endpoint, Timeline, Resolver, etc. Team:Detection Rule Management Security Detection Rule Management Team labels Mar 3, 2026
@elasticmachine
Copy link
Copy Markdown
Contributor

Pinging @elastic/security-detection-rule-management (Team:Detection Rule Management)

@elasticmachine
Copy link
Copy Markdown
Contributor

Pinging @elastic/security-detections-response (Team:Detections and Resp)

@elasticmachine
Copy link
Copy Markdown
Contributor

Pinging @elastic/security-solution (Team: SecuritySolution)

@nikitaindik nikitaindik changed the title fix: add maxSize to unbounded arrayOf in prebuilt rule assets schema [Security Solution] Fix "unbounded array" code scanner warning for prebuilt rule assets Mar 3, 2026
@elastic-vault-github-plugin-prod elastic-vault-github-plugin-prod bot requested a review from a team as a code owner March 3, 2026 11:27
@elasticmachine
Copy link
Copy Markdown
Contributor

elasticmachine commented Mar 5, 2026

💔 Build Failed

Failed CI Steps

Test Failures

  • [job] [logs] Scout: [ platform / dashboard-stateful-classic ] plugin / local-stateful-classic - dashboard REST schema - Registered embeddable schemas have not changed

Metrics [docs]

✅ unchanged

History

cc @nikitaindik

@nikitaindik nikitaindik requested a review from banderror March 5, 2026 16:58
Copy link
Copy Markdown
Member

@gsoldevila gsoldevila left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes LGTM! You can disregard the `Check Saved Objects changes" soft failure, as you have schema-only changes.

Copy link
Copy Markdown
Contributor

@banderror banderror left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @nikitaindik, LGTM!

@banderror banderror removed the request for review from maximpn March 6, 2026 12:39
@nikitaindik nikitaindik merged commit 50e16fe into elastic:main Mar 6, 2026
16 checks passed
@banderror
Copy link
Copy Markdown
Contributor

@nikitaindik Is it worth backporting to active branches?

@nikitaindik
Copy link
Copy Markdown
Contributor Author

@banderror This CodeQL is running only on main, so no need to backport.

kapral18 pushed a commit to kapral18/kibana that referenced this pull request Mar 9, 2026
…ebuilt rule assets (elastic#255741)

**Resolves:
https://github.com/elastic/kibana/security/code-scanning/2072**

## Summary

Adds a `maxSize` constraint to the `tags` field in the `security-rule`
saved object schema (`prebuilt_rule_assets_type.ts`), resolving [CodeQL
alert
elastic#2072](https://github.com/elastic/kibana/security/code-scanning/2072)
(unbounded-array-in-schema).

- Introduced a `MAX_TAGS_PER_RULE` constant (100) to bound the
`schema.arrayOf()` call
- Prebuilt rules typically have fewer than 15 tags, so 100 is a generous
safe limit
- No model version bump needed since this is a validation-only change
with no structural/mapping impact

---------

Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
gsoldevila added a commit that referenced this pull request Mar 11, 2026
…without a version bump (#256432)

## Summary

When a saved object type's schema validation constraints are tightened
(e.g. adding a `maxSize` limit to an array field) without touching the
underlying ES mappings, the 'Check changes in Saved Objects' CI check
was incorrectly rejecting the change as a forbidden model version
mutation.

This PR relaxes the validation to allow schema-only changes to the
**latest** model version, provided all three conditions hold:
- Only the latest model version's schemas were modified (no older
versions touched).
- The mappings have not been modified.
- The latest model version's schema still covers all mapped fields
(`validateAllMappingsInModelVersion` still passes).

When this exceptional case is detected, a warning is emitted in the CI
output making it clear why the change is allowed and reminding that any
future mapping changes will still require a proper model version bump.

## Context

Fixes the CI failure on #255741,
where adding a `maxSize` constraint to the `tags` field in the
`security-rule` SO type caused the check to fail.

Tracking task: elastic/kibana-team#3021
(sub-issue of elastic/kibana-team#2349)

Made with [Cursor](https://cursor.com)
qn895 pushed a commit to qn895/kibana that referenced this pull request Mar 11, 2026
…ebuilt rule assets (elastic#255741)

**Resolves:
https://github.com/elastic/kibana/security/code-scanning/2072**

## Summary

Adds a `maxSize` constraint to the `tags` field in the `security-rule`
saved object schema (`prebuilt_rule_assets_type.ts`), resolving [CodeQL
alert
elastic#2072](https://github.com/elastic/kibana/security/code-scanning/2072)
(unbounded-array-in-schema).

- Introduced a `MAX_TAGS_PER_RULE` constant (100) to bound the
`schema.arrayOf()` call
- Prebuilt rules typically have fewer than 15 tags, so 100 is a generous
safe limit
- No model version bump needed since this is a validation-only change
with no structural/mapping impact

---------

Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
sorenlouv pushed a commit that referenced this pull request Mar 17, 2026
…without a version bump (#256432)

## Summary

When a saved object type's schema validation constraints are tightened
(e.g. adding a `maxSize` limit to an array field) without touching the
underlying ES mappings, the 'Check changes in Saved Objects' CI check
was incorrectly rejecting the change as a forbidden model version
mutation.

This PR relaxes the validation to allow schema-only changes to the
**latest** model version, provided all three conditions hold:
- Only the latest model version's schemas were modified (no older
versions touched).
- The mappings have not been modified.
- The latest model version's schema still covers all mapped fields
(`validateAllMappingsInModelVersion` still passes).

When this exceptional case is detected, a warning is emitted in the CI
output making it clear why the change is allowed and reminding that any
future mapping changes will still require a proper model version bump.

## Context

Fixes the CI failure on #255741,
where adding a `maxSize` constraint to the `tags` field in the
`security-rule` SO type caused the check to fail.

Tracking task: https://github.com/elastic/kibana-team/issues/3021
(sub-issue of https://github.com/elastic/kibana-team/issues/2349)

Made with [Cursor](https://cursor.com)
jeramysoucy pushed a commit to jeramysoucy/kibana that referenced this pull request Mar 26, 2026
…without a version bump (elastic#256432)

## Summary

When a saved object type's schema validation constraints are tightened
(e.g. adding a `maxSize` limit to an array field) without touching the
underlying ES mappings, the 'Check changes in Saved Objects' CI check
was incorrectly rejecting the change as a forbidden model version
mutation.

This PR relaxes the validation to allow schema-only changes to the
**latest** model version, provided all three conditions hold:
- Only the latest model version's schemas were modified (no older
versions touched).
- The mappings have not been modified.
- The latest model version's schema still covers all mapped fields
(`validateAllMappingsInModelVersion` still passes).

When this exceptional case is detected, a warning is emitted in the CI
output making it clear why the change is allowed and reminding that any
future mapping changes will still require a proper model version bump.

## Context

Fixes the CI failure on elastic#255741,
where adding a `maxSize` constraint to the `tags` field in the
`security-rule` SO type caused the check to fail.

Tracking task: elastic/kibana-team#3021
(sub-issue of elastic/kibana-team#2349)

Made with [Cursor](https://cursor.com)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport:skip This PR does not require backporting release_note:skip Skip the PR/issue when compiling release notes Team:Detection Rule Management Security Detection Rule Management Team Team:Detections and Resp Security Detection Response Team Team: SecuritySolution Security Solutions Team working on SIEM, Endpoint, Timeline, Resolver, etc. v9.4.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants