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

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

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

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

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

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

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

        - from: "zeek.ssl.server_name"
          to: "zeek.ssl.server.name"

        - from: "zeek.ssl.cert_chain"
          to: "zeek.ssl.server.cert_chain"

        - from: "zeek.ssl.cert_chain_fuids"
          to: "zeek.ssl.server.cert_chain_fuids"

        - from: "zeek.ssl.client_cert_chain"
          to: "zeek.ssl.client.cert_chain"

        - from: "zeek.ssl.client_cert_chain_fuids"
          to: "zeek.ssl.client.cert_chain_fuids"

        - from: "zeek.ssl.validation_status"
          to: "zeek.ssl.validation.status"

        - from: "zeek.ssl.validation_code"
          to: "zeek.ssl.validation.code"

        # These JA3 fields are available when using the zeek/salesforce/ja3 package.
        - from: zeek.ssl.ja3
          to: tls.client.ja3
        - from: zeek.ssl.ja3s
          to: tls.server.ja3s

        - from: zeek.ssl.not_valid_before
          to: tls.server.not_before
        - from: zeek.ssl.not_valid_after
          to: tls.server.not_after

        - from: zeek.ssl.orig_certificate_sha1
          to: tls.client.hash.sha1
        - from: zeek.ssl.resp_certificate_sha1
          to: tls.server.hash.sha1
      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: "source.address", to: "client.address"}
        - {from: "destination.address", to: "destination.ip", type: "ip"}
        - {from: "destination.address", to: "server.address"}
      ignore_missing: true
      fail_on_error: false
  - 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
