# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
---

transforms:
    - taskgraph.transforms.task_context

kind-dependencies:
    - build

task-defaults:
    run:
        using: run-task
        checkout:
            nss:
                path: nss
        command: "${{VCS_PATH}}/nss/automation/taskcluster/scripts/fuzz.sh {target} {corpus} -max_total_time={MAX_FUZZ_TIME}"
    worker:
        env:
            GTESTFILTER: "*Fuzz*"
            ASAN_OPTIONS: "allocator_may_return_null=1:detect_stack_use_after_return=1"
            UBSAN_OPTIONS: "print_stacktrace=1"
            NSS_DISABLE_ARENA_FREE_LIST: "1"
            NSS_DISABLE_UNLOAD: "1"
            CC: "clang"
            CCC: "clang++"
            TC_PARENT_TASK_ID: {task-reference: "<build>"}
        allow-ptrace: true
        docker-image: {in-tree: fuzz}
        max-run-time: 3600
    worker-type: t-linux
    task-context:
        from-object:
            MAX_FUZZ_TIME: 300
        substitution-fields:
            - run.command
    attributes:
        retrigger: true
    treeherder:
        kind: test

tasks:
    linux-x64-asn1:
        description: Linux x64 ASN1
        dependencies:
            build: build-linux-x64/debug-fuzz
        treeherder:
            symbol: ASN1
            platform: linux-x64/debug-fuzz
        task-context:
            from-object:
                target: asn1
                corpus: asn1

    linux-x64-certdn:
        description: Linux x64 CertDN
        dependencies:
            build: build-linux-x64/debug-fuzz
        treeherder:
            symbol: CertDN
            platform: linux-x64/debug-fuzz
        task-context:
            from-object:
                target: certDN
                corpus: certDN

    linux-x64-dsau:
        description: Linux x64 DSAU
        dependencies:
            build: build-linux-x64/debug-fuzz
        treeherder:
            symbol: DSAU
            platform: linux-x64/debug-fuzz
        task-context:
            from-object:
                target: dsau
                corpus: dsau

    linux-x64-ec-derive:
        description: Linux x64 EC Derive
        dependencies:
            build: build-linux-x64/debug-fuzz
        treeherder:
            symbol: ECDerive
            platform: linux-x64/debug-fuzz
        task-context:
            from-object:
                target: ec-derive
                corpus: ec-derive

    linux-x64-ech:
        description: Linux x64 ECH
        dependencies:
            build: build-linux-x64/debug-fuzz
        treeherder:
            symbol: ECH
            platform: linux-x64/debug-fuzz
        task-context:
            from-object:
                target: ech
                corpus: ech

    linux-x64-pkcs7:
        description: Linux x64 PKCS7
        dependencies:
            build: build-linux-x64/debug-fuzz
        treeherder:
            symbol: PKCS7
            platform: linux-x64/debug-fuzz
        task-context:
            from-object:
                target: pkcs7
                corpus: pkcs7

    linux-x64-pkcs8:
        description: Linux x64 PKCS8
        dependencies:
            build: build-linux-x64/debug-fuzz
        treeherder:
            symbol: PKCS8
            platform: linux-x64/debug-fuzz
        task-context:
            from-object:
                target: pkcs8
                corpus: pkcs8

    linux-x64-pkcs12:
        description: Linux x64 PKCS12
        dependencies:
            build: build-linux-x64/debug-fuzz
        treeherder:
            symbol: PKCS12
            platform: linux-x64/debug-fuzz
        task-context:
            from-object:
                target: pkcs12
                corpus: pkcs12-no_fuzzer_mode

    linux-x64-quickder:
        description: Linux x64 QuickDER
        dependencies:
            build: build-linux-x64/debug-fuzz
        treeherder:
            symbol: QuickDER
            platform: linux-x64/debug-fuzz
        task-context:
            from-object:
                target: quickder
                corpus: quickder

    linux-x64-smime:
        description: Linux x64 SMIME
        dependencies:
            build: build-linux-x64/debug-fuzz
        treeherder:
            symbol: SMIME
            platform: linux-x64/debug-fuzz
        task-context:
            from-object:
                target: smime
                corpus: smime

    linux-x64-tls-client:
        description: Linux x64 TLS Client
        dependencies:
            build: build-linux-x64/debug-fuzz
        treeherder:
            symbol: TLS-Client
            platform: linux-x64/debug-fuzz
        task-context:
            from-object:
                target: tls-client
                corpus: tls-client-no_fuzzer_mode

    linux-x64-tls-server:
        description: Linux x64 TLS Server
        dependencies:
            build: build-linux-x64/debug-fuzz
        treeherder:
            symbol: TLS-Server
            platform: linux-x64/debug-fuzz
        task-context:
            from-object:
                target: tls-server
                corpus: tls-server-no_fuzzer_mode

    linux-x64-dtls-client:
        description: Linux x64 DTLS Client
        dependencies:
            build: build-linux-x64/debug-fuzz
        treeherder:
            symbol: DTLS-Client
            platform: linux-x64/debug-fuzz
        task-context:
            from-object:
                target: dtls-client
                corpus: dtls-client-no_fuzzer_mode

    linux-x64-dtls-server:
        description: Linux x64 DTLS Server
        dependencies:
            build: build-linux-x64/debug-fuzz
        treeherder:
            symbol: DTLS-Server
            platform: linux-x64/debug-fuzz
        task-context:
            from-object:
                target: dtls-server
                corpus: dtls-server-no_fuzzer_mode

    linux-x64-cryptofuzz:
        description: Cryptofuzz
        dependencies:
            build: build-linux-x64/debug-fuzz
        run:
            command: "${{VCS_PATH}}/nss/automation/taskcluster/scripts/cryptofuzz.sh -max_total_time={MAX_FUZZ_TIME}"
        treeherder:
            symbol: Cryptofuzz
            platform: linux-x64/debug-fuzz

    linux-x64-tlsfuzz-pkcs12:
        description: Linux x64 PKCS12
        dependencies:
            build: build-linux-x64/debug-tlsfuzz
        treeherder:
            symbol: TLS(PKCS12)
            platform: linux-x64/debug-fuzz
        task-context:
            from-object:
                target: pkcs12
                corpus: pkcs12

    linux-x64-tlsfuzz-tls-client:
        description: Linux x64 TLS Client
        dependencies:
            build: build-linux-x64/debug-tlsfuzz
        treeherder:
            symbol: TLS(TLS-Client)
            platform: linux-x64/debug-fuzz
        task-context:
            from-object:
                target: tls-client
                corpus: tls-client

    linux-x64-tlsfuzz-tls-server:
        description: Linux x64 TLS Server
        dependencies:
            build: build-linux-x64/debug-tlsfuzz
        treeherder:
            symbol: TLS(TLS-Server)
            platform: linux-x64/debug-fuzz
        task-context:
            from-object:
                target: tls-server
                corpus: tls-server

    linux-x64-tlsfuzz-dtls-client:
        description: Linux x64 DTLS Client
        dependencies:
            build: build-linux-x64/debug-tlsfuzz
        treeherder:
            symbol: TLS(DTLS-Client)
            platform: linux-x64/debug-fuzz
        task-context:
            from-object:
                target: dtls-client
                corpus: dtls-client

    linux-x64-tlsfuzz-dtls-server:
        description: Linux x64 DTLS Server
        dependencies:
            build: build-linux-x64/debug-tlsfuzz
        treeherder:
            symbol: TLS(DTLS-Server)
            platform: linux-x64/debug-fuzz
        task-context:
            from-object:
                target: dtls-server
                corpus: dtls-server

    linux-x86-asn1:
        description: Linux 32 ASN1
        dependencies:
            build: build-linux-x86/debug-fuzz
        treeherder:
            symbol: ASN1
            platform: linux-x86/debug-fuzz
        task-context:
            from-object:
                target: asn1
                corpus: asn1

    linux-x86-certdn:
        description: Linux 32 CertDN
        dependencies:
            build: build-linux-x86/debug-fuzz
        treeherder:
            symbol: CertDN
            platform: linux-x86/debug-fuzz
        task-context:
            from-object:
                target: certDN
                corpus: certDN

    linux-x86-dsau:
        description: Linux 32 DSAU
        dependencies:
            build: build-linux-x86/debug-fuzz
        treeherder:
            symbol: DSAU
            platform: linux-x86/debug-fuzz
        task-context:
            from-object:
                target: dsau
                corpus: dsau

    linux-x86-ec-derive:
        description: Linux 32 EC Derive
        dependencies:
            build: build-linux-x86/debug-fuzz
        treeherder:
            symbol: ECDerive
            platform: linux-x86/debug-fuzz
        task-context:
            from-object:
                target: ec-derive
                corpus: ec-derive

    linux-x86-ech:
        description: Linux 32 ECH
        dependencies:
            build: build-linux-x86/debug-fuzz
        treeherder:
            symbol: ECH
            platform: linux-x86/debug-fuzz
        task-context:
            from-object:
                target: ech
                corpus: ech

    linux-x86-pkcs7:
        description: Linux 32 PKCS7
        dependencies:
            build: build-linux-x86/debug-fuzz
        treeherder:
            symbol: PKCS7
            platform: linux-x86/debug-fuzz
        task-context:
            from-object:
                target: pkcs7
                corpus: pkcs7

    linux-x86-pkcs8:
        description: Linux 32 PKCS8
        dependencies:
            build: build-linux-x86/debug-fuzz
        treeherder:
            symbol: PKCS8
            platform: linux-x86/debug-fuzz
        task-context:
            from-object:
                target: pkcs8
                corpus: pkcs8

    linux-x86-pkcs12:
        description: Linux 32 PKCS12
        dependencies:
            build: build-linux-x86/debug-fuzz
        treeherder:
            symbol: PKCS12
            platform: linux-x86/debug-fuzz
        task-context:
            from-object:
                target: pkcs12
                corpus: pkcs12-no_fuzzer_mode

    linux-x86-quickder:
        description: Linux 32 QuickDER
        dependencies:
            build: build-linux-x86/debug-fuzz
        treeherder:
            symbol: QuickDER
            platform: linux-x86/debug-fuzz
        task-context:
            from-object:
                target: quickder
                corpus: quickder

    linux-x86-smime:
        description: Linux 32 SMIME
        dependencies:
            build: build-linux-x86/debug-fuzz
        treeherder:
            symbol: SMIME
            platform: linux-x86/debug-fuzz
        task-context:
            from-object:
                target: smime
                corpus: smime

    linux-x86-tls-client:
        description: Linux 32 TLS Client
        dependencies:
            build: build-linux-x86/debug-fuzz
        treeherder:
            symbol: TLS-Client
            platform: linux-x86/debug-fuzz
        task-context:
            from-object:
                target: tls-client
                corpus: tls-client-no_fuzzer_mode

    linux-x86-tls-server:
        description: Linux 32 TLS Server
        dependencies:
            build: build-linux-x86/debug-fuzz
        treeherder:
            symbol: TLS-Server
            platform: linux-x86/debug-fuzz
        task-context:
            from-object:
                target: tls-server
                corpus: tls-server-no_fuzzer_mode

    linux-x86-dtls-client:
        description: Linux 32 DTLS Client
        dependencies:
            build: build-linux-x86/debug-fuzz
        treeherder:
            symbol: DTLS-Client
            platform: linux-x86/debug-fuzz
        task-context:
            from-object:
                target: dtls-client
                corpus: dtls-client-no_fuzzer_mode

    linux-x86-dtls-server:
        description: Linux 32 DTLS Server
        dependencies:
            build: build-linux-x86/debug-fuzz
        treeherder:
            symbol: DTLS-Server
            platform: linux-x86/debug-fuzz
        task-context:
            from-object:
                target: dtls-server
                corpus: dtls-server-no_fuzzer_mode

    linux-x86-cryptofuzz:
        description: Cryptofuzz
        dependencies:
            build: build-linux-x86/debug-fuzz
        run:
            command: "${{VCS_PATH}}/nss/automation/taskcluster/scripts/cryptofuzz.sh -max_total_time={MAX_FUZZ_TIME}"
        treeherder:
            symbol: Cryptofuzz
            platform: linux-x86/debug-fuzz

    linux-x86-tlsfuzz-pkcs12:
        description: Linux 32 PKCS12
        dependencies:
            build: build-linux-x86/debug-tlsfuzz
        treeherder:
            symbol: TLS(PKCS12)
            platform: linux-x86/debug-fuzz
        task-context:
            from-object:
                target: pkcs12
                corpus: pkcs12

    linux-x86-tlsfuzz-tls-client:
        description: Linux 32 TLS Client
        dependencies:
            build: build-linux-x86/debug-tlsfuzz
        treeherder:
            symbol: TLS(TLS-Client)
            platform: linux-x86/debug-fuzz
        task-context:
            from-object:
                target: tls-client
                corpus: tls-client

    linux-x86-tlsfuzz-tls-server:
        description: Linux 32 TLS Server
        dependencies:
            build: build-linux-x86/debug-tlsfuzz
        treeherder:
            symbol: TLS(TLS-Server)
            platform: linux-x86/debug-fuzz
        task-context:
            from-object:
                target: tls-server
                corpus: tls-server

    linux-x86-tlsfuzz-dtls-client:
        description: Linux 32 DTLS Client
        dependencies:
            build: build-linux-x86/debug-tlsfuzz
        treeherder:
            symbol: TLS(DTLS-Client)
            platform: linux-x86/debug-fuzz
        task-context:
            from-object:
                target: dtls-client
                corpus: dtls-client

    linux-x86-tlsfuzz-dtls-server:
        description: Linux 32 DTLS Server
        dependencies:
            build: build-linux-x86/debug-tlsfuzz
        treeherder:
            symbol: TLS(DTLS-Server)
            platform: linux-x86/debug-fuzz
        task-context:
            from-object:
                target: dtls-server
                corpus: dtls-server
