-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdocs_security_test.go
More file actions
100 lines (89 loc) · 2.74 KB
/
Copy pathdocs_security_test.go
File metadata and controls
100 lines (89 loc) · 2.74 KB
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
package secrets_sync_test
import (
"os"
"strings"
"testing"
)
func TestSecurityDocsDocumentLoggingContract(t *testing.T) {
required := []string{
"raw secret values",
"raw Vault secret",
"raw AWS secret",
"raw client structures",
"machine-readable `secrets-sync pipeline --output json` result envelopes redact",
"GitHub Actions annotation output escapes workflow-command data",
}
for _, path := range []string{"docs/SECURITY.md", "docs/OBSERVABILITY.md"} {
content, err := os.ReadFile(path)
if err != nil {
t.Fatalf("read %s: %v", path, err)
}
text := strings.ToLower(strings.Join(strings.Fields(string(content)), " "))
for _, phrase := range required {
if !strings.Contains(text, strings.ToLower(phrase)) {
t.Fatalf("%s must document logging contract phrase %q", path, phrase)
}
}
}
}
func TestSecurityDocsUseProjectReportingContacts(t *testing.T) {
required := []string{
"https://github.com/jbcom/secrets-sync/security/advisories",
"security@jbcom.dev",
}
for _, path := range []string{"SECURITY.md", "docs/SECURITY.md"} {
content, err := os.ReadFile(path)
if err != nil {
t.Fatalf("read %s: %v", path, err)
}
text := string(content)
if strings.Contains(text, "robert@lestak.sh") {
t.Fatalf("%s should not use the old fork-era security contact", path)
}
for _, phrase := range required {
if !strings.Contains(text, phrase) {
t.Fatalf("%s must document reporting contact %q", path, phrase)
}
}
}
}
func TestPublicUsageDocsDoNotUseForkEraOwners(t *testing.T) {
for _, path := range []string{"docs/USAGE.md"} {
content, err := os.ReadFile(path)
if err != nil {
t.Fatalf("read %s: %v", path, err)
}
text := string(content)
for _, forbidden := range []string{
"robertlestak",
"vault-secret-sync",
} {
if strings.Contains(text, forbidden) {
t.Fatalf("%s should not use fork-era owner or package identifier %q", path, forbidden)
}
}
}
}
func TestSecurityPolicyDocumentsCurrentMajorOnly(t *testing.T) {
content, err := os.ReadFile("SECURITY.md")
if err != nil {
t.Fatalf("read SECURITY.md: %v", err)
}
text := string(content)
if !strings.Contains(text, "| 2.x") {
t.Fatalf("SECURITY.md should document current 2.x support")
}
for _, oldVersion := range []string{"| 1.2.x", "| 1.1.x", "| 1.0.x"} {
if strings.Contains(text, oldVersion) {
t.Fatalf("SECURITY.md should not advertise old support line %q", oldVersion)
}
}
for _, oldExample := range []string{"1.2.1", "1.2.2"} {
if strings.Contains(text, oldExample) {
t.Fatalf("SECURITY.md should not use unsupported 1.x patch example %q", oldExample)
}
}
if !strings.Contains(text, "2.0.1") || !strings.Contains(text, "2.0.2") {
t.Fatalf("SECURITY.md should use a supported 2.x patch-release example")
}
}