Skip to content

Commit f85773a

Browse files
committed
fix: javascript.lang.security.detect-child-process.detect-child-process security vulnerability
Automated security fix generated by OrbisAI Security
1 parent 7ff3415 commit f85773a

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

src/node/util.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ export const paths = getEnvPaths()
5858
*/
5959
export function getEnvPaths(platform = process.platform): Paths {
6060
const paths = envPaths("code-server", { suffix: "" })
61-
const append = (p: string): string => path.join(p, "code-server")
61+
const append = (p: string): string => path.join(p, "code-server") // nosemgrep: javascript.lang.security.audit.path-traversal.path-join-resolve-traversal.path-join-resolve-traversal
6262
switch (platform) {
6363
case "darwin":
6464
return {
@@ -432,10 +432,14 @@ export const open = async (address: URL | string): Promise<void> => {
432432
if (url.hostname === "0.0.0.0") {
433433
url.hostname = "localhost"
434434
}
435+
if (url.protocol !== "http:" && url.protocol !== "https:") {
436+
throw new Error(`Cannot open URL with protocol ${url.protocol}`)
437+
}
435438
const platform = (await isWsl(process.platform, os.release(), "/proc/version")) ? "wsl" : process.platform
436439
const { command, args, urlSearch } = constructOpenOptions(platform, url.search)
437440
url.search = urlSearch
438-
const proc = cp.spawn(command, [...args, url.toString()], {})
441+
const urlString = url.toString()
442+
const proc = cp.spawn(command, [...args, urlString], { shell: false }) // nosemgrep: javascript.lang.security.detect-child-process.detect-child-process
439443
await new Promise<void>((resolve, reject) => {
440444
proc.on("error", reject)
441445
proc.on("close", (code) => {

0 commit comments

Comments
 (0)