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

httpjson: Chain request tracer filename sanitization #37551

Closed
kcreddy opened this issue Jan 5, 2024 · 2 comments · Fixed by #37682
Closed

httpjson: Chain request tracer filename sanitization #37551

kcreddy opened this issue Jan 5, 2024 · 2 comments · Fixed by #37682
Assignees

Comments

@kcreddy
Copy link
Contributor

kcreddy commented Jan 5, 2024

Currently, for each chain step request, we can add request tracer enabled by following config:

- step:
      request.url: {{hostname}}/assets/export/$.export_uuid/chunks/$.chunks_available[:]
      request.method: GET
      request.tracer.filename: "../../logs/httpjson/http-request-trace-*.ndjson"

But, the filename sanitization only occurs on the base/parent tracer as per https://github.com/elastic/beats/blob/main/x-pack/filebeat/input/httpjson/input.go#L122-L125.

Use file sanitization on chain request/response tracer.

@botelastic botelastic bot added the needs_team Indicates that the issue/PR needs a Team:* label label Jan 5, 2024
@elasticmachine
Copy link
Collaborator

Pinging @elastic/security-external-integrations (Team:Security-External Integrations)

@botelastic botelastic bot removed the needs_team Indicates that the issue/PR needs a Team:* label label Jan 5, 2024
@kcreddy kcreddy changed the title httpjson: Chain tracer filename sanitization httpjson: Chain request tracer filename sanitization Jan 5, 2024
@efd6
Copy link
Contributor

efd6 commented Jan 14, 2024

Alternative proposal:

diff --git a/x-pack/filebeat/input/httpjson/input.go b/x-pack/filebeat/input/httpjson/input.go
index 928c056d2d..28f5e0c112 100644
--- a/x-pack/filebeat/input/httpjson/input.go
+++ b/x-pack/filebeat/input/httpjson/input.go
@@ -122,6 +122,15 @@ func run(ctx v2.Context, cfg config, pub inputcursor.Publisher, crsr *inputcurso
        if cfg.Request.Tracer != nil {
                id := sanitizeFileName(ctx.ID)
                cfg.Request.Tracer.Filename = strings.ReplaceAll(cfg.Request.Tracer.Filename, "*", id)
+               // Propagate tracer behaviour to all chain children.
+               for i, c := range cfg.Chain {
+                       if c.Step != nil { // Request is validated as required.
+                               cfg.Chain[i].Step.Request.Tracer = cfg.Request.Tracer
+                       }
+                       if c.While != nil { // Request is validated as required.
+                               cfg.Chain[i].While.Request.Tracer = cfg.Request.Tracer
+                       }
+               }
        }
 
        metrics := newInputMetrics(reg)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants