Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions packages/cel/_dev/deploy/docker/files/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,17 @@ rules:
- status_code: 200
body: |
{"message": "success"}
- path: /testsecret/api
methods: [GET]
request_headers:
Accept:
- "application/json"
X-Api-Key:
- "test-secret-key"
responses:
- status_code: 200
body: |
{"message": "success"}
- path: /testoauth/token
methods: [POST]
query_params:
Expand Down
49 changes: 49 additions & 0 deletions packages/cel/_dev/test/policy/test-secret-state.expected
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
inputs:
- data_stream:
namespace: ep
meta:
package:
name: cel
name: test-secret-state-cel
streams:
- data_stream:
dataset: cel.cel
interval: 1m
program: |-
request("GET", state.url).with({
"Header": {"X-API-Key": [state.secret.api_key]}
}).do_request().as(resp, {
"events": [resp.Body.decode_json()],
"secret": state.secret,
})
publisher_pipeline.disable_host: true
redact.delete: false
regexp: null
resource.headers: null
resource.tracer:
enabled: false
filename: ../../logs/cel/http-request-trace-*.ndjson
maxbackups: 5
resource.url: https://server.example.com:8089/api
secret_state: ${SECRET_0}
tags:
- forwarded
xsd: null
type: cel
use_output: default
output_permissions:
default:
_elastic_agent_checks:
cluster:
- monitor
_elastic_agent_monitoring:
indices: []
uuid-for-permissions-on-related-indices:
indices:
- names:
- logs-*-*
privileges:
- auto_configure
- create_doc
secret_references:
- {}
14 changes: 14 additions & 0 deletions packages/cel/_dev/test/policy/test-secret-state.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
vars:
url: http://example.com:9001
program: |-
request("GET", state.url).with({
"Header": {"X-API-Key": [state.secret.api_key]}
}).do_request().as(resp, {
"events": [resp.Body.decode_json()],
"secret": state.secret,
})
secret_state: |-
api_key: my-secret-api-key
interval: 5m
preserve_original_event: true
preserve_duplicate_custom_fields: true
20 changes: 20 additions & 0 deletions packages/cel/_dev/test/system/test-secret-state-config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
vars:
redact_fields: [foo]
resource_url: http://{{Hostname}}:{{Port}}/testsecret/api
enable_request_tracer: true
secret_state: |-
api_key: test-secret-key
program: |
request("GET", state.url).with({
"Header": {
"Accept": ["application/json"],
"X-Api-Key": [state.secret.api_key],
}
}).do_request().as(resp, resp.StatusCode == 200 ?
resp.Body.as(body, {
"events": [body.decode_json()],
"secret": state.secret,
})
:
{"events": []}
)
4 changes: 4 additions & 0 deletions packages/cel/agent/input/input.yml.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ program: {{escape_string program}}
state:
{{state}}
{{/if}}
{{#if secret_state}}
secret_state:
{{secret_state}}
{{/if}}
redact.delete: {{delete_redacted_fields}}
{{#if redact_fields}}
redact.fields:
Expand Down
5 changes: 5 additions & 0 deletions packages/cel/changelog.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
- version: "1.20.0"
changes:
- description: Add secret state configuration for encrypted credentials in CEL programs.
type: enhancement
link: https://github.com/elastic/integrations/pull/18834
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟠 High cel/changelog.yml:5

The changelog entry at line 5 uses https://github.com/elastic/integrations/pull/XXXXX as a placeholder PR link, which will be published as a broken link that 404s. Consider replacing XXXXX with the actual pull request number before merging.

-      link: https://github.com/elastic/integrations/pull/XXXXX
+      link: https://github.com/elastic/integrations/pull/XXXXX
🤖 Copy this AI Prompt to have your agent fix this:
In file packages/cel/changelog.yml around line 5:

The changelog entry at line 5 uses `https://github.com/elastic/integrations/pull/XXXXX` as a placeholder PR link, which will be published as a broken link that 404s. Consider replacing `XXXXX` with the actual pull request number before merging.

- version: "1.19.0"
changes:
- description: Add options for including global HTTP request headers.
Expand Down
17 changes: 15 additions & 2 deletions packages/cel/manifest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ name: cel
title: Custom API using Common Expression Language
description: Collect custom events from an API with Elastic agent
type: input
version: "1.19.0"
version: "1.20.0"
categories:
- custom
conditions:
kibana:
version: "^8.19.0 || ^9.1.0"
version: "^8.19.17 || ^9.3.6 || ^9.4.1"
elastic:
subscription: "basic"
policy_templates:
Expand Down Expand Up @@ -81,10 +81,23 @@ policy_templates:
title: Initial CEL evaluation state
description: |
State is the initial state to be provided to the program. If it has a cursor field, that field will be overwritten by any stored cursor, but will be available if no stored cursor exists.
The state must not contain a `secret` key; use the Secret State field instead.
More information can be found in the [documentation](https://www.elastic.co/guide/en/beats/filebeat/current/filebeat-input-cel.html#input-state-cel).
show_user: true
multi: false
required: false
- name: secret_state
type: textarea
title: Secret CEL evaluation state
description: |
Secret state holds key-value pairs that are stored encrypted by Fleet and made available to the CEL program at `state.secret`.
Use this for API keys, tokens, and other credentials that should not be visible in the integration configuration.
Values are automatically redacted in debug logs.
More information can be found in the [documentation](https://www.elastic.co/guide/en/beats/filebeat/current/filebeat-input-cel.html#secret-state-cel).
show_user: true
multi: false
required: false
secret: true
- name: allowed_environment
type: text
title: Allowed environment variables
Expand Down
Loading