Coverage Report

Created: 2026-05-27 07:00

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/proc/self/cwd/fuzz/fuzz_eval.cc
Line
Count
Source
1
/* Copyright 2026 Google LLC
2
3
Licensed under the Apache License, Version 2.0 (the "License");
4
you may not use this file except in compliance with the License.
5
You may obtain a copy of the License at
6
7
      http://www.apache.org/licenses/LICENSE-2.0
8
9
Unless required by applicable law or agreed to in writing, software
10
distributed under the License is distributed on an "AS IS" BASIS,
11
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
See the License for the specific language governing permissions and
13
limitations under the License.
14
*/
15
16
#include <string>
17
18
#include "parser/options.h"
19
#include "parser/parser.h"
20
#include "eval/public/cel_expression.h"
21
#include "eval/public/cel_expr_builder_factory.h"
22
#include "eval/public/builtin_func_registrar.h"
23
#include "eval/public/activation.h"
24
25
14.5k
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
26
14.5k
    if (size > 1024) return 0;
27
14.5k
    std::string str (reinterpret_cast<const char*>(data), size);
28
    
29
14.5k
    auto builder = google::api::expr::runtime::CreateCelExpressionBuilder();
30
14.5k
    auto status = google::api::expr::runtime::RegisterBuiltinFunctions(builder->GetRegistry());
31
14.5k
    if (!status.ok()) {
32
0
        return 0;
33
0
    }
34
35
14.5k
    google::api::expr::parser::ParserOptions options;
36
14.5k
    options.max_recursion_depth = 128;
37
14.5k
    options.expression_size_codepoint_limit = 1 << 20;
38
39
14.5k
    try {
40
14.5k
        auto parse_status = google::api::expr::parser::Parse(str, "fuzzinput", options);
41
14.5k
        if (!parse_status.ok()) {
42
4.18k
            return 0;
43
4.18k
        }
44
45
10.3k
        auto expr_status = builder->CreateExpression(&parse_status->expr(), &parse_status->source_info());
46
10.3k
        if (expr_status.ok()) {
47
9.92k
            google::protobuf::Arena arena;
48
9.92k
            google::api::expr::runtime::Activation activation;
49
9.92k
            auto eval_status = (*expr_status)->Evaluate(activation, &arena);
50
9.92k
        }
51
10.3k
    } catch (const std::exception& e) {
52
0
        return 0;
53
0
    }
54
10.3k
    return 0;
55
14.5k
}