You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
if command_lower.starts_with("sudo") || command_lower.contains(" sudo "){
268
+
returnformat!(
269
+
"Command blocked: '{}'\nReason: Contains 'sudo' which requires privilege escalation.\nSofos only allows read-only operations for security.",
270
+
command
271
+
);
272
+
}
273
+
274
+
// Parent directory traversal
275
+
if command.contains(".."){
276
+
returnformat!(
277
+
"Command blocked: '{}'\nReason: Contains '..' (parent directory traversal).\nAll operations must stay within the current workspace directory.",
278
+
command
279
+
);
280
+
}
281
+
282
+
// Directory change commands
283
+
let directory_commands = ["cd","pushd","popd"];
284
+
for cmd in&directory_commands {
285
+
if command_lower.starts_with(cmd)
286
+
|| command_lower.contains(&format!(" {}", cmd))
287
+
|| command_lower.contains(&format!(";{}", cmd))
288
+
|| command_lower.contains(&format!("&&{}", cmd))
289
+
|| command_lower.contains(&format!("||{}", cmd))
290
+
|| command_lower.contains(&format!("|{}", cmd))
291
+
{
292
+
returnformat!(
293
+
"Command blocked: '{}'\nReason: Contains '{}' which changes the working directory.\nDirectory changes are not allowed for security. Use absolute paths from the workspace root instead.",
294
+
command, cmd
295
+
);
296
+
}
297
+
}
298
+
299
+
// Absolute paths
300
+
if command.starts_with('/') || command.contains(" /")
// Check for specific dangerous git operations and provide helpful feedback
369
+
if command_lower.contains("git push"){
370
+
returnformat!(
371
+
"Command blocked: '{}'\nReason: 'git push' sends data to remote repositories (network operation).\nAllowed: Use 'git status', 'git log', 'git diff' to view changes.",
372
+
command
373
+
);
374
+
}
375
+
376
+
if command_lower.contains("git pull") || command_lower.contains("git fetch"){
377
+
returnformat!(
378
+
"Command blocked: '{}'\nReason: '{}' fetches data from remote repositories (network operation).\nAllowed: Use 'git status', 'git log', 'git diff' to view local changes.",
379
+
command,
380
+
if command_lower.contains("git pull"){"git pull"} else {"git fetch"}
381
+
);
382
+
}
383
+
384
+
if command_lower.contains("git clone"){
385
+
returnformat!(
386
+
"Command blocked: '{}'\nReason: 'git clone' downloads repositories (network operation and creates directories).\nClone repositories manually outside of Sofos.",
387
+
command
388
+
);
389
+
}
390
+
391
+
if command_lower.contains("git commit") || command_lower.contains("git add"){
392
+
returnformat!(
393
+
"Command blocked: '{}'\nReason: '{}' modifies the git repository.\nAllowed: Use 'git status', 'git diff' to view changes. Create commits manually.",
394
+
command,
395
+
if command_lower.contains("git commit"){"git commit"} else {"git add"}
396
+
);
397
+
}
398
+
399
+
if command_lower.contains("git reset") || command_lower.contains("git clean"){
400
+
returnformat!(
401
+
"Command blocked: '{}'\nReason: '{}' is a destructive operation that discards changes.\nAllowed: Use 'git status', 'git log', 'git diff' to view repository state.",
402
+
command,
403
+
if command_lower.contains("git reset"){"git reset"} else {"git clean"}
404
+
);
405
+
}
406
+
407
+
if command_lower.contains("git checkout") || command_lower.contains("git switch"){
408
+
returnformat!(
409
+
"Command blocked: '{}'\nReason: '{}' changes branches or modifies working directory.\nAllowed: Use 'git branch' to list branches, 'git status' to see current branch.",
410
+
command,
411
+
if command_lower.contains("git checkout"){"git checkout"} else {"git switch"}
412
+
);
413
+
}
414
+
415
+
if command_lower.contains("git merge") || command_lower.contains("git rebase"){
416
+
returnformat!(
417
+
"Command blocked: '{}'\nReason: '{}' modifies git history and repository state.\nPerform merges/rebases manually outside of Sofos.",
418
+
command,
419
+
if command_lower.contains("git merge"){"git merge"} else {"git rebase"}
"Command blocked: '{}'\nReason: 'git stash' (without list/show) modifies repository state.\nAllowed: Use 'git stash list' or 'git stash show' to view stashed changes.",
426
+
command
427
+
);
428
+
}
429
+
430
+
if command_lower.contains("git remote add") || command_lower.contains("git remote set-url"){
431
+
returnformat!(
432
+
"Command blocked: '{}'\nReason: Modifying git remotes could redirect pushes to unauthorized servers.\nAllowed: Use 'git remote -v' to view configured remotes.",
433
+
command
434
+
);
435
+
}
436
+
437
+
if command_lower.contains("git submodule"){
438
+
returnformat!(
439
+
"Command blocked: '{}'\nReason: 'git submodule' can fetch from remote repositories (network operation).\nManage submodules manually outside of Sofos.",
0 commit comments