Skip to content

Commit cb124ca

Browse files
committed
fix: add maxSize to unbounded arrayOf in prebuilt rule assets schema
Adds a maxSize constraint to the tags field in the prebuilt rule assets saved object schema to resolve CodeQL alert #2072 (unbounded-array-in-schema). Made-with: Cursor
1 parent b9e6d54 commit cb124ca

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

  • x-pack/solutions/security/plugins/security_solution/server/lib/detection_engine/prebuilt_rules/logic/rule_assets

x-pack/solutions/security/plugins/security_solution/server/lib/detection_engine/prebuilt_rules/logic/rule_assets/prebuilt_rule_assets_type.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,14 @@ import type { SavedObjectsType } from '@kbn/core/server';
1111

1212
export const PREBUILT_RULE_ASSETS_SO_TYPE = 'security-rule';
1313

14+
/**
15+
* Upper bound for the number of tags per prebuilt rule asset.
16+
* In practice, prebuilt rule assets typically have fewer than 15 tags.
17+
* This limit exists to satisfy the "unbounded-array-in-schema" CodeQL check.
18+
* See: https://github.com/elastic/kibana/security/code-scanning/2072
19+
*/
20+
const MAX_TAGS_PER_RULE = 100;
21+
1422
const securityRuleV1 = schema.object(
1523
{
1624
rule_id: schema.string(),
@@ -22,7 +30,7 @@ const securityRuleV1 = schema.object(
2230
const securityRuleV2 = securityRuleV1.extends(
2331
{
2432
name: schema.string(),
25-
tags: schema.maybe(schema.arrayOf(schema.string())),
33+
tags: schema.maybe(schema.arrayOf(schema.string(), { maxSize: MAX_TAGS_PER_RULE })),
2634
severity: schema.string(),
2735
risk_score: schema.number(),
2836
},

0 commit comments

Comments
 (0)