libddwaf-src 2.1.0

Source distribution and build integration for DataDog/libddwaf
Documentation
// Unless explicitly stated otherwise all files in this repository are
// dual-licensed under the Apache-2.0 License or BSD-3-Clause License.
//
// This product includes software developed at Datadog (https://www.datadoghq.com/).
// Copyright 2021 Datadog, Inc.

#pragma once

#include "argument_retriever.hpp"
#include "clock.hpp"
#include "condition/base.hpp"
#include "condition/structured_condition.hpp"
#include "exclusion/common.hpp"
#include "object.hpp"
#include <array>
#include <string_view>
#include <utility>
#include <vector>

namespace ddwaf {

class exists_condition : public base_impl<exists_condition> {
public:
    static constexpr std::array<std::string_view, 1> param_names{"inputs"};

    explicit exists_condition(std::vector<condition_parameter> args)
        : base_impl<exists_condition>(std::move(args))
    {}

protected:
    [[nodiscard]] bool eval_impl(const variadic_argument<object_view> &inputs,
        condition_cache &cache, const object_set_ref &objects_excluded,
        ddwaf::timer &deadline) const;

    friend class base_impl<exists_condition>;
};

class negated_exists_condition : public base_impl<negated_exists_condition> {
public:
    static constexpr std::array<std::string_view, 1> param_names{"inputs"};

    explicit negated_exists_condition(std::vector<condition_parameter> args)
        : base_impl<negated_exists_condition>(std::move(args))
    {}

protected:
    [[nodiscard]] bool eval_impl(const unary_argument<object_view> &input, condition_cache &cache,
        const object_set_ref &objects_excluded, ddwaf::timer & /*deadline*/) const;

    friend class base_impl<negated_exists_condition>;
};

} // namespace ddwaf