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: ssh

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

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

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

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

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

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

        - from: "zeek.ssh.auth_attempts"
          to: "zeek.ssh.auth.attempts"

        - from: "zeek.ssh.auth_success"
          to: "zeek.ssh.auth.success"

        - from: "zeek.ssh.cipher_alg"
          to: "zeek.ssh.algorithm.cipher"

        - from: "zeek.ssh.mac_alg"
          to: "zeek.ssh.algorithm.mac"

        - from: "zeek.ssh.compression_alg"
          to: "zeek.ssh.algorithm.compression"

        - from: "zeek.ssh.kex_alg"
          to: "zeek.ssh.algorithm.key_exchange"

        - from: "zeek.ssh.host_key_alg"
          to: "zeek.ssh.algorithm.host_key"

      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:
          - connection
          - protocol
  - 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
