-
Notifications
You must be signed in to change notification settings - Fork 1
Standard audit #45
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Standard audit #45
Changes from all commits
3a0ed4b
28a835d
a650960
1cc3cf4
19f53bd
46de563
3952da8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,7 +1,7 @@ | ||
| #!/bin/sh | ||
| set -eu | ||
|
|
||
| bunx lint-staged | ||
| bun run lint-staged | ||
|
|
||
| printf '%s\n' "Running security check..." | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| import * as v from "valibot"; | ||
|
|
||
| const EnvSchema = v.object({ | ||
| HOME: v.optional(v.string()), | ||
| LANG: v.optional(v.string()), | ||
| LC_ALL: v.optional(v.string()), | ||
| LOGNAME: v.optional(v.string()), | ||
| PATH: v.optional(v.string()), | ||
| SHELL: v.optional(v.string()), | ||
| SSH_AUTH_SOCK: v.optional(v.string()), | ||
| TEMP: v.optional(v.string()), | ||
| TERM: v.optional(v.string()), | ||
| TMP: v.optional(v.string()), | ||
| TMPDIR: v.optional(v.string()), | ||
| USER: v.optional(v.string()), | ||
| XDG_CONFIG_HOME: v.optional(v.string()), | ||
| XDG_STATE_HOME: v.optional(v.string()), | ||
| }); | ||
|
|
||
| export const env = v.parse(EnvSchema, process.env); |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -111,8 +111,14 @@ export async function loadConfig(): Promise<OpsHarborConfig> { | |
| normalizeConfig(v.parse(ConfigSchema, JSON.parse(raw))), | ||
| detectedAuthorLogin, | ||
| ); | ||
| } catch { | ||
| return withDetectedAuthorLogin(defaultConfig(), detectedAuthorLogin); | ||
| } catch (e) { | ||
| // ENOENT is expected on first run before the config file is created | ||
| if (e instanceof Error && "code" in e && (e as NodeJS.ErrnoException).code === "ENOENT") { | ||
| return withDetectedAuthorLogin(defaultConfig(), detectedAuthorLogin); | ||
| } | ||
| // Schema/parse errors indicate a corrupt or incompatible config file — propagate | ||
| console.error("[ops-harbor] loadConfig: failed to load or parse config:", e); | ||
| throw e; | ||
|
Comment on lines
+120
to
+121
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Avoid logging raw thrown objects from config load failures. Line [120] logs the full caught value. In failure cases, raw error objects can include sensitive config context (for example token-bearing content). Log a sanitized message and still rethrow. 🔒 Suggested safe logging adjustment- console.error("[ops-harbor] loadConfig: failed to load or parse config:", e);
+ const errorSummary =
+ e instanceof Error ? { name: e.name } : { type: typeof e };
+ console.error("[ops-harbor] loadConfig: failed to load or parse config", errorSummary);
throw e;🤖 Prompt for AI Agents |
||
| } | ||
| } | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -13,7 +13,9 @@ export async function syncFromControlPlane( | |||||||||||||||||||||||
| try { | ||||||||||||||||||||||||
| const result = await client.triggerSync(config.authorLogin); | ||||||||||||||||||||||||
| synchronized = result.synchronized; | ||||||||||||||||||||||||
| } catch { | ||||||||||||||||||||||||
| } catch (e) { | ||||||||||||||||||||||||
| // triggerSync is best-effort; network/control-plane errors should not abort the sync | ||||||||||||||||||||||||
| console.error("[ops-harbor] syncFromControlPlane: triggerSync failed:", e); | ||||||||||||||||||||||||
| synchronized = undefined; | ||||||||||||||||||||||||
|
Comment on lines
+16
to
19
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sanitize triggerSync error logging to avoid accidental secret exposure. Line [18] logs the raw thrown object. Client/network errors can contain sensitive request metadata; prefer sanitized fields. 🔒 Suggested safe logging adjustment- } catch (e) {
+ } catch (e) {
// triggerSync is best-effort; network/control-plane errors should not abort the sync
- console.error("[ops-harbor] syncFromControlPlane: triggerSync failed:", e);
+ const errorSummary =
+ e instanceof Error ? { name: e.name } : { type: typeof e };
+ console.error("[ops-harbor] syncFromControlPlane: triggerSync failed", errorSummary);
synchronized = undefined;
}📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||
| } | ||||||||||||||||||||||||
| } | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| import * as v from "valibot"; | ||
|
|
||
| const EnvSchema = v.object({ | ||
| // Default: ~/.config/sdd-webapp (resolved at call-site via homedir()) | ||
| SDD_WEBAPP_CONFIG_DIR: v.optional(v.string()), | ||
| }); | ||
|
|
||
| // Validate at startup (fail-fast), read at call time (testable) | ||
| v.parse(EnvSchema, process.env); | ||
|
|
||
| export const env = { | ||
| get SDD_WEBAPP_CONFIG_DIR() { | ||
| return process.env.SDD_WEBAPP_CONFIG_DIR; | ||
| }, | ||
| }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Avoid logging raw parse/validation errors for secret-bearing config.
Line 101 logs the full caught error object, which can expose sensitive config values in logs (especially on schema-validation failures). Log a sanitized error summary instead.
🔧 Suggested safe logging change
🤖 Prompt for AI Agents