Skip to content

Fix ISO Control Numbers Being Interpreted as Float#779

Open
DEMOCODE675 wants to merge 1 commit intoOWASP:mainfrom
DEMOCODE675:fix/ISO-control
Open

Fix ISO Control Numbers Being Interpreted as Float#779
DEMOCODE675 wants to merge 1 commit intoOWASP:mainfrom
DEMOCODE675:fix/ISO-control

Conversation

@DEMOCODE675
Copy link

Fixes #546

Summary

This PR fixes a recurring issue where ISO control identifiers such as "7.10" were incorrectly interpreted as numeric values and converted to floats (7.10 → 7.1).
Section identifiers are structural strings, not numeric values. Converting them to floats removes trailing zeros and collapses distinct identifiers:
"7.10" ≠ "7.1"
"8.10" ≠ "8.1"

This PR ensures section IDs are treated as strings across all architectural boundaries and adds regression tests to prevent this issue from reoccurring(locally).

What This PR Changes

  1. Fix numericise_ignore Off-by-One
    Updated:
    range(1, wsh.col_count + 1)

  2. Enforce String Type at All Boundaries

  • In parse_export_format, explicitly cast:
    sectionID = str(sectionID)

In Standard.__post_init__
In Tool.__post_init__
Normalize:
self.sectionID = str(self.sectionID) if self.sectionID is not None else ""

  1. Added Regression Tests
    New test file:
    section_id_string_test.py

Covers:

  • YAML round-trip preservation
  • Model invariants
  • Parser string enforcement
  • Natural sorting behavior
  • numericise_ignore off-by-one fix

Test Results
All relevant test suites were run locally:
36/36 tests passing
The new tests explicitly cover the exact failure modes described in issue #546 .

Why This Approach

Rather than fixing only the spreadsheet.py behavior, this PR:

  • Fixes the root cause
  • Adds defensive programming at architectural boundaries
  • Introduces regression tests
  • Protects against silent reintroduction of float coercion
    This ensures long-term stability and correctness of ISO control identifiers.

Result

  • "7.10" remains "7.10"
  • "7.1" remains "7.1"
  • No numeric coercion
  • No identifier collapsing
  • Regression tests prevent recurrence

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ISO control numbers interpreted wrongfully

1 participant