-
Couldn't load subscription status.
- Fork 504
[Akamai] - Migrated SIEM data stream from HTTPJSON to CEL input #15713
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
Open
ShourieG
wants to merge
9
commits into
elastic:main
Choose a base branch
from
ShourieG:akamai/cel_migration
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
9cfe35c
added initial working cel code without auth
ShourieG 5c11cff
updated with working CEL code with proper auth signature
ShourieG d2e92ce
updated state.url
ShourieG 175690c
migrated to cel with working system tests
ShourieG ffd666e
updated changelog
ShourieG d05fc95
updated stack version to support cel functions max(dyn,dyn) & sprintf()
ShourieG 42dcd3d
addressed Dan's suggestions
ShourieG b4206f4
updated changelog
ShourieG 2d32dc5
fixed yml formatting issues
ShourieG File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
159 changes: 159 additions & 0 deletions
159
packages/akamai/data_stream/siem/agent/stream/cel.yml.hbs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,159 @@ | ||
| config_version: 2 | ||
| interval: {{interval}} | ||
| resource: | ||
| url: {{api_host}}/siem/v1/configs/{{config_ids}} | ||
| {{#if ssl}} | ||
| ssl: {{ssl}} | ||
| {{/if}} | ||
| {{#if http_client_timeout}} | ||
| timeout: {{http_client_timeout}} | ||
| {{/if}} | ||
| {{#if proxy_url }} | ||
| proxy_url: {{proxy_url}} | ||
| {{/if}} | ||
| tracer: | ||
| enabled: {{enable_request_tracer}} | ||
| filename: "../../logs/cel/http-request-trace-*.ndjson" | ||
| maxbackups: 5 | ||
| {{#if max_executions}} | ||
| max_executions: {{max_executions}} | ||
| {{/if}} | ||
|
|
||
| state: | ||
| client_token: {{client_token}} | ||
| access_token: {{access_token}} | ||
| client_secret: {{client_secret}} | ||
| initial_interval: {{initial_interval}} | ||
| event_limit: {{event_limit}} | ||
|
|
||
| redact: | ||
| fields: | ||
| - client_secret | ||
| - access_token | ||
| - client_token | ||
|
|
||
| program: | | ||
| state.with( | ||
| ( | ||
| state.?cursor.recovery_mode.orValue(false) ? | ||
| { | ||
| "from": int(now - duration("12h")), | ||
| "to": int(now), | ||
| } | ||
| : state.?cursor.last_offset.hasValue() ? | ||
| { | ||
| "offset": state.cursor.last_offset, | ||
| } | ||
| : | ||
| { | ||
| "from": max(int(now - duration(state.initial_interval)), int(now - duration("12h"))), | ||
| "to": int(now), | ||
| } | ||
| ).as(params, | ||
| now.format("20060102T15:04:05-0700").as(timestamp, | ||
| uuid().as(nonce, | ||
| sprintf( | ||
| "EG1-HMAC-SHA256 client_token=%s;access_token=%s;timestamp=%s;nonce=%s;", | ||
| [state.client_token, state.access_token, timestamp, nonce] | ||
| ).as(sig_base, | ||
| base64(hmac(timestamp, "sha256", bytes(state.client_secret))).as(sig_key, | ||
| ( | ||
| state.url.trim_right("/") + "?" + { | ||
| "limit": [string(state.event_limit)], | ||
| ?"from": (params.?from.orValue("") != "") ? optional.of([string(params.from)]) : optional.none(), | ||
| ?"to": (params.?to.orValue("") != "") ? optional.of([string(params.to)]) : optional.none(), | ||
| ?"offset": (params.?offset.orValue("") != "") ? optional.of([string(params.offset)]) : optional.none(), | ||
| }.format_query() | ||
| ).parse_url().as(u, | ||
| sprintf( | ||
| "GET\t%s\t%s\t%s?%s\t\t\t%s", | ||
| [ | ||
| string(u.Scheme), | ||
| string(u.Host), | ||
| string(u.Path), | ||
| string(u.RawQuery), | ||
| sig_base, | ||
| ] | ||
| ).as(to_sign, | ||
| base64(hmac(to_sign, "sha256", bytes(sig_key))).as(signature, | ||
| sig_base + "signature=" + signature | ||
| ) | ||
| ) | ||
| ) | ||
| ) | ||
| ) | ||
| ) | ||
| ).as(auth_header, | ||
| request( | ||
| "GET", | ||
| state.url.trim_right("/") + "?" + { | ||
| "limit": [string(state.event_limit)], | ||
| ?"from": (params.?from.orValue("") != "") ? optional.of([string(params.from)]) : optional.none(), | ||
| ?"to": (params.?to.orValue("") != "") ? optional.of([string(params.to)]) : optional.none(), | ||
| ?"offset": (params.?offset.orValue("") != "") ? optional.of([string(params.offset)]) : optional.none(), | ||
| }.format_query() | ||
| ).with( | ||
| { | ||
| "Header": { | ||
| "Authorization": [auth_header], | ||
| }, | ||
| } | ||
| ).do_request().as(resp, | ||
| (resp.StatusCode == 200) ? | ||
| string(resp.Body).split("\n").filter(line, line != "").as(lines, | ||
| { | ||
| "events": lines.map(line, {"message": line}), | ||
| "cursor": { | ||
| ?"last_offset": (lines.size() > 0) ? | ||
| lines[lines.size() - 1].decode_json().as(lastEvent, | ||
| lastEvent.?offset | ||
| ) | ||
| : | ||
| optional.none(), | ||
| "recovery_mode": false, | ||
| }, | ||
| "want_more": (lines.size() > 0) ? | ||
| lines[lines.size() - 1].decode_json().as(lastEvent, | ||
| has(lastEvent.offset) && lastEvent.offset != "" | ||
| ) | ||
| : | ||
| false, | ||
| } | ||
| ) | ||
| : (resp.StatusCode == 416) ? | ||
| { | ||
| "events": { | ||
| "error": { | ||
| "code": string(resp.StatusCode), | ||
| "id": string(resp.Status), | ||
| "message": "GET " + state.url.trim_right("/") + ( | ||
| (size(resp.Body) != 0) ? | ||
| string(resp.Body) | ||
| : | ||
| string(resp.Status) + " (" + string(resp.StatusCode) + ")" | ||
| ), | ||
| }, | ||
| }, | ||
| "cursor": {"recovery_mode": true}, | ||
| "want_more": true, | ||
| } | ||
| : | ||
| { | ||
| "events": { | ||
| "error": { | ||
| "code": string(resp.StatusCode), | ||
| "id": string(resp.Status), | ||
| "message": "GET " + state.url.trim_right("/") + ( | ||
| (size(resp.Body) != 0) ? | ||
| string(resp.Body) | ||
| : | ||
| string(resp.Status) + " (" + string(resp.StatusCode) + ")" | ||
| ), | ||
| }, | ||
| }, | ||
| "want_more": false, | ||
| } | ||
| ) | ||
| ) | ||
| ) | ||
| ) |
103 changes: 0 additions & 103 deletions
103
packages/akamai/data_stream/siem/agent/stream/httpjson.yml.hbs
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
run
celfmton this