Fix the BP-1 findings in the cultnet-rs content plane
A hostile manifest of empty chunks no longer becomes a request flood: fetch_content refuses a zero-size chunk beside other chunks, and settles the content hash and every chunk hash (normalised, non-empty) before the first request. Every bad chunk request is now answered found:false in the reference handler's validation order, never refused at decode. validate_message no longer refuses content chunk requests or responses, so a blank message id or hash, a prefix-only hash and a negative size reach answer_content_chunk_request. The answer follows the reference's double normalisation (handler, then CreateRecordKey), which fixes the prefix-only hash spelling to ArgumentException on 'chunkHash'. The cs vectors gain nine reference-server answers (blank and whitespace id, blank, whitespace and prefix-only hash, negative size, record-key case, blank record key, double prefix) and a metadata-order manifest; Rust answers all of them byte-identically. Manifest metadata is Vec<(String, String)> in wire order and refuses a duplicate key, replacing the BTreeMap that re-sorted keys. Tests pin the surviving mutants: unusable chunk sizes, the payload-length and claimed-size halves of the chunk check, stable sort at equal offsets, the normalised hash and canonical key actually sent, and the kind/mime defaults never trimming. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
parent
8a66b1d230
commit
16432d4b1e
6 changed files with 551 additions and 70 deletions
|
|
@ -164,6 +164,16 @@ public sealed class CultMeshContentVectorTests
|
|||
AddAnswer("answer_not_found", Request("vector-missing", new string('0', 64), string.Empty, 100));
|
||||
AddAnswer("answer_record_key_disagrees", Request("vector-key", last.ChunkHash, "mesh:cdn:chunk:other", last.SizeBytes));
|
||||
AddAnswer("answer_size_mismatch", Request("vector-size", last.ChunkHash, key, last.SizeBytes - 1));
|
||||
// Requests the reference refuses in its handler, never at deserialisation: each is answered.
|
||||
AddAnswer("answer_blank_message_id", Request(string.Empty, last.ChunkHash, key, last.SizeBytes));
|
||||
AddAnswer("answer_whitespace_message_id", Request(" ", last.ChunkHash, key, last.SizeBytes));
|
||||
AddAnswer("answer_blank_hash", Request("vector-blank-hash", string.Empty, string.Empty, 100));
|
||||
AddAnswer("answer_whitespace_hash", Request("vector-space-hash", " ", string.Empty, 100));
|
||||
AddAnswer("answer_prefix_only_hash", Request("vector-prefix-hash", "sha256: ", string.Empty, 100));
|
||||
AddAnswer("answer_negative_size", Request("vector-negative", last.ChunkHash, key, -1));
|
||||
AddAnswer("answer_record_key_case", Request("vector-key-case", last.ChunkHash, key.ToUpperInvariant(), last.SizeBytes));
|
||||
AddAnswer("answer_blank_record_key", Request("vector-key-blank", last.ChunkHash, " ", last.SizeBytes));
|
||||
AddAnswer("answer_double_prefix", Request("vector-double", "sha256:sha256:" + last.ChunkHash, string.Empty, last.SizeBytes));
|
||||
AddResponse("response_hash_last_digit", new CultMeshContentChunkResponseMessage
|
||||
{
|
||||
MessageId = "vector-digit",
|
||||
|
|
@ -184,6 +194,9 @@ public sealed class CultMeshContentVectorTests
|
|||
var shuffled = CultMeshCdn.PackArtifact(ArtifactId, Body(), Options()).Manifest;
|
||||
shuffled.Chunks = new[] { 3, 0, 5, 1, 4, 2 }.Select(i => shuffled.Chunks[i]).ToArray();
|
||||
AddManifest("manifest_out_of_order", shuffled);
|
||||
var tagged = CultMeshCdn.PackArtifact(ArtifactId, Body(), Options()).Manifest;
|
||||
tagged.Metadata = new Dictionary<string, string> { ["zeta"] = "1", ["alpha"] = "2", ["mid"] = "3" };
|
||||
AddManifest("manifest_metadata_order", tagged);
|
||||
AddManifest("manifest_empty_body", CultMeshCdn.PackArtifact(ArtifactId, Array.Empty<byte>(), Options()).Manifest);
|
||||
return vectors;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue