type: log
paths:
{{ range $i, $path := .paths }}
 - {{$path}}
{{ end }}
exclude_files: [".gz$"]
tags: {{.tags | tojson}}
publisher_pipeline.disable_host: {{ inList .tags "forwarded" }}

json.keys_under_root: false

fields_under_root: true
fields:
  network.transport: tcp
  network.protocol: rdp

processors:
  - rename:
      fields:
        - from: "json"
          to: "zeek.rdp"

        - from: "zeek.rdp.id.orig_h"
          to: "source.address"

        - from: "zeek.rdp.id.orig_p"
          to: "source.port"

        - from: "zeek.rdp.id.resp_h"
          to: "destination.address"

        - from: "zeek.rdp.id.resp_p"
          to: "destination.port"

        - from: "zeek.rdp.uid"
          to: "zeek.session_id"

        - from: "zeek.rdp.client_build"
          to: "zeek.rdp.client.build"

        - from: "zeek.rdp.client_name"
          to: "zeek.rdp.client.name"

        - from: "zeek.rdp.client_dig_product_id"
          to: "zeek.rdp.client.product_id"

        - from: "zeek.rdp.desktop_width"
          to: "zeek.rdp.desktop.width"

        - from: "zeek.rdp.desktop_height"
          to: "zeek.rdp.desktop.height"

        - from: "zeek.rdp.requested_color_depth"
          to: "zeek.rdp.desktop.color_depth"

        - from: "zeek.rdp.cert_type"
          to: "zeek.rdp.cert.type"

        - from: "zeek.rdp.cert_count"
          to: "zeek.rdp.cert.count"

        - from: "zeek.rdp.cert_permanent"
          to: "zeek.rdp.cert.permanent"

        - from: "zeek.rdp.encryption_level"
          to: "zeek.rdp.encryption.level"

        - from: "zeek.rdp.encryption_method"
          to: "zeek.rdp.encryption.method"

      ignore_missing: true
      fail_on_error: false
  - convert:
      fields:
        - {from: "zeek.session_id", to: "event.id"}
        - {from: "source.address", to: "source.ip", type: "ip"}
        - {from: "destination.address", to: "destination.ip", type: "ip"}
  - add_fields:
      target: event
      fields:
        kind: event
        category:
          - network
        type:
          - protocol
          - info
  - community_id:
{{ if .internal_networks }}
  - add_network_direction:
      source: source.ip
      destination: destination.ip
      target: network.direction
      internal_networks: {{ .internal_networks | tojson }}
{{ end }}
  - add_fields:
      target: ''
      fields:
        ecs.version: 1.12.0
