# Licensed to Elasticsearch B.V. under one or more contributor
# license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright
# ownership. Elasticsearch B.V. licenses this file to you under
# the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# 	http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied.  See the License for the
# specific language governing permissions and limitations
# under the License.
---
- name: code_signature
  title: Code Signature
  group: 2
  description: These fields contain information about binary code signatures.
  type: group
  reusable:
    top_level: false
    expected:
      - file
      - process
      - dll
      # - driver
  fields:

    - name: exists
      level: core
      type: boolean
      description: Boolean to capture if a signature is present.
      example: "true"

    - name: subject_name
      level: core
      type: keyword
      description: Subject name of the code signer
      example: Microsoft Corporation

    - name: valid
      level: extended
      type: boolean
      short: Boolean to capture if the digital signature is verified against the binary content.
      example: "true"
      description: >
        Boolean to capture if the digital signature is verified against the binary content.

        Leave unpopulated if a certificate was unchecked.

    - name: trusted
      level: extended
      type: boolean
      short: Stores the trust status of the certificate chain.
      example: "true"
      description: >
        Stores the trust status of the certificate chain.

        Validating the trust of the certificate chain may be complicated, and this field should only be populated
        by tools that actively check the status.


    - name: status
      level: extended
      type: keyword
      short: Additional information about the certificate status.
      description: >
        Additional information about the certificate status.

        This is useful for logging cryptographic errors with the certificate validity or trust status.
        Leave unpopulated if the validity or trust of the certificate was unchecked.
      example: ERROR_UNTRUSTED_ROOT

    - name: team_id
      level: extended
      type: keyword
      short: The team identifier used to sign the process.
      description: >
        The team identifier used to sign the process.

        This is used to identify the team or vendor of a software product.
        The field is relevant to Apple *OS only.
      example: EQHXZ8M8AV

    - name: signing_id
      level: extended
      type: keyword
      short: The identifier used to sign the process.
      description: >
        The identifier used to sign the process.

        This is used to identify the application manufactured by a software vendor.
        The field is relevant to Apple *OS only.
      example: com.apple.xpc.proxy

    - name: digest_algorithm
      level: extended
      type: keyword
      short: Hashing algorithm used to sign the process.
      description: >
        The hashing algorithm used to sign the process.

        This value can distinguish signatures when a file is signed multiple times
        by the same signer but with a different digest algorithm.
      example: sha256

    - name: timestamp
      level: extended
      type: date
      short: When the signature was generated and signed.
      description: >
        Date and time when the code signature was generated and signed.
      example: "2021-01-01T12:10:30Z"
