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

style: whitelisted_wasms.txt no longer looks like .json5 file #187

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading