From f478258e480884fa780dd6b58de2dfca4e7839b1 Mon Sep 17 00:00:00 2001 From: Daniel Bloom <82895745+Daniel-Bloom-dfinity@users.noreply.github.com> Date: Sat, 26 Feb 2022 22:59:47 -0800 Subject: [PATCH] feat: add feature to skip body verifiction (#21) For now we want to skip body verification. --- .github/workflows/release.yml | 7 ++++--- Cargo.toml | 3 +++ src/main.rs | 3 ++- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 9308fe5..3421aa1 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,6 +1,7 @@ name: Release on: + workflow_dispatch: push: branches: - main @@ -55,14 +56,14 @@ jobs: cargo install cargo-deb --target x86_64-unknown-linux-musl echo "1.55.0" >./rust-toolchain rustup target add x86_64-unknown-linux-musl - RUSTFLAGS="--remap-path-prefix=${GITHUB_WORKSPACE}=/builds/dfinity" cargo deb --target x86_64-unknown-linux-musl -- --locked + RUSTFLAGS="--remap-path-prefix=${GITHUB_WORKSPACE}=/builds/dfinity" cargo deb --target x86_64-unknown-linux-musl -- --locked --features=skip_body_verification if: contains(matrix.target, 'linux-musl') - name: Linux build (gnu) env: RUSTFLAGS: --remap-path-prefix=${GITHUB_WORKSPACE}=/builds/dfinity run: | - cargo build --locked --release --target x86_64-unknown-linux-gnu + cargo build --locked --release --target x86_64-unknown-linux-gnu --features=skip_body_verification cd ${{ matrix.binary_path }} ldd icx-proxy if: contains(matrix.target, 'linux-gnu') @@ -71,7 +72,7 @@ jobs: env: RUSTFLAGS: --remap-path-prefix=${GITHUB_WORKSPACE}=/builds/dfinity run: | - cargo build --locked --release + cargo build --locked --release --features=skip_body_verification cd target/release otool -L icx-proxy if: contains(matrix.os, 'macos') diff --git a/Cargo.toml b/Cargo.toml index a8559ec..3d0dab1 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -37,3 +37,6 @@ slog = { version = "2.7.0", features = ["max_level_trace"] } slog-async = "2.7.0" slog-term = "2.8.0" url = "2.2.1" + +[features] +skip_body_verification = [] \ No newline at end of file diff --git a/src/main.rs b/src/main.rs index c06ddb8..ec46be6 100644 --- a/src/main.rs +++ b/src/main.rs @@ -422,7 +422,8 @@ async fn forward_request( // Canisters don't have to provide certified variables (None, None) => true, }; - if !body_valid { + + if !body_valid && !cfg!(feature = "skip_body_verification") { return Ok(Response::builder() .status(StatusCode::INTERNAL_SERVER_ERROR) .body("Body does not pass verification".into())