vectordotdev / vector

A high-performance observability data pipeline.
https://vector.dev
Mozilla Public License 2.0
17.07k stars 1.48k forks source link

VRL compilation warning for `set_secret` #20809

Closed bobelev closed 1 week ago

bobelev commented 1 week ago

A note for the community

Problem

Using set_sector in a remap transform produces a warning on startup. It works as expected tho. This warning is misleading and leaks secrets to the logs.

Another strange behaviour: when .event.category is commented out, then the warning disappears.

Configuration

data_dir: /var/lib/vector/
sources:
  source0:
    count: 9223372036854775807
    format: json
    interval: 1.0
    type: demo_logs
    decoding:
      codec: bytes
    framing:
      method: bytes
transforms:
  transform0:
    inputs:
      - source0
    drop_on_abort: false
    drop_on_error: false
    metric_tag_values: single
    reroute_dropped: false
    type: remap
    source: |
      %index = "linux_auth"
      set_secret("splunk_hec_token", "B7E5D595-61E8-4008-A556-E557421E81F0")
      .event.category = "authentication"
sinks:
  sink0:
    inputs:
      - transform0
    target: stdout
    type: console
    encoding:
      codec: json
      json:
        pretty: true
    buffer:
      type: memory
      max_events: 500
      when_full: block

tests:
  - name: name0
    inputs:
      - insert_at: transform0
        type: log
        log_fields:
          bytes: 32544
          datetime: 08/Jul/2024:12:31:10
          host: 22.183.99.160
          method: PUT
          protocol: HTTP/2.0
          referer: https://some.pf/booper/bopper/mooper/mopper
          request: /observability/metrics/production
          status: "300"

    outputs:
      - extract_from: transform0
        conditions:
          - type: vrl
            source: |
              assert_eq!(%index, "linux_auth")
              assert_eq!(.status, "300")

Version

vector 0.39.0

Debug Output

Running tests
2024-07-08T09:39:48.574972Z  WARN transform{component_kind="transform" component_id=transform0 component_type=remap}: vector::transforms::remap: VRL compilation warning. warnings=
warning[E900]: unused result for function call `set_secret("splunk_hec_token", "B7E5D595-61E8-4008-A556-E557421E81F0")`
  ┌─ :2:1
  │
2 │ set_secret("splunk_hec_token", "B7E5D595-61E8-4008-A556-E557421E81F0")
  │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the result of this expression or remove it
  │
  = this expression has no side-effects
  = see language documentation at https://vrl.dev
  = try your code in the VRL REPL, learn more at https://vrl.dev/examples

test name0 ... passed


### Example Data

_No response_

### Additional Context

_No response_

### References

_No response_
jszwedko commented 1 week ago

Thanks for this report @bobelev . It was a pretty quick fix so I opened https://github.com/vectordotdev/vector/pull/20820