refactor: narrow test harness compatibility surfaces (#3592)

This commit is contained in:
安正超
2026-06-19 07:10:52 +08:00
committed by GitHub
parent b14e49e84e
commit b1c6578df1
27 changed files with 384 additions and 105 deletions
+1
View File
@@ -8758,6 +8758,7 @@ name = "rustfs-storage-api"
version = "1.0.0-beta.8"
dependencies = [
"async-trait",
"rustfs-filemeta",
"serde",
"time",
"uuid",
+13 -3
View File
@@ -1,9 +1,12 @@
#![no_main]
#[path = "bucket_validation/storage_compat.rs"]
mod storage_compat;
use libfuzzer_sys::fuzz_target;
use crate::storage_compat::ecstore::bucket::utils::{check_bucket_and_object_names, check_list_objs_args, check_valid_bucket_name_strict};
use crate::storage_compat::ecstore::bucket::utils::{
check_bucket_and_object_names, check_list_objs_args, check_valid_bucket_name_strict, is_meta_bucketname,
};
fn parse_case(data: &[u8]) -> (String, String) {
let text = String::from_utf8_lossy(data);
@@ -25,6 +28,7 @@ fuzz_target!(|data: &[u8]| {
let (bucket, object) = parse_case(data);
let strict_bucket_ok = check_valid_bucket_name_strict(&bucket).is_ok();
let valid_bucket_for_object_ops = strict_bucket_ok || is_meta_bucketname(&bucket);
let pair_ok = check_bucket_and_object_names(&bucket, &object).is_ok();
let list_ok = check_list_objs_args(&bucket, &object, &None).is_ok();
@@ -48,10 +52,16 @@ fuzz_target!(|data: &[u8]| {
}
if pair_ok {
assert!(strict_bucket_ok, "accepted bucket/object pair must also satisfy strict bucket validation");
assert!(
valid_bucket_for_object_ops,
"accepted bucket/object pair must satisfy strict bucket validation or meta bucket compatibility"
);
}
if list_ok {
assert!(strict_bucket_ok, "accepted list-object args must also satisfy strict bucket validation");
assert!(
valid_bucket_for_object_ops,
"accepted list-object args must satisfy strict bucket validation or meta bucket compatibility"
);
}
});
@@ -0,0 +1,23 @@
// Copyright 2024 RustFS Team
//
// Licensed 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.
pub(crate) mod ecstore {
pub(crate) mod bucket {
pub(crate) mod utils {
pub(crate) use rustfs_ecstore::bucket::utils::{
check_bucket_and_object_names, check_list_objs_args, check_valid_bucket_name_strict, is_meta_bucketname,
};
}
}
}
+1
View File
@@ -1,5 +1,6 @@
#![no_main]
#[path = "path_containment/storage_compat.rs"]
mod storage_compat;
use libfuzzer_sys::fuzz_target;
@@ -13,5 +13,11 @@
// limitations under the License.
pub(crate) mod ecstore {
pub(crate) use rustfs_ecstore::bucket;
pub(crate) mod bucket {
pub(crate) mod utils {
pub(crate) use rustfs_ecstore::bucket::utils::{
check_object_name_for_length_and_slash, has_bad_path_component, is_valid_object_prefix,
};
}
}
}