Skip to content

[refactor] Unify & cleanup certconfig#233

Open
bitterpanda63 wants to merge 1 commit intomainfrom
refactor-cacerts-unified
Open

[refactor] Unify & cleanup certconfig#233
bitterpanda63 wants to merge 1 commit intomainfrom
refactor-cacerts-unified

Conversation

@bitterpanda63
Copy link
Copy Markdown
Member

@bitterpanda63 bitterpanda63 commented Mar 31, 2026

Useful for when we add new tools here, otherwise it'll become a mess overlooking this

Summary by Aikido

⚠️ Security Issues: 4 🔍 Quality Issues: 2 ✅ Resolved Issues: 4

🚀 New Features

  • Introduced OS-specific shared shell helpers for Darwin and Windows.

⚡ Enhancements

  • Added Docker configurator and integrated Docker CA handling into daemon.

🔧 Refactors

  • Reorganized certconfig into subpackages and unified configurator interfaces.
  • Exported and renamed shared certbundle functions for reuse across packages.

More info

savedPath string,
lookup func(context.Context) (CertSetting, error),
) (CertSetting, error) {
if data, err := os.ReadFile(savedPath); err == nil {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Potential file inclusion attack via reading file - medium severity
If an attacker can control the input leading into the ReadFile function, they might be able to read sensitive files and launch further attacks with that information.

Show fix

Remediation: Ignore this issue only after you've verified or sanitized the input going into this function.

Reply @AikidoSec ignore: [REASON] to ignore this issue.
More info

if err != nil {
continue // shell not installed
}
out, err := platform.RunAsCurrentUserWithPathEnv(ctx, shellPath, lookup.Args...)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

platform.RunAsCurrentUserWithPathEnv error is ignored; add logging or an explanatory comment to justify swallowing the error.

Details

✨ AI Reasoning
​An error-from-external-process case is being silently ignored with no logging, re-throwing, or comment. Silently swallowing errors from invoking user shells can hide failures and make debugging difficult; a minimal log or explicit intent comment would clarify why the error is ignored.

🔧 How do I fix it?
Add proper error handling in catch blocks. Log the error, show user feedback, or rethrow if needed.

Reply @AikidoSec feedback: [FEEDBACK] to get better review comments in the future.
Reply @AikidoSec ignore: [REASON] to ignore this issue.
More info

Comment on lines +32 to +33
content := ""
if data, err := os.ReadFile(path); err == nil {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Potential file inclusion attack via reading file - high severity
If an attacker can control the input leading into the ReadFile function, they might be able to read sensitive files and launch further attacks with that information.

Show fix
Suggested change
content := ""
if data, err := os.ReadFile(path); err == nil {
if strings.Contains(path, "..") {
return fmt.Errorf("invalid file path")
}
content := ""
if data, err := os.ReadFile(path); err == nil {

More info

Comment on lines +50 to +55
body = strings.ReplaceAll(body, "\r\n", "\n")
if newline != "\n" {
body = strings.ReplaceAll(body, "\n", newline)
}

return os.WriteFile(path, []byte(stripped+BuildManagedBlock(body, format, newline)), perm)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function parameter 'body' is reassigned (body = strings.ReplaceAll(...)). Avoid mutating parameters; assign to a new local variable (e.g., normalizedBody) before further processing.

Show fix
Suggested change
body = strings.ReplaceAll(body, "\r\n", "\n")
if newline != "\n" {
body = strings.ReplaceAll(body, "\n", newline)
}
return os.WriteFile(path, []byte(stripped+BuildManagedBlock(body, format, newline)), perm)
normalizedBody := strings.ReplaceAll(body, "\r\n", "\n")
if newline != "\n" {
normalizedBody = strings.ReplaceAll(normalizedBody, "\n", newline)
}
return os.WriteFile(path, []byte(stripped+BuildManagedBlock(normalizedBody, format, newline)), perm)
Details

✨ AI Reasoning
​A function parameter is reassigned to a new string value. Reassigning parameters can obscure the original argument and make debugging harder; here 'body' is normalized in-place which hides the original input. This is a conservative quality concern because transforming inputs is common, but in-place reassignment reduces clarity.

Reply @AikidoSec feedback: [FEEDBACK] to get better review comments in the future.
Reply @AikidoSec ignore: [REASON] to ignore this issue.
More info

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