-
-
Notifications
You must be signed in to change notification settings - Fork 102
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c2852a5
commit a5e7ada
Showing
5 changed files
with
65 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -71,3 +71,5 @@ test( | |
protocol: 'tap', | ||
depends: test_schemas | ||
) | ||
|
||
subdir('tests') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
/* | ||
* SPDX-License-Identifier: GPL-3.0-or-later | ||
* SPDX-FileCopyrightText: 2024 elementary, Inc. (https://elementary.io) | ||
*/ | ||
|
||
private void main (string[] args) { | ||
Test.init (ref args); | ||
|
||
Test.add_func ("/valid", () => { | ||
string msg; | ||
|
||
// false positive for su | ||
assert (Terminal.Utils.is_safe_paste ("suspend", out msg)); | ||
}); | ||
|
||
Test.add_func ("/invalid", () => { | ||
string msg; | ||
|
||
// Elevated permissions | ||
assert (!Terminal.Utils.is_safe_paste ("doas pacman -Syu", out msg)); | ||
assert (!Terminal.Utils.is_safe_paste ("pkexec visudo", out msg)); | ||
assert (!Terminal.Utils.is_safe_paste ("run0 --nice=19 my-task-with-low-priority", out msg)); | ||
assert (!Terminal.Utils.is_safe_paste ("su username", out msg)); | ||
assert (!Terminal.Utils.is_safe_paste ("sudo apt autoremove", out msg)); | ||
|
||
// Multi-line commands | ||
assert (!Terminal.Utils.is_safe_paste ("\n", out msg)); | ||
assert (!Terminal.Utils.is_safe_paste ("&", out msg)); | ||
assert (!Terminal.Utils.is_safe_paste ("|", out msg)); | ||
assert (!Terminal.Utils.is_safe_paste (";", out msg)); | ||
}); | ||
|
||
Test.run (); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
unsafe_paste_test = executable( | ||
'UnsafePasteTest', | ||
'UnsafePasteTest.vala', | ||
meson.project_source_root() / 'src' / 'Utils.vala', | ||
dependencies: [ | ||
glib_dep, | ||
gtk_dep | ||
], | ||
install: false | ||
) | ||
|
||
test('UnsafePaste Test', unsafe_paste_test) |