fix security vulnerability with sapaicore provider (#8215)
Co-authored-by: Max Paulus 🥪 <max@cline.bot>
This commit is contained in:
1 parent
1b7f971c34
commit
47ff7c1620
2 files changed
+6
-7
No files matched your search
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"claude-dev": patch
|
||||
---
|
||||
|
||||
fix sapaicore security issue
|
||||
@@ -878,12 +878,6 @@ export class SapAiCoreHandler implements ApiHandler {
|
||||
stream: any,
|
||||
_model: { id: SapAiCoreModelId; info: ModelInfo },
|
||||
): AsyncGenerator<any, void, unknown> {
|
||||
function toStrictJson(str: string): string {
|
||||
// Wrap it in parentheses so JS will treat it as an expression
|
||||
const obj = new Function("return " + str)()
|
||||
return JSON.stringify(obj)
|
||||
}
|
||||
|
||||
const _usage = { input_tokens: 0, output_tokens: 0 }
|
||||
|
||||
try {
|
||||
@@ -898,7 +892,7 @@ export class SapAiCoreHandler implements ApiHandler {
|
||||
|
||||
try {
|
||||
// Parse the incoming JSON data from the stream
|
||||
const data = JSON.parse(toStrictJson(jsonData))
|
||||
const data = JSON.parse(jsonData)
|
||||
|
||||
// Handle metadata (token usage)
|
||||
if (data.metadata?.usage) {
|
||||
|
||||
Reference in new issue
Block a user