Γ–ffentliche Dateiansicht: Raw-Dateien, Tree, Releases und Issues sind ohne Login verfΓΌgbar.
global/global_test.go
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
package global

import "testing"

// ─── safeLogPath ─────────────────────────────────────────────────────────────

func TestSafeLogPath_Valid(t *testing.T) {
	cases := []string{
		"./log/noxway.log",
		"/var/log/noxway.log",
		"/app/log/gateway.log",
		"log/access.log",
		"/tmp/noxway.log",
	}
	for _, p := range cases {
		if !safeLogPath(p) {
			t.Errorf("expected %q to be a safe path", p)
		}
	}
}

func TestSafeLogPath_Traversal(t *testing.T) {
	cases := []string{
		"../../etc/passwd",
		"../secret.log",
		"/app/../../../etc/cron.d/evil",
		"log/../../etc/shadow",
		"./../outside.log",
	}
	for _, p := range cases {
		if safeLogPath(p) {
			t.Errorf("expected %q to be rejected as unsafe path", p)
		}
	}
}
Sprachen
Go 46%
JavaScript 45%
Markdown 3.3%
HTML 2.5%
YAML 1.7%
JSON 1.1%
Klonen
HTTPS