Skip to content

Commit a781296

Browse files
committed
Rework of comments
Signed-off-by: sabi789 <sabithac6298@gmail.com>
1 parent 2ff902e commit a781296

2 files changed

Lines changed: 26 additions & 26 deletions

File tree

stable-patches/MANIFEST.patch

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,16 @@ index 985d179..2a1cd25 100644
66
tests/quotearray3.sub f
77
tests/quotearray4.sub f
88
tests/quotearray5.sub f
9-
+tests/rbash.tests f
10-
+tests/rbash.right f
9+
+tests/rbash.tests f
10+
+tests/rbash.right f
1111
tests/read.tests f
1212
tests/read.right f
1313
tests/read1.sub f
1414
@@ -1565,6 +1567,7 @@ tests/run-printf f
1515
tests/run-procsub f
1616
tests/run-quote f
1717
tests/run-quotearray f
18-
+tests/run-rbash f
18+
+tests/run-rbash f
1919
tests/run-read f
2020
tests/run-redir f
2121
tests/run-rhs-exp f

stable-patches/tests/rbash_test.patch

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -26,31 +26,31 @@ index 0000000..a9c88cc
2626
+ echo "Testing: $test_name"
2727
+
2828
+ # Run command in rbash and capture exit code
29-
+ rbash -c "$command" 2>/dev/null
29+
+ ${THIS_SH} -r -c "$command" 2>/dev/null
3030
+ local exit_code=$?
3131
+
3232
+ # For restricted operations, we expect non-zero exit code
3333
+ if [ $exit_code -ne 0 ]; then
34-
+ echo " ✓ PASS: Command properly restricted (exit code: $exit_code)"
34+
+ echo " [PASS]: Command properly restricted (exit code: $exit_code)"
3535
+ ((PASSED++))
3636
+ else
37-
+ echo " ✗ FAIL: Command should have been restricted but succeeded"
37+
+ echo " [FAIL]: Command should have been restricted but succeeded"
3838
+ ((FAILED++))
3939
+ fi
4040
+ echo ""
4141
+}
4242
+
4343
+# Test 1: Cannot change directory
44-
+test_restriction "cd restriction" "cd /tmp"
44+
+test_restriction "cd restriction" "cd /"
4545
+
4646
+# Test 2: Cannot modify PATH
4747
+test_restriction "PATH modification" "PATH=/bin:/usr/bin"
4848
+
4949
+# Test 3: Cannot use commands with absolute path
50-
+test_restriction "command with /" "/bin/ls"
50+
+test_restriction "command with /" "/usr/bin/env"
5151
+
5252
+# Test 4: Cannot redirect output
53-
+test_restriction "output redirection" "echo test > /tmp/test.txt"
53+
+test_restriction "output redirection" "echo test > test.txt"
5454
+
5555
+# Test 5: Cannot use exec builtin
5656
+test_restriction "exec builtin" "exec ls"
@@ -59,19 +59,19 @@ index 0000000..a9c88cc
5959
+test_restriction "SHELL modification" "SHELL=/bin/sh"
6060
+
6161
+# Test 7: Cannot modify ENV variable
62-
+test_restriction "ENV modification" "ENV=/tmp/env"
62+
+test_restriction "ENV modification" "ENV=/etc/profile"
6363
+
6464
+# Test 8: Cannot modify BASH_ENV variable
65-
+test_restriction "BASH_ENV modification" "BASH_ENV=/tmp/bashenv"
65+
+test_restriction "BASH_ENV modification" "BASH_ENV=/etc/profile"
6666
+
6767
+# Test 9: Allowed operation - simple echo should work
6868
+echo "Testing: allowed operation (echo)"
69-
+rbash -c "echo 'Hello from rbash'" >/dev/null 2>&1
69+
+${THIS_SH} -r -c "echo 'Hello from rbash'" >/dev/null 2>&1
7070
+if [ $? -eq 0 ]; then
71-
+ echo " ✓ PASS: Allowed command works correctly"
71+
+ echo " [PASS]: Allowed command works correctly"
7272
+ ((PASSED++))
7373
+else
74-
+ echo " ✗ FAIL: Allowed command failed"
74+
+ echo " [FAIL]: Allowed command failed"
7575
+ ((FAILED++))
7676
+fi
7777
+echo ""
@@ -84,10 +84,10 @@ index 0000000..a9c88cc
8484
+echo ""
8585
+
8686
+if [ $FAILED -eq 0 ]; then
87-
+ echo "✓ All rbash restriction tests passed!"
87+
+ echo "[PASS] All rbash restriction tests passed!"
8888
+ exit 0
8989
+else
90-
+ echo "✗ Some rbash restriction tests failed!"
90+
+ echo "[FAIL] Some rbash restriction tests failed!"
9191
+ exit 1
9292
+fi
9393
diff --git a/tests/rbash.right b/tests/rbash.right
@@ -99,38 +99,38 @@ index 0000000..e831f1d
9999
+=== Restricted Bash (rbash) Test Suite ===
100100
+
101101
+Testing: cd restriction
102-
+ ✓ PASS: Command properly restricted (exit code: 1)
102+
+ [PASS]: Command properly restricted (exit code: 1)
103103
+
104104
+Testing: PATH modification
105-
+ ✓ PASS: Command properly restricted (exit code: 1)
105+
+ [PASS]: Command properly restricted (exit code: 1)
106106
+
107107
+Testing: command with /
108-
+ ✓ PASS: Command properly restricted (exit code: 127)
108+
+ [PASS]: Command properly restricted (exit code: 1)
109109
+
110110
+Testing: output redirection
111-
+ ✓ PASS: Command properly restricted (exit code: 1)
111+
+ [PASS]: Command properly restricted (exit code: 1)
112112
+
113113
+Testing: exec builtin
114-
+ ✓ PASS: Command properly restricted (exit code: 1)
114+
+ [PASS]: Command properly restricted (exit code: 1)
115115
+
116116
+Testing: SHELL modification
117-
+ ✓ PASS: Command properly restricted (exit code: 1)
117+
+ [PASS]: Command properly restricted (exit code: 1)
118118
+
119119
+Testing: ENV modification
120-
+ ✓ PASS: Command properly restricted (exit code: 1)
120+
+ [PASS]: Command properly restricted (exit code: 1)
121121
+
122122
+Testing: BASH_ENV modification
123-
+ ✓ PASS: Command properly restricted (exit code: 1)
123+
+ [PASS]: Command properly restricted (exit code: 1)
124124
+
125125
+Testing: allowed operation (echo)
126-
+ ✓ PASS: Allowed command works correctly
126+
+ [PASS]: Allowed command works correctly
127127
+
128128
+=== Test Summary ===
129129
+Total tests: 9
130130
+Passed: 9
131131
+Failed: 0
132132
+
133-
+✓ All rbash restriction tests passed!
133+
+[PASS] All rbash restriction tests passed!
134134
diff --git a/tests/run-rbash b/tests/run-rbash
135135
new file mode 100644
136136
index 0000000..f80b7f2

0 commit comments

Comments
 (0)