Skip to content

[BUG] Search API for rules does not support returning specific fields #331

@amsiglan

Description

@amsiglan

What is the bug?
Search API for rules does not support returning specific fields when the _source field is specified as part of the request body.

How can one reproduce the bug?
Steps to reproduce the behavior:

  1. Make following search REST API call
POST /_plugins/_security_analytics/rules/_search
{
  "query": {
    "nested": {
      "path": "rule",
      "query": {
        "term": {
          "rule.category": {
            "value": "network"
          }
        }
      }
    }
  },
  "_source": ["rule.title"]
}

It should only return the title field

{
  ...
    "hits": [
      {
        "_index": ".opensearch-sap-pre-packaged-rules-config",
        "_id": "503fe26e-b5f2-4944-a126-eab405cc06e5",
        "_score": 3.9827108,
        "_source": {
          "title": "Kerberos Network Traffic RC4 Ticket Encryption"
        }
      },
     ...
    ]
  }
}

but it returns all the fields as part of source

What is the expected behavior?
Only specified fields should be returned

What is your host/environment?
Opensearch 2.5

Do you have any screenshots?
NA

Do you have any additional context?
The underlying index does support this, so if the call is made against .opensearch-sap-pre-packaged-rules-config index, it works correctly

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingv2.7.0

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions