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) 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/redact.in/.teller.yml similarity index 100% rename from teller-cli/tests/cmd/run.in/teller.yml rename to teller-cli/tests/cmd/redact.in/.teller.yml 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..2ab4130e --- /dev/null +++ b/teller-cli/tests/cmd/redact.trycmd @@ -0,0 +1,6 @@ +```console +$ teller redact --in text.txt +hello [REDACTED], +I just read that you made linux. + +``` diff --git a/teller-cli/tests/cmd/scan.in/teller.yml b/teller-cli/tests/cmd/run.in/.teller.yml similarity index 100% rename from teller-cli/tests/cmd/scan.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/template.in/teller.yml b/teller-cli/tests/cmd/scan.in/.teller.yml similarity index 100% rename from teller-cli/tests/cmd/template.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 new file mode 100644 index 00000000..719d24a0 --- /dev/null +++ b/teller-cli/tests/cmd/template.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/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 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 {