Skip to content

sector-textile: fibre composition sum-check bypasses the real per-entry validator; whitespace passes as justification #33

Description

@LKSNDRTMLKV

Static read-through audit of plugins/sector-textile — the first design-partner pilot sector. Three verified findings.

1. Fibre-sum check bypasses the richer per-fibre validator

Location: src/fibre_composition.rs:20-32
Issue: fibre_sum_ok reimplements only the sum check and drops non-numeric/missing pct entries via filter_map instead of failing on them — bypassing dpp_rules::textiles::fibre::validate_fibre_composition, which enforces each fibre's pct is finite and in [0,100].
Failure scenario: [{"fibre":"cotton","pct":150.0},{"fibre":"wool","pct":-50.0}] sums to 100 and is marked Compliant despite neither percentage being physically valid. [{"fibre":"cotton"},{"fibre":"wool","pct":100.0}] (one entry missing pct entirely) is silently reduced to [100.0] and marked Compliant — an incomplete declaration passes as complete.

2. Three metric fields have zero range validation

Location: src/lib.rs:78-83
Issue: Unlike every sibling plugin (electronics, construction, furniture, aluminium, tyre all validate their equivalent field), the fibre-branch validate_input never calls optional_pct/require_pct on recycledContentPct, nor bounds-checks carbonFootprintKgCo2e or repairScore.
Failure scenario: "recycledContentPct": -9999 or 1e9 is accepted and published as a compliance metric with no range check at all.

3. Whitespace-only string satisfies the justification length gate

Location: src/unsold_goods.rs:19
Issue: justification.len() < 10 counts raw bytes without trimming, unlike Validator::require_str used elsewhere in this same crate.
Failure scenario: destination: "exempt_destruction" with destructionJustification: " " (10 spaces) yields Compliant with detail "exempt destruction with valid justification" despite no substantive justification being provided.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingcomplianceRegulatory/compliance correctness issue

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions