[codex] Address high CodeQL findings#1612
Merged
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
This PR addresses high-severity CodeQL findings by removing potentially backtracking regex patterns in ABI/type validation utilities and replacing them with deterministic string parsing, plus adding regression tests for the flagged inputs.
Changes:
- Replace regex-based tuple, named-tuple, fixed-array, and Starknet ID domain checks with deterministic string parsing.
- Use
replaceAll('*', '')when normalizing Cairo 0 array element types (calldata + response parsing). - Add focused unit/regression tests covering previously flagged backtracking-style inputs and nested fixed-array types.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| src/utils/starknetId.ts | Replaces regex-based .stark domain validation with deterministic label parsing. |
| src/utils/calldata/responseParser.ts | Normalizes Cairo 0 array element types using replaceAll when parsing responses. |
| src/utils/calldata/cairo.ts | Replaces tuple/named-tuple regex checks and strips all * in getArrayType. |
| src/utils/cairoDataTypes/fixedArray.ts | Adds deterministic fixed-array type parsing and reuses it across helpers. |
| tests/utils/starknetId.test.ts | Adds regression tests for deterministic Starknet ID domain validation. |
| tests/utils/calldata/cairo.test.ts | Adds regression tests for tuple/named-tuple checks and multi-* array types. |
| tests/utils/cairoDataTypes/CairoFixedArray.test.ts | Adds regression tests for nested fixed-array types and pathological inputs. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+422
to
+430
| return name.split('.').every((label) => { | ||
| return ( | ||
| label.length > 0 && | ||
| label.length <= 48 && | ||
| [...label].every((char) => { | ||
| return (char >= 'a' && char <= 'z') || (char >= '0' && char <= '9') || char === '-'; | ||
| }) | ||
| ); | ||
| }); |
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.
Summary
*removal withreplaceAllin calldata array type handlingValidation
npm run lintnpm run ts:checknpx jest -i --config "{\"transform\":{\"^.+\\\\.(t|j)sx?$\":\"@swc/jest\"},\"testMatch\":[\"**/__tests__/**/(*.)+(spec|test).[jt]s?(x)\"]}" __tests__/utils/calldata/cairo.test.ts __tests__/utils/cairoDataTypes/CairoFixedArray.test.ts __tests__/utils/starknetId.test.tsNote: the repo default Jest config requires a local Starknet devnet, so the focused unit test command bypasses global setup for these pure utility tests.