Skip to content

Commit 9340275

Browse files
committed
Fix command injection
1 parent 3bb2629 commit 9340275

File tree

3 files changed

+8
-8
lines changed

3 files changed

+8
-8
lines changed

Core/Sources/ChatGPTChatTab/Chat.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -206,9 +206,9 @@ struct Chat {
206206
"/bin/bash",
207207
arguments: [
208208
"-c",
209-
"xed -l \(reference.startLine ?? 0) \"\(reference.uri)\"",
209+
"xed -l \(reference.startLine ?? 0) ${TARGET_FILE}",
210210
],
211-
environment: [:]
211+
environment: ["TARGET_FILE": reference.uri]
212212
)
213213
} catch {
214214
print(error)

Core/Sources/Service/SuggestionCommandHandler/PseudoCommandHandler.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -505,9 +505,9 @@ struct PseudoCommandHandler: CommandHandler {
505505
"/bin/bash",
506506
arguments: [
507507
"-c",
508-
"xed -l \(line) \"\(fileURL.path)\"",
508+
"xed -l \(line) ${TARGET_FILE}",
509509
],
510-
environment: [:]
510+
environment: ["TARGET_FILE": fileURL.path],
511511
)
512512
} catch {
513513
print(error)

Tool/Sources/GitIgnoreCheck/GitIgnoreCheck.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,9 @@ public struct DefaultGitIgnoredChecker: GitIgnoredChecker {
5454
do {
5555
let result = try await terminal.runCommand(
5656
"/bin/bash",
57-
arguments: ["-c", "git check-ignore \"\(fileURL.path)\""],
57+
arguments: ["-c", "git check-ignore ${TARGET_FILE}"],
5858
currentDirectoryURL: gitFolderURL,
59-
environment: [:]
59+
environment: ["TARGET_FILE": fileURL.path]
6060
)
6161
if result.isEmpty { return false }
6262
return true
@@ -76,9 +76,9 @@ public struct DefaultGitIgnoredChecker: GitIgnoredChecker {
7676
do {
7777
let result = try await terminal.runCommand(
7878
"/bin/bash",
79-
arguments: ["-c", "git check-ignore \(filePaths)"],
79+
arguments: ["-c", "git check-ignore ${TARGET_FILE}"],
8080
currentDirectoryURL: gitFolderURL,
81-
environment: [:]
81+
environment: ["TARGET_FILE": filePaths]
8282
)
8383
return result
8484
.split(whereSeparator: \.isNewline)

0 commit comments

Comments
 (0)