Skip to content

Commit 7eca332

Browse files
committed
fix: harden local command execution and SNI error handling
Use argument-based child process execution in the shadcn update script to avoid shell interpolation risks and add a nil-safe close fallback in SNI inspection error paths to prevent panics. Made-with: Cursor
1 parent 701ca88 commit 7eca332

2 files changed

Lines changed: 16 additions & 5 deletions

File tree

frontend/update-shadcn.cjs

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
const fs = require("fs");
44
const path = require("path");
5-
const { execSync } = require("child_process");
5+
const { execFileSync } = require("child_process");
66

77
/**
88
* shadcn 컴포넌트를 자동으로 업데이트하는 스크립트
@@ -69,12 +69,19 @@ function main() {
6969
try {
7070
console.log(`🔄 업데이트 중: ${componentName}...`);
7171

72-
const command = `npx shadcn@latest add -o -y ${componentName}`;
73-
execSync(command, {
72+
if (!/^[a-z0-9_-]+$/i.test(componentName)) {
73+
throw new Error(`invalid component name: ${componentName}`);
74+
}
75+
76+
execFileSync(
77+
"npx",
78+
["shadcn@latest", "add", "-o", "-y", componentName],
79+
{
7480
stdio: "pipe",
7581
encoding: "utf8",
7682
env: { ...process.env, npm_config_legacy_peer_deps: "true" },
77-
});
83+
}
84+
);
7885

7986
console.log(`✅ ${componentName} 업데이트 완료`);
8087
successCount++;

portal/server.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -396,7 +396,11 @@ func (s *Server) runSNIListener(ctx context.Context) error {
396396
func (s *Server) handleSNIConn(ctx context.Context, conn net.Conn) {
397397
clientHello, wrappedConn, err := l4.InspectClientHello(conn, s.cfg.ClientHelloTimeout)
398398
if err != nil {
399-
_ = wrappedConn.Close()
399+
if wrappedConn != nil {
400+
_ = wrappedConn.Close()
401+
} else {
402+
_ = conn.Close()
403+
}
400404
return
401405
}
402406

0 commit comments

Comments
 (0)