feat: add hard-coded allowed script paths, for security reasons

This commit is contained in:
Jerry Tian 2025-04-06 16:27:39 -04:00
parent 57cbbb70de
commit 6694cf0170
4 changed files with 25 additions and 0 deletions

View File

@ -0,0 +1,3 @@
#!/bin/bash
echo "Script executed with args: $1 $2"
echo "Current time: $(date)"

View File

@ -0,0 +1,4 @@
#!/bin/bash
echo "Script executed with args: $1 $2"
echo "Current time: $(date)"
echo "Current directory: $(pwd)"

View File

@ -24,6 +24,22 @@ export async function executeScript(
params: ScriptParams,
): Promise<ScriptResult> {
// Add the script execution to the queue
// hardcoded the allowed script path for security reasons
var allowedScriptPaths = [
"/tmp/api_scripts/hello_test.sh",
"/tmp/api_scripts/video_add_watermark.sh",
];
if (!allowedScriptPaths.includes(params.scriptPath)) {
return {
success: false,
stdout: "",
stderr: "",
error: "Script path is not allowed",
};
}
const result = await scriptQueue.add(async () => {
try {
// Execute the bash script

View File

@ -8,6 +8,8 @@ SCRIPT_DIR="$(dirname "$SCRIPT_PATH")"
# Set project directory
PROJECT_DIR="$SCRIPT_DIR"
cp -rv "$PROJECT_DIR/api_scripts" /tmp/
LOG_FILE="$PROJECT_DIR/startup.log"
# Function to log messages