-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsecurity_policy.go
More file actions
61 lines (54 loc) · 1.62 KB
/
Copy pathsecurity_policy.go
File metadata and controls
61 lines (54 loc) · 1.62 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
package certkit
import (
"fmt"
"strings"
)
// SecurityPolicy selects an optional strictness profile for transport and
// certificate diagnostics. These are heuristic policy checks, not proof that a
// remote service is operating with a validated cryptographic module.
type SecurityPolicy string
const (
// SecurityPolicyNone disables policy-specific diagnostics.
SecurityPolicyNone SecurityPolicy = ""
// SecurityPolicyFIPS1402 enables a conservative FIPS 140-2 heuristic profile.
SecurityPolicyFIPS1402 SecurityPolicy = "fips-140-2"
// SecurityPolicyFIPS1403 enables a conservative FIPS 140-3 heuristic profile.
SecurityPolicyFIPS1403 SecurityPolicy = "fips-140-3"
)
// Enabled reports whether a policy profile is active.
func (p SecurityPolicy) Enabled() bool {
switch p {
case SecurityPolicyNone:
return false
case SecurityPolicyFIPS1402, SecurityPolicyFIPS1403:
return true
default:
return false
}
}
// DisplayName returns a human-readable label for the selected policy.
func (p SecurityPolicy) DisplayName() string {
switch p {
case SecurityPolicyNone:
return ""
case SecurityPolicyFIPS1402:
return "FIPS 140-2"
case SecurityPolicyFIPS1403:
return "FIPS 140-3"
default:
return ""
}
}
type likelyNotAuthorizedDetailInput struct {
policy SecurityPolicy
singular string
plural string
items []string
}
func formatLikelyNotAuthorizedDetail(input likelyNotAuthorizedDetailInput) string {
noun := input.plural
if len(input.items) == 1 {
noun = input.singular
}
return fmt.Sprintf("%d %s likely not authorized by %s: %s", len(input.items), noun, input.policy.DisplayName(), strings.Join(input.items, ", "))
}