diff --git a/cli/src/test/snapshot.rs b/cli/src/test/snapshot.rs index 6aa58c65..37cddad2 100644 --- a/cli/src/test/snapshot.rs +++ b/cli/src/test/snapshot.rs @@ -149,12 +149,26 @@ impl SnapshotGenerator { return Err(eyre!("Empty snapshot, no data found for the selected options (filter, starting_block, num_batches ...)")); } + let stream_options = sanitize_stream_options(&self.stream_options); + Ok(Snapshot { script_path: self.script_path, num_batches: self.num_batches, - stream_options: self.stream_options, + stream_options, stream_configuration_options: self.stream_configuration_options, stream, }) } } + +/// Remove all the fields from the stream options that are not needed for the snapshot. +/// +/// This is done to avoid leaking sensitive information (e.g. the bearer token) in the snapshots. +fn sanitize_stream_options(options: &StreamOptions) -> StreamOptions { + StreamOptions { + stream_url: options.stream_url.clone(), + max_message_size: options.max_message_size.clone(), + timeout_duration_seconds: options.timeout_duration_seconds, + ..Default::default() + } +} diff --git a/sink-common/src/configuration.rs b/sink-common/src/configuration.rs index 460aef7a..ea3432b7 100644 --- a/sink-common/src/configuration.rs +++ b/sink-common/src/configuration.rs @@ -81,19 +81,24 @@ pub struct DotenvOptions { pub struct StreamOptions { /// DNA stream url. If starting with `https://`, use a secure connection. #[arg(long, env)] + #[serde(skip_serializing_if = "Option::is_none")] pub stream_url: Option, /// Limits the maximum size of a decoded message. Accept message size in human readable form, /// e.g. 1kb, 1MB, 1GB. If not set the default is 1MB. #[arg(long, env)] + #[serde(skip_serializing_if = "Option::is_none")] pub max_message_size: Option, /// Add metadata to the stream, in the `key: value` format. Can be specified multiple times. #[arg(long, short = 'M', env, value_delimiter = ',')] + #[serde(skip_serializing_if = "Option::is_none")] pub metadata: Option>, /// Use the authorization together when connecting to the stream. #[arg(long, short = 'A', env)] + #[serde(skip_serializing_if = "Option::is_none")] pub auth_token: Option, /// Maximum timeout (in seconds) between stream messages. Defaults to 45s. #[arg(long, env)] + #[serde(skip_serializing_if = "Option::is_none")] pub timeout_duration_seconds: Option, } @@ -104,10 +109,13 @@ pub struct StreamConfigurationOptions { #[serde(flatten)] pub filter: NetworkFilterOptions, /// Set the response preferred batch size. + #[serde(skip_serializing_if = "Option::is_none")] pub batch_size: Option, /// The finality of the data to be streamed. + #[serde(skip_serializing_if = "Option::is_none")] pub finality: Option, /// Start streaming data from the specified block. + #[serde(skip_serializing_if = "Option::is_none")] pub starting_block: Option, }