aboutsummaryrefslogtreecommitdiff
path: root/src/artifactory.c
diff options
context:
space:
mode:
authorJoseph Hunkeler <jhunkeler@gmail.com>2024-04-15 13:33:36 -0400
committerJoseph Hunkeler <jhunkeler@gmail.com>2024-04-15 13:33:36 -0400
commitcabcd35daa18bb883f0d348b2adf93c5828af69f (patch)
treea8a1c2e5142662244fcab2e928754dc48db05e4b /src/artifactory.c
parent208962dfdbd24788a6decf1839ecbbf584fb2e09 (diff)
downloadstasis-cabcd35daa18bb883f0d348b2adf93c5828af69f.tar.gz
Move artifactory authentication redaction code into its own function: redact_sensitive()
Diffstat (limited to 'src/artifactory.c')
-rw-r--r--src/artifactory.c16
1 files changed, 3 insertions, 13 deletions
diff --git a/src/artifactory.c b/src/artifactory.c
index 437912d..a23af98 100644
--- a/src/artifactory.c
+++ b/src/artifactory.c
@@ -224,9 +224,6 @@ int jfrog_cli(struct JFRT_Auth *auth, char *args) {
return -1;
}
- snprintf(cmd, sizeof(cmd) - 1, "jf %s %s", args, auth_args);
- strcpy(cmd_redacted, cmd);
-
const char *redactable[] = {
"--access-token=",
"--ssh-key-path=",
@@ -236,16 +233,9 @@ int jfrog_cli(struct JFRT_Auth *auth, char *args) {
"--password=",
NULL,
};
- for (size_t i = 0; redactable[i] != NULL; i++) {
- char *thing = strstr(cmd_redacted, redactable[i]);
- if (thing) {
- thing += strlen(redactable[i]);
- while (*thing != '\0' && !isspace(*thing)) {
- *thing = 'x';
- ++thing;
- }
- }
- }
+ snprintf(cmd, sizeof(cmd) - 1, "jf %s %s", args, auth_args);
+ redact_sensitive(redactable, cmd, cmd_redacted, sizeof(cmd_redacted) - 1);
+
guard_free(auth_args);
guard_strlist_free(&arg_map);