File tree Expand file tree Collapse file tree 12 files changed +0
-20
lines changed
apps/sim/app/api/tools/ssh Expand file tree Collapse file tree 12 files changed +0
-20
lines changed Original file line number Diff line number Diff line change @@ -30,7 +30,6 @@ export async function POST(request: NextRequest) {
3030 const body = await request . json ( )
3131 const params = CheckCommandExistsSchema . parse ( body )
3232
33- // Validate SSH authentication
3433 if ( ! params . password && ! params . privateKey ) {
3534 return NextResponse . json (
3635 { error : 'Either password or privateKey must be provided' } ,
Original file line number Diff line number Diff line change @@ -49,7 +49,6 @@ export async function POST(request: NextRequest) {
4949 const body = await request . json ( )
5050 const params = CheckFileExistsSchema . parse ( body )
5151
52- // Validate SSH authentication
5352 if ( ! params . password && ! params . privateKey ) {
5453 return NextResponse . json (
5554 { error : 'Either password or privateKey must be provided' } ,
Original file line number Diff line number Diff line change @@ -37,7 +37,6 @@ export async function POST(request: NextRequest) {
3737 const body = await request . json ( )
3838 const params = CreateDirectorySchema . parse ( body )
3939
40- // Validate SSH authentication
4140 if ( ! params . password && ! params . privateKey ) {
4241 return NextResponse . json (
4342 { error : 'Either password or privateKey must be provided' } ,
@@ -60,7 +59,6 @@ export async function POST(request: NextRequest) {
6059 const dirPath = sanitizePath ( params . path )
6160 const escapedPath = escapeShellArg ( dirPath )
6261
63- // Check if directory already exists
6462 const checkResult = await executeSSHCommand (
6563 client ,
6664 `test -d '${ escapedPath } ' && echo "exists"`
@@ -77,7 +75,6 @@ export async function POST(request: NextRequest) {
7775 } )
7876 }
7977
80- // Create directory
8178 const mkdirFlag = params . recursive ? '-p' : ''
8279 const command = `mkdir ${ mkdirFlag } -m ${ params . permissions } '${ escapedPath } '`
8380 const result = await executeSSHCommand ( client , command )
Original file line number Diff line number Diff line change @@ -37,7 +37,6 @@ export async function POST(request: NextRequest) {
3737 const body = await request . json ( )
3838 const params = DeleteFileSchema . parse ( body )
3939
40- // Validate SSH authentication
4140 if ( ! params . password && ! params . privateKey ) {
4241 return NextResponse . json (
4342 { error : 'Either password or privateKey must be provided' } ,
@@ -60,7 +59,6 @@ export async function POST(request: NextRequest) {
6059 const filePath = sanitizePath ( params . path )
6160 const escapedPath = escapeShellArg ( filePath )
6261
63- // Check if path exists
6462 const checkResult = await executeSSHCommand (
6563 client ,
6664 `test -e '${ escapedPath } ' && echo "exists"`
@@ -69,7 +67,6 @@ export async function POST(request: NextRequest) {
6967 return NextResponse . json ( { error : `Path does not exist: ${ filePath } ` } , { status : 404 } )
7068 }
7169
72- // Build delete command
7370 let command : string
7471 if ( params . recursive ) {
7572 command = params . force ? `rm -rf '${ escapedPath } '` : `rm -r '${ escapedPath } '`
Original file line number Diff line number Diff line change @@ -44,7 +44,6 @@ export async function POST(request: NextRequest) {
4444 const body = await request . json ( )
4545 const params = DownloadFileSchema . parse ( body )
4646
47- // Validate SSH authentication
4847 if ( ! params . password && ! params . privateKey ) {
4948 return NextResponse . json (
5049 { error : 'Either password or privateKey must be provided' } ,
Original file line number Diff line number Diff line change @@ -31,7 +31,6 @@ export async function POST(request: NextRequest) {
3131 const body = await request . json ( )
3232 const params = ExecuteCommandSchema . parse ( body )
3333
34- // Validate SSH authentication
3534 if ( ! params . password && ! params . privateKey ) {
3635 return NextResponse . json (
3736 { error : 'Either password or privateKey must be provided' } ,
@@ -51,7 +50,6 @@ export async function POST(request: NextRequest) {
5150 } )
5251
5352 try {
54- // Build command with optional working directory
5553 let command = sanitizeCommand ( params . command )
5654 if ( params . workingDirectory ) {
5755 command = `cd "${ params . workingDirectory } " && ${ command } `
Original file line number Diff line number Diff line change @@ -32,7 +32,6 @@ export async function POST(request: NextRequest) {
3232 const body = await request . json ( )
3333 const params = ExecuteScriptSchema . parse ( body )
3434
35- // Validate SSH authentication
3635 if ( ! params . password && ! params . privateKey ) {
3736 return NextResponse . json (
3837 { error : 'Either password or privateKey must be provided' } ,
@@ -52,13 +51,10 @@ export async function POST(request: NextRequest) {
5251 } )
5352
5453 try {
55- // Create a temporary script file, execute it, and clean up
5654 const scriptPath = `/tmp/sim_script_${ requestId } .sh`
5755 const escapedScriptPath = escapeShellArg ( scriptPath )
5856 const escapedInterpreter = escapeShellArg ( params . interpreter )
5957
60- // Build the command to create, execute, and clean up the script
61- // Note: heredoc with quoted delimiter ('SIMEOF') prevents variable expansion
6258 let command = `cat > '${ escapedScriptPath } ' << 'SIMEOF'
6359${ params . script }
6460SIMEOF
Original file line number Diff line number Diff line change @@ -29,7 +29,6 @@ export async function POST(request: NextRequest) {
2929 const body = await request . json ( )
3030 const params = GetSystemInfoSchema . parse ( body )
3131
32- // Validate SSH authentication
3332 if ( ! params . password && ! params . privateKey ) {
3433 return NextResponse . json (
3534 { error : 'Either password or privateKey must be provided' } ,
Original file line number Diff line number Diff line change @@ -70,7 +70,6 @@ export async function POST(request: NextRequest) {
7070 const body = await request . json ( )
7171 const params = ListDirectorySchema . parse ( body )
7272
73- // Validate SSH authentication
7473 if ( ! params . password && ! params . privateKey ) {
7574 return NextResponse . json (
7675 { error : 'Either password or privateKey must be provided' } ,
Original file line number Diff line number Diff line change @@ -45,7 +45,6 @@ export async function POST(request: NextRequest) {
4545 const body = await request . json ( )
4646 const params = ReadFileContentSchema . parse ( body )
4747
48- // Validate SSH authentication
4948 if ( ! params . password && ! params . privateKey ) {
5049 return NextResponse . json (
5150 { error : 'Either password or privateKey must be provided' } ,
You can’t perform that action at this time.
0 commit comments