From 91d7f4f70583e3aab13ae503bdeda97073cedb07 Mon Sep 17 00:00:00 2001 From: Joseph Hunkeler Date: Fri, 14 Jun 2024 19:47:34 -0400 Subject: Fix redaction code to accept NULL pointers in array * And let the caller specify the length of the array of strings to redact. * Redactions now occur directly on authentication strings rather than their command line arguments --- src/artifactory.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) (limited to 'src/artifactory.c') diff --git a/src/artifactory.c b/src/artifactory.c index 4772602..5678d64 100644 --- a/src/artifactory.c +++ b/src/artifactory.c @@ -229,16 +229,15 @@ int jfrog_cli(struct JFRT_Auth *auth, char *args) { } const char *redactable[] = { - "--access-token=", - "--ssh-key-path=", - "--ssh-passphrase=", - "--client-cert-key-path=", - "--client-cert-path=", - "--password=", - NULL, + auth->access_token, + auth->ssh_key_path, + auth->ssh_passphrase, + auth->client_cert_key_path, + auth->client_cert_path, + auth->password, }; snprintf(cmd, sizeof(cmd) - 1, "jf %s %s", args, auth_args); - redact_sensitive(redactable, cmd, cmd_redacted, sizeof(cmd_redacted) - 1); + redact_sensitive(redactable, sizeof(redactable) / sizeof (*redactable), cmd, cmd_redacted, sizeof(cmd_redacted) - 1); guard_free(auth_args); guard_strlist_free(&arg_map); -- cgit