Skip to content

Commit

Permalink
Enhance unsafe detection (#800)
Browse files Browse the repository at this point in the history
Not the cleanest. Can always define "more" dangerous behaviours, depends how much we want to get in the weeds.
I need to learn more vala

contains:
Multiple commands: as oneliners chained with ";", "||", "|", "&&", "&"

Admin commands: run0, su, pkexec, who serve similar purpose to sudo and doas. "su -" can do a lot too
Add a space, to avoid false flag if say, it is a word like "visual" that has "su" in it. A command needs a space after it.

Co-authored-by: Jeremy Wootten <jeremywootten@gmail.com>
  • Loading branch information
teamcons and jeremypw authored Dec 6, 2024
1 parent c5cfbcd commit e1a34f7
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/Widgets/TerminalWidget.vala
Original file line number Diff line number Diff line change
Expand Up @@ -536,10 +536,11 @@ namespace Terminal {
return;
}


string? warn_text = null;
if ("\n" in text) {
if ("\n" in text || "&" in text || "|" in text || ";" in text ) {
warn_text = _("The pasted text may contain multiple commands");
} else if ("sudo" in text || "doas" in text) {
} else if ("sudo " in text || "doas " in text || "run0 " in text || "pkexec " in text || "su " in text) {
warn_text = _("The pasted text may be trying to gain administrative access");
}

Expand Down

0 comments on commit e1a34f7

Please sign in to comment.