-
Notifications
You must be signed in to change notification settings - Fork 48
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
implementing suggestions from Egis audit review (#960)
* refactor: index admin in AllowToHook event * feat: include dash in alphanumeric check * build: update precompiles * docs: update natspec * refactor: rename isAlphanumericWithSpaces to IsAllowedCharacter * test: fixes --------- Co-authored-by: Paul Razvan Berg <prberg@proton.me>
- Loading branch information
1 parent
4fada2a
commit 9eaac34
Showing
9 changed files
with
128 additions
and
121 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains 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
This file contains 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
104 changes: 104 additions & 0 deletions
104
test/integration/concrete/nft-descriptor/is-allowed-character/IsAllowedCharacter.t.sol
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
// SPDX-License-Identifier: UNLICENSED | ||
pragma solidity >=0.8.22 <0.9.0; | ||
|
||
import { NFTDescriptor_Integration_Shared_Test } from "../../../shared/nft-descriptor/NFTDescriptor.t.sol"; | ||
|
||
contract IsAllowedCharacter_Integration_Concrete_Test is NFTDescriptor_Integration_Shared_Test { | ||
function test_IsAllowedCharacter_EmptyString() external view { | ||
string memory symbol = ""; | ||
bool result = nftDescriptorMock.isAllowedCharacter_(symbol); | ||
assertTrue(result, "isAllowedCharacter"); | ||
} | ||
|
||
modifier whenNotEmptyString() { | ||
_; | ||
} | ||
|
||
function test_IsAllowedCharacter_ContainsUnsupportedCharacters() external view whenNotEmptyString { | ||
string memory symbol = "<foo/>"; | ||
bool result = nftDescriptorMock.isAllowedCharacter_(symbol); | ||
assertFalse(result, "isAllowedCharacter"); | ||
|
||
symbol = "foo/"; | ||
result = nftDescriptorMock.isAllowedCharacter_(symbol); | ||
assertFalse(result, "isAllowedCharacter"); | ||
|
||
symbol = "foo\\"; | ||
result = nftDescriptorMock.isAllowedCharacter_(symbol); | ||
assertFalse(result, "isAllowedCharacter"); | ||
symbol = "foo%"; | ||
result = nftDescriptorMock.isAllowedCharacter_(symbol); | ||
assertFalse(result, "isAllowedCharacter"); | ||
symbol = "foo&"; | ||
result = nftDescriptorMock.isAllowedCharacter_(symbol); | ||
assertFalse(result, "isAllowedCharacter"); | ||
symbol = "foo("; | ||
result = nftDescriptorMock.isAllowedCharacter_(symbol); | ||
assertFalse(result, "isAllowedCharacter"); | ||
symbol = "foo)"; | ||
result = nftDescriptorMock.isAllowedCharacter_(symbol); | ||
assertFalse(result, "isAllowedCharacter"); | ||
symbol = "foo\""; | ||
result = nftDescriptorMock.isAllowedCharacter_(symbol); | ||
assertFalse(result, "isAllowedCharacter"); | ||
symbol = "foo'"; | ||
result = nftDescriptorMock.isAllowedCharacter_(symbol); | ||
assertFalse(result, "isAllowedCharacter"); | ||
symbol = "foo`"; | ||
result = nftDescriptorMock.isAllowedCharacter_(symbol); | ||
assertFalse(result, "isAllowedCharacter"); | ||
symbol = "foo;"; | ||
result = nftDescriptorMock.isAllowedCharacter_(symbol); | ||
assertFalse(result, "isAllowedCharacter"); | ||
symbol = "foo%20"; // URL-encoded empty space | ||
result = nftDescriptorMock.isAllowedCharacter_(symbol); | ||
assertFalse(result, "isAllowedCharacter"); | ||
} | ||
modifier whenOnlySupportedCharacters() { | ||
_; | ||
} | ||
function test_IsAllowedCharacter() external view whenNotEmptyString whenOnlySupportedCharacters { | ||
string memory symbol = "foo"; | ||
bool result = nftDescriptorMock.isAllowedCharacter_(symbol); | ||
assertTrue(result, "isAllowedCharacter"); | ||
symbol = "Foo"; | ||
result = nftDescriptorMock.isAllowedCharacter_(symbol); | ||
assertTrue(result, "isAllowedCharacter"); | ||
symbol = "Foo "; | ||
result = nftDescriptorMock.isAllowedCharacter_(symbol); | ||
assertTrue(result, "isAllowedCharacter"); | ||
symbol = "Foo Bar"; | ||
result = nftDescriptorMock.isAllowedCharacter_(symbol); | ||
assertTrue(result, "isAllowedCharacter"); | ||
symbol = "Bar-Foo"; | ||
result = nftDescriptorMock.isAllowedCharacter_(symbol); | ||
assertTrue(result, "isAllowedCharacter"); | ||
symbol = " "; | ||
result = nftDescriptorMock.isAllowedCharacter_(symbol); | ||
assertTrue(result, "isAllowedCharacter"); | ||
symbol = "foo01234"; | ||
result = nftDescriptorMock.isAllowedCharacter_(symbol); | ||
assertTrue(result, "isAllowedCharacter"); | ||
symbol = "123456789"; | ||
result = nftDescriptorMock.isAllowedCharacter_(symbol); | ||
assertTrue(result, "isAllowedCharacter"); | ||
} | ||
} |
2 changes: 1 addition & 1 deletion
2
...with-spaces/isAlphanumericWithSpaces.tree → ...allowed-character/IsAllowedCharacter.tree
This file contains 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
100 changes: 0 additions & 100 deletions
100
...ration/concrete/nft-descriptor/is-alphanumeric-with-spaces/isAlphanumericWithSpaces.t.sol
This file was deleted.
Oops, something went wrong.
This file contains 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
This file contains 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
This file contains 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