-
Notifications
You must be signed in to change notification settings - Fork 1.1k
crypto: lazy_static removed, light parser for address URI added
#2250
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
Merged
Merged
Changes from 23 commits
Commits
Show all changes
32 commits
Select commit
Hold shift + click to select a range
5b233fc
crypto: lazy_static removed, light parser added
michalkucharczyk 3ab3733
fuzzer added
michalkucharczyk 7e6bdb3
fix
michalkucharczyk f92f50f
cleanup
michalkucharczyk 1a52c98
license added
michalkucharczyk b0167c3
std gate added
michalkucharczyk b6dbf0d
address uri moved to src/
michalkucharczyk eaf5de0
Apply suggestions from code review
michalkucharczyk 047eb83
parsing error added
michalkucharczyk b33de54
fix
michalkucharczyk ee7f179
Merge remote-tracking branch 'origin/master' into mku-crypto-address-…
michalkucharczyk a3b9ded
Update substrate/primitives/core/src/address_uri.rs
michalkucharczyk 3aad2c5
Update substrate/primitives/core/src/address_uri.rs
michalkucharczyk d556091
review suggestions
michalkucharczyk 40486a6
fuzzer fixed
michalkucharczyk 77ad7f1
review suggestion
michalkucharczyk 93bc851
naming
michalkucharczyk 33dd1f3
missed review suggesions + fixes
michalkucharczyk 0476638
Update substrate/primitives/core/src/address_uri.rs
michalkucharczyk 0dddd34
fix
michalkucharczyk 2500fe0
Merge remote-tracking branch 'origin/master' into mku-crypto-address-…
michalkucharczyk 52f8aa2
Merge branch 'master' into mku-crypto-address-uri-parser
michalkucharczyk abff740
".git/.scripts/commands/update-ui/update-ui.sh"
b2bb315
test-pallet-ui: trybuild-overwrite
michalkucharczyk 13582d3
Merge branch 'master' into mku-crypto-address-uri-parser
michalkucharczyk 9fa5ff8
better error communication
michalkucharczyk 80532e7
fuzzer added to workspace
michalkucharczyk 69d7c7f
fix
michalkucharczyk ad71461
fix
michalkucharczyk ab059c3
fix indexing to be 0-based
michalkucharczyk f6c7bfd
Merge branch 'master' into mku-crypto-address-uri-parser
michalkucharczyk 06dd2fd
Merge branch 'master' into mku-crypto-address-uri-parser
michalkucharczyk File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| [package] | ||
| name = "sp-core-fuzz" | ||
| version = "0.0.0" | ||
| publish = false | ||
|
|
||
| [package.metadata] | ||
| cargo-fuzz = true | ||
|
|
||
| [dependencies] | ||
| lazy_static = "1.4.0" | ||
| libfuzzer-sys = "0.4" | ||
| regex = "1.10.2" | ||
|
|
||
| sp-core = { path = ".." } | ||
|
|
||
| # Prevent this from interfering with workspaces | ||
| [workspace] | ||
| members = ["."] | ||
|
|
||
| [profile.release] | ||
| debug = 1 | ||
|
|
||
| [[bin]] | ||
| name = "fuzz_address_uri" | ||
| path = "fuzz_targets/fuzz_address_uri.rs" | ||
| test = false | ||
| doc = false | ||
50 changes: 50 additions & 0 deletions
50
substrate/primitives/core/fuzz/fuzz_targets/fuzz_address_uri.rs
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,50 @@ | ||
| // This file is part of Substrate. | ||
|
|
||
| // Copyright (C) Parity Technologies (UK) Ltd. | ||
| // SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| // Licensed under the Apache License, Version 2.0 (the "License"); | ||
| // you may not use this file except in compliance with the License. | ||
| // You may obtain a copy of the License at | ||
| // | ||
| // http://www.apache.org/licenses/LICENSE-2.0 | ||
| // | ||
| // Unless required by applicable law or agreed to in writing, software | ||
| // distributed under the License is distributed on an "AS IS" BASIS, | ||
| // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| // See the License for the specific language governing permissions and | ||
| // limitations under the License. | ||
|
|
||
| #![no_main] | ||
|
|
||
| extern crate libfuzzer_sys; | ||
| extern crate regex; | ||
| extern crate sp_core; | ||
|
|
||
| use libfuzzer_sys::fuzz_target; | ||
| use regex::Regex; | ||
| use sp_core::crypto::AddressUri; | ||
|
|
||
| lazy_static::lazy_static! { | ||
| static ref SECRET_PHRASE_REGEX: Regex = Regex::new(r"^(?P<phrase>[a-zA-Z0-9 ]+)?(?P<path>(//?[^/]+)*)(///(?P<password>.*))?$") | ||
| .expect("constructed from known-good static value; qed"); | ||
| } | ||
|
|
||
| fuzz_target!(|input: &str| { | ||
| let regex_result = SECRET_PHRASE_REGEX.captures(input); | ||
| let manual_result = AddressUri::parse(input); | ||
| assert_eq!(regex_result.is_some(), manual_result.is_ok()); | ||
| if let (Some(regex_result), Ok(manual_result)) = (regex_result, manual_result) { | ||
| assert_eq!(regex_result.name("phrase").map(|p| p.as_str()), manual_result.phrase); | ||
|
|
||
| let manual_paths = manual_result | ||
| .paths | ||
| .iter() | ||
| .map(|s| "/".to_string() + s) | ||
| .collect::<Vec<_>>() | ||
| .join(""); | ||
|
|
||
| assert_eq!(regex_result.name("path").unwrap().as_str().to_string(), manual_paths); | ||
| assert_eq!(regex_result.name("password").map(|pass| pass.as_str()), manual_result.pass); | ||
| } | ||
| }); |
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.