Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improved unicode support in mutator, flattener, and more #2662

Open
wants to merge 15 commits into
base: dev
Choose a base branch
from

Conversation

bohendo
Copy link
Contributor

@bohendo bohendo commented Feb 7, 2025

solc, foundry, hardhat, everything reports source_map offsets denominated in bytes (solidity#14733 is a false positive). And (almost) all slither detectors/properly properly index the source code byte-wise. Great.

But some tools, notably the mutator and flattener, use per-byte offsets to index strings per-character. Once this PR is merged, they will not.

Summary of changes:

  • fixed source_mapping.content to index source code correctly and used this property instead of manual indexing in flat/mutate tools
  • fixed src_mapping usage in the documentation tool too
  • small bugfix to Makefile
  • manual review of all other src_mapping, source_code, and utf8 encodings to ensure we aren't applying byte-offsets to strings anywhere else
    • resolved subtle unicode bugs in the unused_import, upgradability and codex detectors.
    • standardize encoding strings from a mixture of "utf-8" and "utf8" to just the latter
  • try/catch mutant generation, so one bugged mutator won't crash the entire campaign (and it'll print more helpful logs now)
  • more tweaks to mutation logging (eg uncaught mutants use white text so the above errors stand out better)
  • bug fixes to a few mutators that eg crashed on assembly instructions

Note that the last 3 of these were merged into this branch from PR#2648 bc most of the changes in that PR would have needed to be duplicated in this one.

@bohendo bohendo mentioned this pull request Feb 7, 2025
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.

1 participant