Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conditionally add agentless index permissions #203810

Merged
merged 8 commits into from
Jan 7, 2025

Conversation

orestisfl
Copy link
Contributor

@orestisfl orestisfl commented Dec 11, 2024

Summary

Adds necessary permissions to write to the agentless-* index. See:

As part of https://github.com/elastic/security-team/issues/11104, we need to write integration data that needs to be persistent. The implementation we are working on, uses Elasticsearch as the storage mechanism for this data.

Normally, integrations write to data streams instead of normal ES indices. However, data streams cannot provide a generic implementation for our use case and thus we need a normal ES index.

This PR grants permissions from the fleet service account to the agentless integrations to write to agentless-* ES indices.

In x-pack/plugins/fleet/server/services/agent_policies/package_policies_to_agent_permissions.ts there are other examples of other integrations that need ES index permissions so there is prior art in doing this. The difference with this PR however, is that we need to conditionally merge the extra agentless-* permissions with any potential existing data stream permissions since we are dealing with arbitrary agentless integrations.

Checklist

Check the PR satisfies following conditions.

Reviewers should verify this PR satisfies this list as well.

  • Any text added follows EUI's writing guidelines, uses sentence case text and includes i18n support
  • Documentation was added for features that require explanation or tutorials
  • Unit or functional tests were updated or added to match the most common scenarios
  • If a plugin configuration key changed, check if it needs to be allowlisted in the cloud and added to the docker list
  • This was checked for breaking HTTP API changes, and any breaking changes have been approved by the breaking-change committee. The release_note:breaking label should be applied in these situations.
  • Flaky Test Runner was used on any tests changed
  • The PR description includes the appropriate Release Notes section, and the correct release_note:* label is applied per the guidelines

Identify risks

Does this PR introduce any risks? For example, consider risks like hard to test bugs, performance regression, potential of data loss.

Describe the risk, its severity, and mitigation for each identified risk. Invite stakeholders and evaluate how to proceed before merging.

@orestisfl orestisfl force-pushed the agentless-storage-permissions branch from 72913fb to fa79140 Compare December 11, 2024 14:43
@orestisfl orestisfl marked this pull request as ready for review December 16, 2024 10:14
@orestisfl orestisfl requested a review from a team as a code owner December 16, 2024 10:14
@orestisfl orestisfl force-pushed the agentless-storage-permissions branch from b03c206 to 82cb077 Compare December 23, 2024 12:10
@botelastic botelastic bot added the Team:Fleet Team label for Observability Data Collection Fleet team label Dec 23, 2024
@elasticmachine
Copy link
Contributor

Pinging @elastic/fleet (Team:Fleet)

@orestisfl orestisfl changed the title WIP: conditionally add agentless index permissions Conditionally add agentless index permissions Dec 24, 2024
@orestisfl orestisfl added v9.0.0 Team:Cloud Security Cloud Security team related backport:prev-minor Backport to (8.x) the previous minor version (i.e. one version back from main) v8.18.0 labels Dec 24, 2024
@elasticmachine
Copy link
Contributor

Pinging @elastic/kibana-cloud-security-posture (Team:Cloud Security)

@orestisfl orestisfl requested review from a team and seanrathier December 24, 2024 15:08
Copy link
Contributor

@seanrathier seanrathier left a comment

Choose a reason for hiding this comment

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

I don't fully understand why we need to do this. I tried getting the gist from reading the parent issues but still don't understand.

@orestisfl
Copy link
Contributor Author

I don't fully understand why we need to do this. I tried getting the gist from reading the parent issues but still don't understand.

Hey. As part of https://github.com/elastic/security-team/issues/11104, we need to write integration data that needs to be persistent. The implementation we are working on, uses Elasticsearch as the storage mechanism for this data.

Normally, integrations write to data streams instead of normal ES indices. However, data streams cannot provide a generic implementation for our use case and thus we need a normal ES index.

This PR grants permissions from the fleet service account to the agentless integrations to write to agentless-* ES indices.

In x-pack/plugins/fleet/server/services/agent_policies/package_policies_to_agent_permissions.ts there are other examples of other integrations that need ES index permissions so there is prior art in doing this. The difference with this PR however, is that we need to conditionally merge the extra agentless-* permissions with any potential existing data stream permissions since we are dealing with arbitrary agentless integrations.

I've added this comment to the description of the PR. Hope it helps, let me know if you need any further clarifications.

@orestisfl orestisfl requested a review from seanrathier January 2, 2025 09:17
Copy link
Contributor

@juliaElastic juliaElastic left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Contributor

@seanrathier seanrathier left a comment

Choose a reason for hiding this comment

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

Thanks for the explanation!

@orestisfl
Copy link
Contributor Author

@elasticmachine merge upstream

@orestisfl orestisfl added the release_note:skip Skip the PR/issue when compiling release notes label Jan 7, 2025
@elasticmachine
Copy link
Contributor

elasticmachine commented Jan 7, 2025

💚 Build Succeeded

  • Buildkite Build
  • Commit: a25b53c
  • Kibana Serverless Image: docker.elastic.co/kibana-ci/kibana-serverless:pr-203810-a25b53c5541c

Metrics [docs]

✅ unchanged

History

cc @orestisfl

@orestisfl orestisfl enabled auto-merge (squash) January 7, 2025 12:10
@orestisfl orestisfl merged commit d0166b6 into elastic:main Jan 7, 2025
10 checks passed
@kibanamachine
Copy link
Contributor

Starting backport for target branches: 8.x

https://github.com/elastic/kibana/actions/runs/12651677510

@kibanamachine
Copy link
Contributor

💔 All backports failed

Status Branch Result
8.x Backport failed because of merge conflicts

Manual backport

To create the backport manually run:

node scripts/backport --pr 203810

Questions ?

Please refer to the Backport tool documentation

@orestisfl
Copy link
Contributor Author

💚 All backports created successfully

Status Branch Result
8.x

Note: Successful backport PRs will be merged automatically after passing CI.

Questions ?

Please refer to the Backport tool documentation

kowalczyk-krzysztof pushed a commit to kowalczyk-krzysztof/kibana that referenced this pull request Jan 7, 2025
## Summary

Adds necessary permissions to write to the `agentless-*` index. See:
- Elasticsearch PR: elastic/elasticsearch#118644
- Context: elastic/security-team#11104

As part of elastic/security-team#11104, we
need to write integration data that needs to be persistent. The
implementation we are working on, uses Elasticsearch as the storage
mechanism for this data.

Normally, integrations write to data streams instead of normal ES
indices. However, data streams cannot provide a generic implementation
for our use case and thus we need a normal ES index.

This PR grants permissions from the fleet service account to the
agentless integrations to write to `agentless-*` ES indices.

In
`x-pack/plugins/fleet/server/services/agent_policies/package_policies_to_agent_permissions.ts`
there are other examples of other integrations that need ES index
permissions so there is prior art in doing this. The difference with
this PR however, is that we need to conditionally merge the extra
`agentless-*` permissions with any potential existing data stream
permissions since we are dealing with arbitrary agentless integrations.
orestisfl added a commit that referenced this pull request Jan 9, 2025
# Backport

This will backport the following commits from `main` to `8.x`:
- [Conditionally add agentless index permissions
(#203810)](#203810)

<!--- Backport version: 8.9.8 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sqren/backport)

<!--BACKPORT [{"author":{"name":"Orestis
Floros","email":"[email protected]"},"sourceCommit":{"committedDate":"2025-01-07T12:34:54Z","message":"Conditionally
add agentless index permissions (#203810)\n\n## Summary\n\nAdds
necessary permissions to write to the `agentless-*` index. See:\n-
Elasticsearch PR:
https://github.com/elastic/elasticsearch/pull/118644\n- Context:
https://github.com/elastic/security-team/issues/11104\n\nAs part of
elastic/security-team#11104, we\nneed to write
integration data that needs to be persistent. The\nimplementation we are
working on, uses Elasticsearch as the storage\nmechanism for this
data.\n\nNormally, integrations write to data streams instead of normal
ES\nindices. However, data streams cannot provide a generic
implementation\nfor our use case and thus we need a normal ES
index.\n\nThis PR grants permissions from the fleet service account to
the\nagentless integrations to write to `agentless-*` ES
indices.\n\nIn\n`x-pack/plugins/fleet/server/services/agent_policies/package_policies_to_agent_permissions.ts`\nthere
are other examples of other integrations that need ES index\npermissions
so there is prior art in doing this. The difference with\nthis PR
however, is that we need to conditionally merge the extra\n`agentless-*`
permissions with any potential existing data stream\npermissions since
we are dealing with arbitrary agentless
integrations.","sha":"d0166b6730e8cf712aa0f7fc3a38f00fa7693396","branchLabelMapping":{"^v9.0.0$":"main","^v8.18.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","Team:Fleet","v9.0.0","Team:Cloud
Security","backport:prev-minor","ci:build-serverless-image","v8.18.0"],"number":203810,"url":"https://github.com/elastic/kibana/pull/203810","mergeCommit":{"message":"Conditionally
add agentless index permissions (#203810)\n\n## Summary\n\nAdds
necessary permissions to write to the `agentless-*` index. See:\n-
Elasticsearch PR:
https://github.com/elastic/elasticsearch/pull/118644\n- Context:
https://github.com/elastic/security-team/issues/11104\n\nAs part of
elastic/security-team#11104, we\nneed to write
integration data that needs to be persistent. The\nimplementation we are
working on, uses Elasticsearch as the storage\nmechanism for this
data.\n\nNormally, integrations write to data streams instead of normal
ES\nindices. However, data streams cannot provide a generic
implementation\nfor our use case and thus we need a normal ES
index.\n\nThis PR grants permissions from the fleet service account to
the\nagentless integrations to write to `agentless-*` ES
indices.\n\nIn\n`x-pack/plugins/fleet/server/services/agent_policies/package_policies_to_agent_permissions.ts`\nthere
are other examples of other integrations that need ES index\npermissions
so there is prior art in doing this. The difference with\nthis PR
however, is that we need to conditionally merge the extra\n`agentless-*`
permissions with any potential existing data stream\npermissions since
we are dealing with arbitrary agentless
integrations.","sha":"d0166b6730e8cf712aa0f7fc3a38f00fa7693396"}},"sourceBranch":"main","suggestedTargetBranches":["8.x"],"targetPullRequestStates":[{"branch":"main","label":"v9.0.0","labelRegex":"^v9.0.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/203810","number":203810,"mergeCommit":{"message":"Conditionally
add agentless index permissions (#203810)\n\n## Summary\n\nAdds
necessary permissions to write to the `agentless-*` index. See:\n-
Elasticsearch PR:
https://github.com/elastic/elasticsearch/pull/118644\n- Context:
https://github.com/elastic/security-team/issues/11104\n\nAs part of
elastic/security-team#11104, we\nneed to write
integration data that needs to be persistent. The\nimplementation we are
working on, uses Elasticsearch as the storage\nmechanism for this
data.\n\nNormally, integrations write to data streams instead of normal
ES\nindices. However, data streams cannot provide a generic
implementation\nfor our use case and thus we need a normal ES
index.\n\nThis PR grants permissions from the fleet service account to
the\nagentless integrations to write to `agentless-*` ES
indices.\n\nIn\n`x-pack/plugins/fleet/server/services/agent_policies/package_policies_to_agent_permissions.ts`\nthere
are other examples of other integrations that need ES index\npermissions
so there is prior art in doing this. The difference with\nthis PR
however, is that we need to conditionally merge the extra\n`agentless-*`
permissions with any potential existing data stream\npermissions since
we are dealing with arbitrary agentless
integrations.","sha":"d0166b6730e8cf712aa0f7fc3a38f00fa7693396"}},{"branch":"8.x","label":"v8.18.0","labelRegex":"^v8.18.0$","isSourceBranch":false,"state":"NOT_CREATED"}]}]
BACKPORT-->
orestisfl added a commit to elastic/elasticsearch that referenced this pull request Jan 10, 2025
Closes elastic/security-team#11102
Closes elastic/security-team#11104

This allows agentless integrations (via elastic/beats#41446, elastic/kibana#203810) to write to agentless-* indices. Each index is created on-demand by the filebeat client and kibana conditionally extends the API key permissions to allow writing to the index.
orestisfl added a commit to orestisfl/elasticsearch that referenced this pull request Jan 10, 2025
)

Closes elastic/security-team#11102
Closes elastic/security-team#11104

This allows agentless integrations (via elastic/beats#41446, elastic/kibana#203810) to write to agentless-* indices. Each index is created on-demand by the filebeat client and kibana conditionally extends the API key permissions to allow writing to the index.

(cherry picked from commit 3c184b9)

# Conflicts:
#	docs/reference/rest-api/security/get-service-accounts.asciidoc
#	x-pack/plugin/security/qa/service-account/src/javaRestTest/java/org/elasticsearch/xpack/security/authc/service/ServiceAccountIT.java
#	x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/authc/service/ElasticServiceAccounts.java
CAWilson94 pushed a commit to CAWilson94/kibana that referenced this pull request Jan 13, 2025
## Summary

Adds necessary permissions to write to the `agentless-*` index. See:
- Elasticsearch PR: elastic/elasticsearch#118644
- Context: elastic/security-team#11104

As part of elastic/security-team#11104, we
need to write integration data that needs to be persistent. The
implementation we are working on, uses Elasticsearch as the storage
mechanism for this data.

Normally, integrations write to data streams instead of normal ES
indices. However, data streams cannot provide a generic implementation
for our use case and thus we need a normal ES index.

This PR grants permissions from the fleet service account to the
agentless integrations to write to `agentless-*` ES indices.

In
`x-pack/plugins/fleet/server/services/agent_policies/package_policies_to_agent_permissions.ts`
there are other examples of other integrations that need ES index
permissions so there is prior art in doing this. The difference with
this PR however, is that we need to conditionally merge the extra
`agentless-*` permissions with any potential existing data stream
permissions since we are dealing with arbitrary agentless integrations.
orestisfl added a commit to elastic/elasticsearch that referenced this pull request Jan 13, 2025
…119973)

Closes elastic/security-team#11102
Closes elastic/security-team#11104

This allows agentless integrations (via elastic/beats#41446, elastic/kibana#203810) to write to agentless-* indices. Each index is created on-demand by the filebeat client and kibana conditionally extends the API key permissions to allow writing to the index.

(cherry picked from commit 3c184b9)

# Conflicts:
#	docs/reference/rest-api/security/get-service-accounts.asciidoc
#	x-pack/plugin/security/qa/service-account/src/javaRestTest/java/org/elasticsearch/xpack/security/authc/service/ServiceAccountIT.java
#	x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/authc/service/ElasticServiceAccounts.java
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport:prev-minor Backport to (8.x) the previous minor version (i.e. one version back from main) ci:build-serverless-image release_note:skip Skip the PR/issue when compiling release notes Team:Cloud Security Cloud Security team related Team:Fleet Team label for Observability Data Collection Fleet team v8.18.0 v9.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants