Skip to content

Commit 6f0d850

Browse files
committed
revised the score value based on observation of one *or more* url(s) or one email(s) found; unit tests update accordingly
1 parent 29707c2 commit 6f0d850

2 files changed

Lines changed: 23 additions & 35 deletions

File tree

checks/evaluation/security_policy.go

Lines changed: 6 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -52,30 +52,18 @@ func scoreSecurityCriteria(f checker.File, info []checker.SecurityPolicyInformat
5252
Text: "",
5353
}
5454

55-
// #1: found one linked (email/http) content: score += 3
56-
// rationale: someone to collaborate with or link to
57-
// information (strong for community)
58-
if urls >= 1 || emails >= 1 {
59-
score += 3
55+
// #1: more than one unique (email/http) linked content found: score += 6
56+
// rationale: if more than one link, even stronger for the community
57+
if (urls + emails) > 0 {
58+
score += 6
6059
msg.Text = "Found linked content in security policy"
6160
dl.Info(&msg)
6261
} else {
6362
msg.Text = "no email or URL found in security policy"
6463
dl.Warn(&msg)
6564
}
6665

67-
// #2: more than one unique (email/http) linked content found: score += 3
68-
// rationale: if more than one link, even stronger for the community
69-
if (urls + emails) > 1 {
70-
score += 3
71-
msg.Text = "Found multiple linked content in security policy"
72-
dl.Info(&msg)
73-
} else {
74-
msg.Text = "Only one email or URL (if any) found in security policy"
75-
dl.Warn(&msg)
76-
}
77-
78-
// #3: more bytes than the sum of the length of all the linked content found: score += 3
66+
// #2: more bytes than the sum of the length of all the linked content found: score += 3
7967
// rationale: there appears to be information and context around those links
8068
// no credit if there is just a link to a site or an email address (those given above)
8169
// the test here is that each piece of linked content will likely contain a space
@@ -89,7 +77,7 @@ func scoreSecurityCriteria(f checker.File, info []checker.SecurityPolicyInformat
8977
dl.Warn(&msg)
9078
}
9179

92-
// #4: found whole number(s) and or match(es) to "Disclos" and or "Vuln": score += 1
80+
// #3: found whole number(s) and or match(es) to "Disclos" and or "Vuln": score += 1
9381
// rationale: works towards the intent of the security policy file
9482
// regarding whom to contact about vuls and disclosures and timing
9583
// e.g., we'll disclose, report a vulnerabily, 30 days, etc.

checks/security_policy_test.go

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -44,20 +44,20 @@ func TestSecurityPolicy(t *testing.T) {
4444
},
4545
want: scut.TestReturn{
4646
Score: 10,
47-
NumberOfInfo: 5,
47+
NumberOfInfo: 4,
4848
NumberOfWarn: 0,
4949
},
5050
},
5151
{
5252
name: ".github/security.md",
53-
path: "./testdata/securitypolicy/07_realworld",
53+
path: "./testdata/securitypolicy/10_realworldtwo",
5454
files: []string{
5555
".github/security.md",
5656
},
5757
want: scut.TestReturn{
58-
Score: 7,
58+
Score: 10,
5959
NumberOfInfo: 4,
60-
NumberOfWarn: 1,
60+
NumberOfWarn: 0,
6161
},
6262
},
6363
{
@@ -69,7 +69,7 @@ func TestSecurityPolicy(t *testing.T) {
6969
want: scut.TestReturn{
7070
Score: 4,
7171
NumberOfInfo: 3,
72-
NumberOfWarn: 2,
72+
NumberOfWarn: 1,
7373
},
7474
},
7575
{
@@ -81,31 +81,31 @@ func TestSecurityPolicy(t *testing.T) {
8181
want: scut.TestReturn{
8282
Score: 3,
8383
NumberOfInfo: 2,
84-
NumberOfWarn: 3,
84+
NumberOfWarn: 2,
8585
},
8686
},
8787
{
8888
name: ".github/security.rst",
89-
path: "./testdata/securitypolicy/03_urlOnly",
89+
path: "./testdata/securitypolicy/06_urlOnly",
9090
files: []string{
9191
".github/security.rst",
9292
},
9393
want: scut.TestReturn{
94-
Score: 3,
94+
Score: 6,
9595
NumberOfInfo: 2,
96-
NumberOfWarn: 3,
96+
NumberOfWarn: 2,
9797
},
9898
},
9999
{
100100
name: "docs/security.rst",
101-
path: "./testdata/securitypolicy/03_emailOnly",
101+
path: "./testdata/securitypolicy/06_emailOnly",
102102
files: []string{
103103
"docs/security.rst",
104104
},
105105
want: scut.TestReturn{
106-
Score: 3,
106+
Score: 6,
107107
NumberOfInfo: 2,
108-
NumberOfWarn: 3,
108+
NumberOfWarn: 2,
109109
},
110110
},
111111
{
@@ -116,7 +116,7 @@ func TestSecurityPolicy(t *testing.T) {
116116
},
117117
want: scut.TestReturn{
118118
Score: 6,
119-
NumberOfInfo: 3,
119+
NumberOfInfo: 2,
120120
NumberOfWarn: 2,
121121
},
122122
},
@@ -128,7 +128,7 @@ func TestSecurityPolicy(t *testing.T) {
128128
},
129129
want: scut.TestReturn{
130130
Score: 9,
131-
NumberOfInfo: 4,
131+
NumberOfInfo: 3,
132132
NumberOfWarn: 1,
133133
},
134134
},
@@ -140,7 +140,7 @@ func TestSecurityPolicy(t *testing.T) {
140140
},
141141
want: scut.TestReturn{
142142
Score: 10,
143-
NumberOfInfo: 5,
143+
NumberOfInfo: 4,
144144
NumberOfWarn: 0,
145145
},
146146
},
@@ -153,7 +153,7 @@ func TestSecurityPolicy(t *testing.T) {
153153
want: scut.TestReturn{
154154
Score: 0,
155155
NumberOfInfo: 1,
156-
NumberOfWarn: 4,
156+
NumberOfWarn: 3,
157157
},
158158
},
159159
{
@@ -165,7 +165,7 @@ func TestSecurityPolicy(t *testing.T) {
165165
want: scut.TestReturn{
166166
Score: 0,
167167
NumberOfInfo: 1,
168-
NumberOfWarn: 4,
168+
NumberOfWarn: 3,
169169
},
170170
},
171171
}

0 commit comments

Comments
 (0)