Skip to content

Commit

Permalink
style: whitelisted_wasms.txt no longer looks like .json5 file
Browse files Browse the repository at this point in the history
  • Loading branch information
Marcin Nowak-Liebiediew committed Aug 10, 2023
1 parent 2c02e85 commit c913d7a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
11 changes: 9 additions & 2 deletions service/wasm-utils/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,10 @@ struct Config {
#[ic_cdk::query]
fn is_whitelisted(wasm: ByteBuf) -> ByteBuf {
let wasm_hash = hex::encode(sha2::Sha256::digest(&wasm));
let white_list = include!("whitelisted_wasms.txt");
let white_list = include_str!("whitelisted_wasms.txt")
.lines()
.filter_map(|line| line.split_whitespace().next())
.collect::<Vec<_>>();
if white_list.contains(&wasm_hash.as_str()) {
wasm
} else {
Expand All @@ -40,7 +43,11 @@ fn transform(wasm: ByteBuf, config: Config) -> ByteBuf {

#[test]
fn test_parsing_whitelisted_wasms_txt() {
let white_list = include!("whitelisted_wasms.txt");
let white_list = include_str!("whitelisted_wasms.txt")
.lines()
.filter_map(|line| line.split_whitespace().next())
.collect::<Vec<_>>();
dbg!(&white_list);
let hash = "88d1e5795d29debc1ff56fa0696dcb3adfa67f82fe2739d1aa644263838174b9";
assert!(white_list.contains(&hash));
}
4 changes: 1 addition & 3 deletions service/wasm-utils/whitelisted_wasms.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
[
"88d1e5795d29debc1ff56fa0696dcb3adfa67f82fe2739d1aa644263838174b9", // dfx 0.15.0 frontend canister
]
88d1e5795d29debc1ff56fa0696dcb3adfa67f82fe2739d1aa644263838174b9 dfx 0.15.0 frontend canister

0 comments on commit c913d7a

Please sign in to comment.