summaryrefslogtreecommitdiff
path: root/tests/e2e/arg_integrity_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'tests/e2e/arg_integrity_test.go')
-rw-r--r--tests/e2e/arg_integrity_test.go45
1 files changed, 45 insertions, 0 deletions
diff --git a/tests/e2e/arg_integrity_test.go b/tests/e2e/arg_integrity_test.go
new file mode 100644
index 0000000..7121c2b
--- /dev/null
+++ b/tests/e2e/arg_integrity_test.go
@@ -0,0 +1,45 @@
+package e2e
+
+import (
+ "fmt"
+ "os/exec"
+ "strings"
+ "testing"
+)
+
+func TestArgumentIntegrity(t *testing.T) {
+ payloads := []string{
+ "$(whoami)",
+ "; rm -rf /",
+ "`id`",
+ "| wall 'hacked'",
+ "\"'\"'\"", // Complex quoting
+ " spaced argument ",
+ "$\nnewline",
+ }
+
+ for _, payload := range payloads {
+ t.Run(fmt.Sprintf("Payload_%s", payload), func(t *testing.T) {
+ binaryPath := GetBinaryPath()
+ cmd := exec.Command(binaryPath, "test-args", payload)
+ out, err := cmd.CombinedOutput()
+ if err != nil {
+ t.Fatalf("wg-wrap test-args failed for payload %s: %v\nOutput: %s", payload, err, string(out))
+ }
+
+ lines := strings.Split(strings.TrimSpace(string(out)), "\n")
+ if len(lines) < 3 {
+ t.Fatalf("Unexpected output format for payload %s\nOutput: %s", payload, string(out))
+ }
+
+ parts := strings.Split(lines[len(lines)-1], ":")
+ if len(parts) < 2 {
+ t.Fatalf("Malformed hex line for payload %s: %s", payload, lines[len(lines)-1])
+ }
+
+ if parts[1] != fmt.Sprintf("%x", payload) {
+ t.Errorf("8-bit mismatch!\nSent Hex: %s\nRecv Hex: %s\nPayload: %q", fmt.Sprintf("%x", payload), parts[1], payload)
+ }
+ })
+ }
+}