Skip to content

fix(rules): safely parse non-dotted tags and preserve custom namespaced governance tags - #1807

Open
AAH20 wants to merge 1 commit into
opensearch-project:mainfrom
AAH20:feat/support-non-attack-governance-tags
Open

fix(rules): safely parse non-dotted tags and preserve custom namespaced governance tags#1807
AAH20 wants to merge 1 commit into
opensearch-project:mainfrom
AAH20:feat/support-non-attack-governance-tags

Conversation

@AAH20

@AAH20 AAH20 commented Sep 4, 2026

Copy link
Copy Markdown

Description

This pull request addresses two related tag parsing and serialization issues in OpenSearch Security Analytics Sigma rules:

  1. Bug Fix (ArrayIndexOutOfBoundsException on single-token tags):
    Previously, SigmaRuleTag.fromStr(tag) unconditionally split on . and accessed tagParts[1] without checking array length (tag.split("\\.", 2)). If a rule or custom tag did not contain a period (such as "tag", "ransomware", or un-namespaced tags), SigmaRuleTag.fromStr threw an uncaught ArrayIndexOutOfBoundsException: Index 1 out of bounds for length 1.

    • Fix: When no . delimiter is present, SigmaRuleTag now safely treats the entire string as the tag name and initializes namespace as "".
    • In Rule.java, serialization now delegates to ruleTag.getFormattedTag() rather than formatting as "%s.%s", preventing unintended leading periods (e.g. ".tag").
  2. Support for Non-ATT&CK & Governance / Compliance Namespaced Tags:
    Modern SOC teams and detection engineers annotate rules with regulatory, governance, and asset risk tags (e.g., grc.nist.800-53.sc-8, compliance.pci-dss.10-2, asset.tier.0_critical).

    • SigmaRuleTag cleanly handles any namespace and multi-dotted sub-namespaces.
    • getFormattedTag() reconstructs the full original tag string identically.
  3. Testing:

    • Replaced the exception assertion in SigmaRuleTagTests.java with verification that single-token tags parse cleanly and format back to their original token.
    • Added test coverage (testSigmaRuleTagGovernanceAndCompliance) verifying that multi-segment compliance and asset tags (grc.*, asset.*) parse correctly and format back intact.

Related Issues

Resolves #1724
Relates to #1806

Check List

  • New functionality includes testing.
  • New functionality has been documented.
  • API changes companion pull request created.
  • Commits are signed per the DCO using --signoff.
  • Public documentation issue/PR created.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.

…ed governance tags

- Prevent ArrayIndexOutOfBoundsException in SigmaRuleTag.fromStr when parsing tags without dot delimiter (e.g. 'tag')
- Support empty namespace representation with getFormattedTag() to avoid prepending a dot on single-token tags
- Retain arbitrary namespaced governance and compliance tags (e.g. 'grc.nist.*', 'asset.tier.*') across rule serialization
- Update SigmaRuleTagTests to assert safe parsing of single-token tags and multi-segment governance tags
- Resolves opensearch-project#1724 and supports governance tagging for opensearch-project#1806

Signed-off-by: aah20 <[email protected]>
@github-actions

github-actions Bot commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

PR Reviewer Guide 🔍

Here are some key observations to aid the review process:

🧪 PR contains tests
🔒 No security concerns identified
✅ No TODO sections
🔀 No multiple PR themes
⚡ No major issues detected

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FEATURE] Preserve Sigma rule UUID or support non-ATT&CK namespaced metadata/tags

1 participant