/src/ztunnel/fuzz/fuzz_targets/protobuf.rs
Line | Count | Source |
1 | | // Copyright Istio Authors |
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 | | #![no_main] |
16 | | |
17 | | use libfuzzer_sys::fuzz_target; |
18 | | use prost::Message; |
19 | | use ztunnel::rbac::Authorization; |
20 | | use ztunnel::state::workload::Workload; |
21 | | use ztunnel::xds::istio::security::Authorization as XdsAuthorization; |
22 | | use ztunnel::xds::istio::workload::Workload as XdsWorkload; |
23 | | |
24 | | fuzz_target!(|data: &[u8]| { |
25 | | let _ = run_workload(data); |
26 | | let _ = run_rbac(data); |
27 | | }); |
28 | | |
29 | 10.1k | fn run_workload(data: &[u8]) -> anyhow::Result<()> { |
30 | 10.1k | Workload::try_from(XdsWorkload::decode(data)?)?; |
31 | 937 | Ok(()) |
32 | 10.1k | } |
33 | | |
34 | 10.1k | fn run_rbac(data: &[u8]) -> anyhow::Result<()> { |
35 | 10.1k | Authorization::try_from(XdsAuthorization::decode(data)?)?; |
36 | 2.41k | Ok(()) |
37 | 10.1k | } |