mirror of
https://github.com/openclaw/openclaw.git
synced 2026-04-25 08:02:04 +00:00
fix(security): harden exec approval boundaries
This commit is contained in:
@@ -110,4 +110,50 @@ enum ExecEnvInvocationUnwrapper {
|
||||
}
|
||||
return current
|
||||
}
|
||||
|
||||
private static func unwrapTransparentEnvInvocation(_ command: [String]) -> [String]? {
|
||||
var idx = 1
|
||||
while idx < command.count {
|
||||
let token = command[idx].trimmingCharacters(in: .whitespacesAndNewlines)
|
||||
if token.isEmpty {
|
||||
idx += 1
|
||||
continue
|
||||
}
|
||||
if token == "--" {
|
||||
idx += 1
|
||||
break
|
||||
}
|
||||
if token == "-" {
|
||||
return nil
|
||||
}
|
||||
if self.isEnvAssignment(token) {
|
||||
return nil
|
||||
}
|
||||
if token.hasPrefix("-"), token != "-" {
|
||||
return nil
|
||||
}
|
||||
break
|
||||
}
|
||||
guard idx < command.count else { return nil }
|
||||
return Array(command[idx...])
|
||||
}
|
||||
|
||||
static func unwrapTransparentDispatchWrappersForResolution(_ command: [String]) -> [String] {
|
||||
var current = command
|
||||
var depth = 0
|
||||
while depth < self.maxWrapperDepth {
|
||||
guard let token = current.first?.trimmingCharacters(in: .whitespacesAndNewlines), !token.isEmpty else {
|
||||
break
|
||||
}
|
||||
guard ExecCommandToken.basenameLower(token) == "env" else {
|
||||
break
|
||||
}
|
||||
guard let unwrapped = self.unwrapTransparentEnvInvocation(current), !unwrapped.isEmpty else {
|
||||
break
|
||||
}
|
||||
current = unwrapped
|
||||
depth += 1
|
||||
}
|
||||
return current
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user