Skip to content

Secrets service experiment#26

Closed
Benehiko wants to merge 6 commits intomainfrom
secrets-service-experiment
Closed

Secrets service experiment#26
Benehiko wants to merge 6 commits intomainfrom
secrets-service-experiment

Conversation

@Benehiko
Copy link
Member

This is an experiment - it is a simple package that tests the org.freedesktop.secrets API over DBUS. It tries to list and create collections.

Benehiko added 6 commits June 20, 2025 17:49
Signed-off-by: Alano Terblanche <18033717+Benehiko@users.noreply.github.com>
Signed-off-by: Alano Terblanche <18033717+Benehiko@users.noreply.github.com>
Signed-off-by: Alano Terblanche <18033717+Benehiko@users.noreply.github.com>
Signed-off-by: Alano Terblanche <18033717+Benehiko@users.noreply.github.com>
Signed-off-by: Alano Terblanche <18033717+Benehiko@users.noreply.github.com>
Signed-off-by: Alano Terblanche <18033717+Benehiko@users.noreply.github.com>
if err != nil {
return err
}
fmt.Printf("\nID: %s\nValues: %s\n", k, vv)

Check failure

Code scanning / CodeQL

Clear-text logging of sensitive information High

Sensitive data returned by an access to Password
flows to a logging call.

Copilot Autofix

AI 9 months ago

To fix the issue, the sensitive information (password) should be excluded from the logs or obfuscated before being logged. The Marshal method in MockCredential should be updated to ensure that sensitive data is not exposed. Additionally, the logging statement in keychain/cmd/main.go should be modified to avoid printing the password.

Steps to fix:

  1. Update the Marshal method in keychain/mocks/mock_credential.go to obfuscate the password (e.g., replace it with a placeholder like ***).
  2. Modify the logging statement in keychain/cmd/main.go to exclude sensitive data or use the updated Marshal method that obfuscates the password.

Suggested changeset 2
keychain/cmd/main.go

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/keychain/cmd/main.go b/keychain/cmd/main.go
--- a/keychain/cmd/main.go
+++ b/keychain/cmd/main.go
@@ -40,3 +40,3 @@
 				}
-				fmt.Printf("\nID: %s\nValues: %s\n", k, vv)
+				fmt.Printf("\nID: %s\nValues: %s\n", k, vv) // Password obfuscated in Marshal method
 			}
EOF
@@ -40,3 +40,3 @@
}
fmt.Printf("\nID: %s\nValues: %s\n", k, vv)
fmt.Printf("\nID: %s\nValues: %s\n", k, vv) // Password obfuscated in Marshal method
}
keychain/mocks/mock_credential.go
Outside changed files

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/keychain/mocks/mock_credential.go b/keychain/mocks/mock_credential.go
--- a/keychain/mocks/mock_credential.go
+++ b/keychain/mocks/mock_credential.go
@@ -18,3 +18,3 @@
 func (m *MockCredential) Marshal() ([]byte, error) {
-	return []byte(m.Username + ":" + m.Password), nil
+	return []byte(m.Username + ":***"), nil // Obfuscate the password
 }
EOF
@@ -18,3 +18,3 @@
func (m *MockCredential) Marshal() ([]byte, error) {
return []byte(m.Username + ":" + m.Password), nil
return []byte(m.Username + ":***"), nil // Obfuscate the password
}
Copilot is powered by AI and may make mistakes. Always verify output.
if err != nil {
return err
}
fmt.Printf("Secret:\nID:%s\nValues:%s\n", id.String(), val)

Check failure

Code scanning / CodeQL

Clear-text logging of sensitive information High

Sensitive data returned by an access to Password
flows to a logging call.

Copilot Autofix

AI 9 months ago

To fix the issue, we need to ensure that sensitive information (e.g., passwords) is not logged in clear text. Instead of logging the entire output of the Marshal method, we should log only non-sensitive information, such as the Username or a sanitized version of the data.

In this case, we will modify the fmt.Printf statement on line 86 in keychain/cmd/main.go to exclude the password from the logged output. Additionally, we will update the Marshal method in keychain/mocks/mock_credential.go to provide a sanitized version of the data for logging purposes.


Suggested changeset 2
keychain/cmd/main.go

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/keychain/cmd/main.go b/keychain/cmd/main.go
--- a/keychain/cmd/main.go
+++ b/keychain/cmd/main.go
@@ -85,3 +85,3 @@
 			}
-			fmt.Printf("Secret:\nID:%s\nValues:%s\n", id.String(), val)
+			fmt.Printf("Secret:\nID:%s\nValues:%s\n", id.String(), sanitizeSecret(val))
 			return nil
EOF
@@ -85,3 +85,3 @@
}
fmt.Printf("Secret:\nID:%s\nValues:%s\n", id.String(), val)
fmt.Printf("Secret:\nID:%s\nValues:%s\n", id.String(), sanitizeSecret(val))
return nil
keychain/mocks/mock_credential.go
Outside changed files

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/keychain/mocks/mock_credential.go b/keychain/mocks/mock_credential.go
--- a/keychain/mocks/mock_credential.go
+++ b/keychain/mocks/mock_credential.go
@@ -31 +31,10 @@
 }
+
+// sanitizeSecret redacts sensitive information (e.g., passwords) from the secret data.
+func sanitizeSecret(data []byte) string {
+	parts := bytes.Split(data, []byte(":"))
+	if len(parts) != 2 {
+		return "Invalid secret format"
+	}
+	return string(parts[0]) + ":<redacted>"
+}
EOF
@@ -31 +31,10 @@
}

// sanitizeSecret redacts sensitive information (e.g., passwords) from the secret data.
func sanitizeSecret(data []byte) string {
parts := bytes.Split(data, []byte(":"))
if len(parts) != 2 {
return "Invalid secret format"
}
return string(parts[0]) + ":<redacted>"
}
Copilot is powered by AI and may make mistakes. Always verify output.
@Benehiko
Copy link
Member Author

this is already supported in main. Will close this.

@Benehiko Benehiko closed this Aug 21, 2025
@Benehiko Benehiko deleted the secrets-service-experiment branch January 27, 2026 14:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant