-
Notifications
You must be signed in to change notification settings - Fork 4.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Externalize Vendor Code #3393
base: develop
Are you sure you want to change the base?
Externalize Vendor Code #3393
Conversation
file: fs.createReadStream(audioFile.path), | ||
model: "whisper-1", | ||
}); | ||
const transcription = await runtime.useModel(ModelClass.TRANSCRIPTION, fs.createReadStream(audioFile.path)); |
Check failure
Code scanning / CodeQL
Uncontrolled data used in path expression High
user-provided value
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix AI about 5 hours ago
To fix the problem, we need to ensure that the file path derived from user input is validated and sanitized before being used. We can achieve this by resolving the file path to a known safe directory and ensuring it does not escape this directory. This can be done using path.resolve
and fs.realpathSync
to normalize the path and check it against the safe directory.
- Define a safe root directory where uploaded files are stored.
- Resolve the
audioFile.path
to ensure it is within the safe directory. - If the resolved path is not within the safe directory, return an error response.
-
Copy modified lines R94-R100
@@ -93,3 +93,9 @@ | ||
|
||
const transcription = await runtime.useModel(ModelClass.TRANSCRIPTION, fs.createReadStream(audioFile.path)); | ||
const safeRoot = path.join(process.cwd(), "/data/uploads"); | ||
const resolvedPath = fs.realpathSync(path.resolve(safeRoot, audioFile.path)); | ||
if (!resolvedPath.startsWith(safeRoot)) { | ||
res.status(403).send("Invalid file path"); | ||
return; | ||
} | ||
const transcription = await runtime.useModel(ModelClass.TRANSCRIPTION, fs.createReadStream(resolvedPath)); | ||
|
* added character methods * missing comma/syntax issue
fix: add @solana/web3.js deps
* clean up types and registry validation * dont check in lock files
* db path resolution * Update resolve-database-path.ts
This PR has many core breaking changes
The main change is that vendor code has been removed from core. For any third party vendor plugins, interfaces are available to register plugins to handle nearly everything (or at least there will be soon)
Other than that, many things were moved, removed, consolidated or simplified. The primary goal of this branch is to enable the project to scale and reach more users. Also, switched from
pnpm
tobun