Repository navigation
Follow-ups from the audits of the crate and the false-positive PRs - #306
Merged
Merged
Conversation
Non-blocking findings of audit-pywhat-rs-crate-b and audit-pywhat-rs-fp-b: * Top::of computes percentages as Python does: Decimal rounds total × percent to 28 significant digits (half to even), then the division by 100 and the ceiling are exact. It no longer overflows u128 for large totals (50.000000000000000000% of usize::MAX), and it no longer panics on a Top::Percent that parse() wouldn't return. parse() strips Python's whitespace, including U+001C to U+001F. Differential against Python's Top.of: 0 differences in 119,016 (percentage, total) pairs. * validators::facebook_access_token skips the first two characters, not two bytes, as Python's token[2:] does (they differed on non-ASCII input). * Examples that test both languages on Unicode: a CashAddr with a Kelvin sign (invalid) and a Visa number with ideographic spaces (valid). * The golden test: a new option set "and_exclude" catches Filter::and excluding the wrong tags (13 differences with that change), and scripts/golden.py ends both recordings with their counts, so a cut recording or missing JSON records fail. * Area pull requests don't conflict in the two shared lists: regexes that need fancy-regex, or whose Charset Only tag is decided by hand, go into their area's block (AREAS_NOT_ON_THE_REGEX_CRATE in tests/examples.rs, AREAS_BY_HAND in tests/charset_only.rs), compared by name. The contract says so, and that validators add no crates without the maintainers' agreement. * Stale text: CONTRIBUTING.md starts with the contract, the golden test's commands, "regex.json" where a regex can be in an area file, the Charset Only lengths, the 14 files of Ciphey that import lemmeknow, and the size of the big-file JSON (296,955,554 bytes).
Owner
Author
|
Rebased onto main (0c78b02, with #303 and #304) without conflicts: the head is now e702a9c. The range-diff against the audited head is empty: MERGE_OK of audit-pywhat-rs-followups (at a0d89ef) carries over. The local CI mirror passes on this head (now on the Rust engine: pytest 2,276 passed, 156 skipped). |
bee-san
force-pushed
the
pywhat-rs-followups
branch
from
November 5, 2026 00:41
a0d89ef to
e702a9c
Compare
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



The non-blocking findings of the audits of #299 (the crate) and #300 (false positives), fixed. This PR is stacked on #303: only the last commit, a0d89ef, is new here.
Changes
Top::ofcomputes percentages the way Python does (crate audit F10).Decimalrounds total × percent to 28 significant digits (half to even), then divides by 100 and takes the ceiling, both exactly. The Rust code now does the same, with integer arithmetic.50.000000000000000000%ofusize::MAXoverflowedu128.Top::Percentthatparse()wouldn't return.parse()strips whitespace like Python'sstr.strip()and\s, which include U+001C to U+001F.Top.ofgives 0 differences in 119,016 (percentage, total) pairs, over 6,018 generated and adversarial percentages and 24 totals up to 2^64−1.parse()agrees on all 6,018.validators::facebook_access_tokenin Rust skips two characters, not two bytes, as Python'stoken[2:]does (FP audit F15). The two versions differed on non-ASCII input. Both test suites now test the same cases.K, as an invalid Bitcoin Cash example;4111 1111 1111 1111with ideographic spaces, as a valid Visa example.and_exclude, catchesFilter::andexcluding the wrong tags. Replacing its intersection of the excluded tags with a union gives13 differences {"and_exclude": 13}.scripts/golden.pyends both recordings with their counts. A cut recording, or one without its JSON records, now fails (checked:has no trailer: cut off?).AREAS_NOT_ON_THE_REGEX_CRATEintests/examples.rs. A regex whoseCharset Onlytag is decided by hand goes into its area's block ofAREAS_BY_HANDintests/charset_only.rs. Both lists are compared by name, so an entry's place doesn't depend on its rarity. The contract says so, and also that validators add no crates without the maintainers' agreement, since two areas that each add one would conflict inCargo.tomlandCargo.lock.Charset Onlylengths correctly.grep -rl 'lemmeknow::' src);detection.rschanges in step 6.Checks
noxon Python 3.10, thencargo fmt, clippy with default features, none,childrenandwasm, andcargo testwith default features, none andchildren. It passes: pytest 2,410 passed, 6 skipped.golden: 43454 texts, 143531 comparisons, 0 differences {}, 30 documented Unicode differences,golden files: 16 cases, 0 differences.