Skip to content

Commit da2a8b0

Browse files
committed
feat(proxy): emit warning when proxy build-time and runtime versions of EQL differ
1. mise.toml downloads the EQL version specified in `CS_EQL_VERSION` 2. `cipherstash-proxy` now has a `build.rs` file that reads `CS_EQL_VERSION` at compile time. 3. The env var is consumed (at compile time) in `cipherstash-proxy`'s `main.rs` and stored in a constant 4. When `Encrypt` is initialised the version from the database is compared with the version from compile time and a `warn!(..)` is issued when they differ.
1 parent 964873f commit da2a8b0

File tree

3 files changed

+20
-0
lines changed

3 files changed

+20
-0
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ rust-toolchain.toml
1414
# release artifacts
1515
/cipherstash-proxy
1616
/cipherstash-eql.sql
17+
/packages/cipherstash-proxy/eql-version-at-build-time.txt
1718

1819
# credentials for local dev
1920
.env.proxy.docker
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
use std::env;
2+
3+
fn main() {
4+
if let Ok(eql_version) = env::var("CS_EQL_VERSION") {
5+
println!(
6+
"cargo:rustc-env=EQL_VERSION_AT_BUILD_TIME={}",
7+
eql_version.trim()
8+
);
9+
}
10+
}

packages/cipherstash-proxy/src/main.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ use tokio::signal::unix::{signal, SignalKind};
1111
use tokio_util::task::TaskTracker;
1212
use tracing::{error, info, warn};
1313

14+
const EQL_VERSION_AT_BUILD_TIME: Option<&'static str> = option_env!("EQL_VERSION_AT_BUILD_TIME");
15+
1416
fn main() -> Result<(), Box<dyn std::error::Error>> {
1517
let args = Args::parse();
1618

@@ -219,6 +221,13 @@ async fn init(mut config: TandemConfig) -> Encrypt {
219221
username = encrypt.config.database.username,
220222
eql_version = encrypt.eql_version,
221223
);
224+
if encrypt.eql_version.as_deref() != EQL_VERSION_AT_BUILD_TIME {
225+
warn!(
226+
msg = "installed version of EQL is different to the version that Proxy was built with",
227+
eql_build_version = EQL_VERSION_AT_BUILD_TIME,
228+
eql_installed_version = encrypt.eql_version,
229+
);
230+
}
222231
encrypt
223232
}
224233
Err(err) => {

0 commit comments

Comments
 (0)