From c7d8fb5d3402c7361d2ff906ffebe2fe7402b9aa Mon Sep 17 00:00:00 2001 From: Steven Kessler Date: Tue, 14 May 2024 12:30:04 -0400 Subject: [PATCH 1/4] bugfix(teller file name): re use the variable declared for the default to prevent drift between teller new and file lookup --- teller-cli/src/cli.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/teller-cli/src/cli.rs b/teller-cli/src/cli.rs index 1c85f380..84bb49bc 100644 --- a/teller-cli/src/cli.rs +++ b/teller-cli/src/cli.rs @@ -183,7 +183,7 @@ pub struct NewArgs { } async fn load_teller(config: Option) -> eyre::Result { - let config_arg = config.unwrap_or_else(|| "teller.yml".to_string()); + let config_arg = config.unwrap_or_else(|| DEFAULT_FILE_PATH.to_string()); let config_path = Path::new(&config_arg); let teller = Teller::from_yaml(config_path).await?; Ok(teller) From 4d385122356e6a81ddc09090e4fe790f5fe1d84d Mon Sep 17 00:00:00 2001 From: Steven Kessler Date: Tue, 14 May 2024 13:06:28 -0400 Subject: [PATCH 2/4] testfix(naming): made the naming and configs more consistent, if a config is specificed it should use that name, if no name is specificed it should use the defaults --- .../tests/cmd/copy.in/{teller.yml => .teller.yml} | 0 .../tests/cmd/delete.in/{teller.yml => .teller.yml} | 0 .../tests/cmd/export.in/{teller.yml => .teller.yml} | 0 teller-cli/tests/cmd/export.trycmd | 12 ++++++------ .../tests/cmd/put.in/{teller.yml => .teller.yml} | 0 .../tests/cmd/run.in/{teller.yml => .teller.yml} | 0 teller-cli/tests/cmd/run.trycmd | 2 +- .../tests/cmd/scan.in/{teller.yml => .teller.yml} | 0 teller-cli/tests/cmd/scan.trycmd | 6 +++--- .../cmd/template.in/{teller.yml => .teller.yml} | 0 teller-cli/tests/cmd/template.trycmd | 2 +- 11 files changed, 11 insertions(+), 11 deletions(-) rename teller-cli/tests/cmd/copy.in/{teller.yml => .teller.yml} (100%) rename teller-cli/tests/cmd/delete.in/{teller.yml => .teller.yml} (100%) rename teller-cli/tests/cmd/export.in/{teller.yml => .teller.yml} (100%) rename teller-cli/tests/cmd/put.in/{teller.yml => .teller.yml} (100%) rename teller-cli/tests/cmd/run.in/{teller.yml => .teller.yml} (100%) rename teller-cli/tests/cmd/scan.in/{teller.yml => .teller.yml} (100%) rename teller-cli/tests/cmd/template.in/{teller.yml => .teller.yml} (100%) diff --git a/teller-cli/tests/cmd/copy.in/teller.yml b/teller-cli/tests/cmd/copy.in/.teller.yml similarity index 100% rename from teller-cli/tests/cmd/copy.in/teller.yml rename to teller-cli/tests/cmd/copy.in/.teller.yml diff --git a/teller-cli/tests/cmd/delete.in/teller.yml b/teller-cli/tests/cmd/delete.in/.teller.yml similarity index 100% rename from teller-cli/tests/cmd/delete.in/teller.yml rename to teller-cli/tests/cmd/delete.in/.teller.yml diff --git a/teller-cli/tests/cmd/export.in/teller.yml b/teller-cli/tests/cmd/export.in/.teller.yml similarity index 100% rename from teller-cli/tests/cmd/export.in/teller.yml rename to teller-cli/tests/cmd/export.in/.teller.yml diff --git a/teller-cli/tests/cmd/export.trycmd b/teller-cli/tests/cmd/export.trycmd index 6190e5b6..02e53d3c 100644 --- a/teller-cli/tests/cmd/export.trycmd +++ b/teller-cli/tests/cmd/export.trycmd @@ -1,29 +1,29 @@ ```console -$ teller -c teller.yml export yaml +$ teller export yaml FOO_BAR: foo FOO_BAZ: baz PRINT_MOOD: happy PRINT_NAME: linus -$ teller -c teller.yml export csv +$ teller export csv FOO_BAR,foo PRINT_NAME,linus FOO_BAZ,baz PRINT_MOOD,happy -$ teller -c teller.yml export json +$ teller export json {"FOO_BAR":"foo","FOO_BAZ":"baz","PRINT_MOOD":"happy","PRINT_NAME":"linus"} -$ teller -c teller.yml export env +$ teller export env FOO_BAR=foo PRINT_NAME=linus FOO_BAZ=baz PRINT_MOOD=happy -$ teller -c teller.yml sh +$ teller sh #!/bin/sh export FOO_BAR='foo' export PRINT_NAME='linus' @@ -31,7 +31,7 @@ export FOO_BAZ='baz' export PRINT_MOOD='happy' -$ teller -c teller.yml env +$ teller env FOO_BAR=foo PRINT_NAME=linus FOO_BAZ=baz diff --git a/teller-cli/tests/cmd/put.in/teller.yml b/teller-cli/tests/cmd/put.in/.teller.yml similarity index 100% rename from teller-cli/tests/cmd/put.in/teller.yml rename to teller-cli/tests/cmd/put.in/.teller.yml diff --git a/teller-cli/tests/cmd/run.in/teller.yml b/teller-cli/tests/cmd/run.in/.teller.yml similarity index 100% rename from teller-cli/tests/cmd/run.in/teller.yml rename to teller-cli/tests/cmd/run.in/.teller.yml diff --git a/teller-cli/tests/cmd/run.trycmd b/teller-cli/tests/cmd/run.trycmd index cbfabddb..26499184 100644 --- a/teller-cli/tests/cmd/run.trycmd +++ b/teller-cli/tests/cmd/run.trycmd @@ -1,5 +1,5 @@ ```console -$ teller -c teller.yml run --reset --shell -- node index.js +$ teller run --reset --shell -- node index.js hello from nodejs linus happy diff --git a/teller-cli/tests/cmd/scan.in/teller.yml b/teller-cli/tests/cmd/scan.in/.teller.yml similarity index 100% rename from teller-cli/tests/cmd/scan.in/teller.yml rename to teller-cli/tests/cmd/scan.in/.teller.yml diff --git a/teller-cli/tests/cmd/scan.trycmd b/teller-cli/tests/cmd/scan.trycmd index 8d471e7f..46a27fc4 100644 --- a/teller-cli/tests/cmd/scan.trycmd +++ b/teller-cli/tests/cmd/scan.trycmd @@ -1,5 +1,5 @@ ```console -$ teller -c teller.yml scan +$ teller scan scanning for 4 item(s) in . 2:9 ./one.env fo*** dotenv one.env 2:9 ./two.env ba*** dotenv two.env @@ -7,7 +7,7 @@ scanning for 4 item(s) in . 1:12 ./one.env li*** dotenv one.env found 4 result(s) -$ teller -c teller.yml scan -a +$ teller scan -a scanning for 4 item(s) in . 2:9 ./one.env fo*** dotenv one.env 2:9 ./two.env ba*** dotenv two.env @@ -16,7 +16,7 @@ scanning for 4 item(s) in . 1:12 ./one.env li*** dotenv one.env found 5 result(s) -$ teller -c teller.yml scan -b +$ teller scan -b scanning for 4 item(s) in . 2:9 ./one.env fo*** dotenv one.env 2:9 ./two.env ba*** dotenv two.env diff --git a/teller-cli/tests/cmd/template.in/teller.yml b/teller-cli/tests/cmd/template.in/.teller.yml similarity index 100% rename from teller-cli/tests/cmd/template.in/teller.yml rename to teller-cli/tests/cmd/template.in/.teller.yml diff --git a/teller-cli/tests/cmd/template.trycmd b/teller-cli/tests/cmd/template.trycmd index 7ba16b92..80b0d674 100644 --- a/teller-cli/tests/cmd/template.trycmd +++ b/teller-cli/tests/cmd/template.trycmd @@ -1,5 +1,5 @@ ```console -$ teller -c teller.yml template --in config-templ.t +$ teller template --in config-templ.t production_var: linus production_mood: happy From 38f59653f9432230e8aaf64255e443a129f3e88f Mon Sep 17 00:00:00 2001 From: Dotan Nahum Date: Wed, 15 May 2024 11:12:38 +0300 Subject: [PATCH 3/4] fix: empty redactions, #217 --- teller-cli/tests/cmd/redact.in/.teller.yml | 11 +++++++++++ teller-cli/tests/cmd/redact.in/one.env | 3 +++ teller-cli/tests/cmd/redact.in/text.txt | 2 ++ teller-cli/tests/cmd/redact.in/two.env | 2 ++ teller-cli/tests/cmd/redact.trycmd | 4 ++++ teller-core/src/redact.rs | 17 ++++++++++------- 6 files changed, 32 insertions(+), 7 deletions(-) create mode 100644 teller-cli/tests/cmd/redact.in/.teller.yml create mode 100644 teller-cli/tests/cmd/redact.in/one.env create mode 100644 teller-cli/tests/cmd/redact.in/text.txt create mode 100644 teller-cli/tests/cmd/redact.in/two.env create mode 100644 teller-cli/tests/cmd/redact.trycmd diff --git a/teller-cli/tests/cmd/redact.in/.teller.yml b/teller-cli/tests/cmd/redact.in/.teller.yml new file mode 100644 index 00000000..719d24a0 --- /dev/null +++ b/teller-cli/tests/cmd/redact.in/.teller.yml @@ -0,0 +1,11 @@ +providers: + dot1: + kind: dotenv + maps: + - id: one + path: one.env + dot2: + kind: dotenv + maps: + - id: two + path: two.env diff --git a/teller-cli/tests/cmd/redact.in/one.env b/teller-cli/tests/cmd/redact.in/one.env new file mode 100644 index 00000000..a52bed13 --- /dev/null +++ b/teller-cli/tests/cmd/redact.in/one.env @@ -0,0 +1,3 @@ +PRINT_NAME=linus +FOO_BAR=foo +EMPTY="" diff --git a/teller-cli/tests/cmd/redact.in/text.txt b/teller-cli/tests/cmd/redact.in/text.txt new file mode 100644 index 00000000..9a7597f4 --- /dev/null +++ b/teller-cli/tests/cmd/redact.in/text.txt @@ -0,0 +1,2 @@ +hello linus, +I just read that you made linux. diff --git a/teller-cli/tests/cmd/redact.in/two.env b/teller-cli/tests/cmd/redact.in/two.env new file mode 100644 index 00000000..18b198b4 --- /dev/null +++ b/teller-cli/tests/cmd/redact.in/two.env @@ -0,0 +1,2 @@ +PRINT_MOOD=happy +FOO_BAZ=baz diff --git a/teller-cli/tests/cmd/redact.trycmd b/teller-cli/tests/cmd/redact.trycmd new file mode 100644 index 00000000..f021b58a --- /dev/null +++ b/teller-cli/tests/cmd/redact.trycmd @@ -0,0 +1,4 @@ +```console +$ teller redact --in text.txt + +``` diff --git a/teller-core/src/redact.rs b/teller-core/src/redact.rs index d057c1f0..9d6c0871 100644 --- a/teller-core/src/redact.rs +++ b/teller-core/src/redact.rs @@ -39,13 +39,16 @@ impl Redactor { if self.has_match(message, kvs) { let mut redacted = message.to_string(); for kv in kvs { - redacted = redacted.replace( - &kv.value, - kv.meta - .as_ref() - .and_then(|m| m.redact_with.as_ref()) - .map_or("[REDACTED]", |s| s.as_str()), - ); + // only replace values with at least 2 chars + if kv.value.len() >= 2 { + redacted = redacted.replace( + &kv.value, + kv.meta + .as_ref() + .and_then(|m| m.redact_with.as_ref()) + .map_or("[REDACTED]", |s| s.as_str()), + ); + } } Cow::Owned(redacted) } else { From 5064e4e37edc7ec4df60171e90a687b47b876da1 Mon Sep 17 00:00:00 2001 From: Dotan Nahum Date: Wed, 15 May 2024 11:24:26 +0300 Subject: [PATCH 4/4] tests: align snapshot --- teller-cli/tests/cmd/redact.trycmd | 2 ++ 1 file changed, 2 insertions(+) diff --git a/teller-cli/tests/cmd/redact.trycmd b/teller-cli/tests/cmd/redact.trycmd index f021b58a..2ab4130e 100644 --- a/teller-cli/tests/cmd/redact.trycmd +++ b/teller-cli/tests/cmd/redact.trycmd @@ -1,4 +1,6 @@ ```console $ teller redact --in text.txt +hello [REDACTED], +I just read that you made linux. ```