Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

obfuscation is now turnoffable #20

Merged
merged 4 commits into from
May 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,15 @@ API_KEY = "App1Secret"
BEAM_APP_ID_LONG = "app1.broker.example.com"
```

optional variable
### Optional variables

```bash
RETRY_COUNT = "32"
```

The default maximum number of retries for beam and blaze healthchecks is 32.

To disable the count obfuscation, set the env. variable `DO_NOT_OBFUSCATE`.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please give values for on / off.

Consider using a positive variable (negations are confusing)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It doesn't work with boolean.
clap-rs/clap#1649
Do you want it to be a string?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Surprising but then I'm fine with it


Optionally, you can provide the `TLS_CA_CERTIFICATES_DIR` environment variable to add additional trusted certificates, e.g., if you have a TLS-terminating proxy server in place. The application respects the `HTTP_PROXY`, `HTTPS_PROXY`, `ALL_PROXY`, `NO_PROXY`, and their respective lowercase equivalents.

Expand Down
6 changes: 6 additions & 0 deletions src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@ struct CliArgs {
#[clap(long, env, value_parser)]
blaze_url: Uri,

/// Should the results not be obfuscated
#[clap(long, env, value_parser)]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't you want to set default value == false (meaning "yes, obfuscate?)

negations are confusing

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When the parameter is not present, it is false, no default needed

do_not_obfuscate: bool,

/// Outgoing HTTP proxy: Directory with CA certificates to trust for TLS connections (e.g. /etc/samply/cacerts/)
#[clap(long, env, value_parser)]
tls_ca_certificates_dir: Option<PathBuf>,
Expand All @@ -53,6 +57,7 @@ pub(crate) struct Config {
pub api_key: String,
pub retry_count: usize,
pub blaze_url: Uri,
pub do_not_obfuscate: bool,
tls_ca_certificates: Vec<Certificate>,
pub client: Client,
}
Expand All @@ -71,6 +76,7 @@ impl Config {
api_key: cli_args.api_key,
retry_count: cli_args.retry_count,
blaze_url: cli_args.blaze_url,
do_not_obfuscate: cli_args.do_not_obfuscate,
tls_ca_certificates,
client
};
Expand Down
7 changes: 5 additions & 2 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -167,9 +167,12 @@ async fn run_cql_query(task: &BeamTask, query: &Query, obf_cache: &mut ObfCache)
}
};

let cql_result_new = obfuscate_counts_mr(&cql_result, obf_cache);
let cql_result_new = match CONFIG.do_not_obfuscate {
false => obfuscate_counts_mr(&cql_result, obf_cache)?,
true => cql_result
};

let result = beam_result(task.to_owned(), cql_result_new?
let result = beam_result(task.to_owned(), cql_result_new
.to_string()).unwrap_or_else(|e| {
err.body = e.to_string();
return err;
Expand Down