From c913d7a92c437ea12bdefd62b1f4a476969c7590 Mon Sep 17 00:00:00 2001 From: Marcin Nowak-Liebiediew Date: Thu, 10 Aug 2023 17:24:02 +0200 Subject: [PATCH] style: `whitelisted_wasms.txt` no longer looks like `.json5` file --- service/wasm-utils/lib.rs | 11 +++++++++-- service/wasm-utils/whitelisted_wasms.txt | 4 +--- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/service/wasm-utils/lib.rs b/service/wasm-utils/lib.rs index 2d257f46..2d208201 100644 --- a/service/wasm-utils/lib.rs +++ b/service/wasm-utils/lib.rs @@ -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::>(); if white_list.contains(&wasm_hash.as_str()) { wasm } else { @@ -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::>(); + dbg!(&white_list); let hash = "88d1e5795d29debc1ff56fa0696dcb3adfa67f82fe2739d1aa644263838174b9"; assert!(white_list.contains(&hash)); } diff --git a/service/wasm-utils/whitelisted_wasms.txt b/service/wasm-utils/whitelisted_wasms.txt index 2373d3ca..c29ffa05 100644 --- a/service/wasm-utils/whitelisted_wasms.txt +++ b/service/wasm-utils/whitelisted_wasms.txt @@ -1,3 +1 @@ -[ - "88d1e5795d29debc1ff56fa0696dcb3adfa67f82fe2739d1aa644263838174b9", // dfx 0.15.0 frontend canister -] +88d1e5795d29debc1ff56fa0696dcb3adfa67f82fe2739d1aa644263838174b9 dfx 0.15.0 frontend canister