Skip to content

Commit

Permalink
Added regex assertion for station_id
Browse files Browse the repository at this point in the history
  • Loading branch information
PatrickNercessian committed May 2, 2024
1 parent 12fe9b8 commit 6620505
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
1 change: 1 addition & 0 deletions daemon/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ atomicwrites = "0.4.3"
clap = { version = "4.5.4", features = ["derive", "env"] }
env_logger.workspace = true
log.workspace = true
regex = "1.10.4"
serde.workspace = true
serde_json = "1.0.116"
tokio = { workspace = true }
Expand Down
5 changes: 5 additions & 0 deletions daemon/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ use std::time::Duration;

use args::CliArgs;
use clap::Parser;
use regex::Regex;

use zinnia_runtime::anyhow::{anyhow, Context, Error, Result};
use zinnia_runtime::{
Expand Down Expand Up @@ -87,6 +88,10 @@ async fn run(config: CliArgs) -> Result<RunOutput> {
rng_seed: None,
};

if !Regex::new(r"^[0-9a-fA-F]{88}$").unwrap().is_match(&runtime_config.station_id) {
return Err(anyhow!("Invalid station_id format"));
}

// TODO: handle module exit and restart it
// https://github.com/filecoin-station/zinnia/issues/146
log::info!("Starting module {main_module}");
Expand Down

0 comments on commit 6620505

Please sign in to comment.