Skip to content

[Bug] CLI detection_rules kibana import-rules imports all exceptions and connectors if --rule-file or --rule-id is set #4574

Open
@frederikb96

Description

@frederikb96

Describe the Bug

According to the CLI documentation for kibana import-rules command, when setting --rule-file or --rule-id argument, only a single rule should be imported and not everything recursively from the directory.

However, this imports all exceptions and connectors and not only the exception lists and connectors linked to the rule of interest.

So all exception lists and connectors are imported if the env CUSTOM_RULES_DIR is set (which is necessary to find items the rule depends on).

To Reproduce

In the Screenshare you can see the problem:

Screencast.From.2025-03-27.12-42-41.webm
  1. The env is set
  2. The command imports all the exceptions from the custom dir to Kibana though the rule doesn't contain any exceptions or connectors at all.
  3. Unset the env
  4. Only the rule is imported

Expected Behavior

Only the exceptions and connectors where the rule depends on should be imported.

Screenshots

No response

Desktop - OS

None

Desktop - Version

No response

Additional Context

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions