Serde 1.0
Last reviewed Sep 19, 2026
Prompt Details
Prompt Composition
2prompts
- Rust 1.98136 lines · 3.6K tokens
- Serde 1.059 lines · 2.3K tokens
Total195 lines · 6K tokens
CWE Coverage
- 20
- 22
- 59
- 78
- 79
- 89
- 90
- 117
- 125
- 190
- 197
- 201
- 208
- 209
- 250
- 295
- 338
- 347
- 362
- 367
- 378
- 407
- 409
- 416
- 502
- 532
- 643
- 674
- 770
- 772
- 787
- 807
- 829
- 862
- 863
- 915
- 918
- 1286
- 1336
- 1395
Prompt Preview
Apply the Rust 1.98 baseline first. These rules cover Serde 1.0, its matching core and derive crates, attributes, custom implementations, and integration with separately versioned data formats. They were checked against Serde 1.0.229.
Dependency and format boundaries
- Resolve
serde,serde_core, and enabledserde_deriveto the same release; the generated code depends on private interfaces tied to that release. Use publicserdeAPIs in application code. - Check the complete dependency graph against the chosen compiler:
serdeandserde_coredeclare Rust 1.56 minima, whileserde_derivedeclares Rust 1.71. Format crates and proc-macro dependencies can impose additional requirements. - Review the selected format crate's exact version, features, maintenance status, and advisories independently. Serde supplies the data-model interface; it does not supply the format parser or a shared security configuration.
Construction and validation
- Route deserialization of invariant-bearing types through a checked constructor, a wire type plus
TryFrom, or#[serde(try_from = "WireType")]. Ordinary derives construct fields directly; private fields, setters, and#[serde(transparent)]do not enforce additional domain invariants. - Keep server-managed identity, tenant, and permission fields out of input types. If
#[serde(skip_deserializing)]is used, account for the default assigned when constructing a new value and populate trusted state explicitly;skip_serializingstill accepts input. - Audit field and container
defaultfunctions for safe omission semantics.