| 1 |
package rfc |
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
import ( |
| 18 |
"github.com/zmap/zcrypto/x509" |
| 19 |
"github.com/zmap/zlint/v3/lint" |
| 20 |
"github.com/zmap/zlint/v3/util" |
| 21 |
) |
| 22 |
|
| 23 |
type nameConstraintMax struct{} |
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
|
| 33 |
|
| 34 |
|
| 35 |
|
| 36 |
func init() { |
| 37 |
lint.RegisterCertificateLint(&lint.CertificateLint{ |
| 38 |
LintMetadata: lint.LintMetadata{ |
| 39 |
Name: "e_name_constraint_maximum_not_absent", |
| 40 |
Description: "Within the name constraints name form, the maximum field is not used and therefore MUST be absent", |
| 41 |
Citation: "RFC 5280: 4.2.1.10", |
| 42 |
Source: lint.RFC5280, |
| 43 |
EffectiveDate: util.RFC2459Date, |
| 44 |
}, |
| 45 |
Lint: NewNameConstraintMax, |
| 46 |
}) |
| 47 |
} |
| 48 |
|
| 49 |
func NewNameConstraintMax() lint.LintInterface { |
| 50 |
return &nameConstraintMax{} |
| 51 |
} |
| 52 |
|
| 53 |
func (l *nameConstraintMax) CheckApplies(c *x509.Certificate) bool { |
| 54 |
return util.IsExtInCert(c, util.NameConstOID) |
| 55 |
} |
| 56 |
|
| 57 |
|
| 58 |
func (l *nameConstraintMax) Execute(c *x509.Certificate) *lint.LintResult { |
| 59 |
for _, i := range c.PermittedDNSNames { |
| 60 |
if i.Max != 0 { |
| 61 |
return &lint.LintResult{Status: lint.Error} |
| 62 |
} |
| 63 |
} |
| 64 |
for _, i := range c.ExcludedDNSNames { |
| 65 |
if i.Max != 0 { |
| 66 |
return &lint.LintResult{Status: lint.Error} |
| 67 |
} |
| 68 |
} |
| 69 |
for _, i := range c.PermittedDNSNames { |
| 70 |
if i.Max != 0 { |
| 71 |
return &lint.LintResult{Status: lint.Error} |
| 72 |
} |
| 73 |
} |
| 74 |
for _, i := range c.ExcludedEmailAddresses { |
| 75 |
if i.Max != 0 { |
| 76 |
return &lint.LintResult{Status: lint.Error} |
| 77 |
} |
| 78 |
} |
| 79 |
for _, i := range c.PermittedIPAddresses { |
| 80 |
if i.Max != 0 { |
| 81 |
return &lint.LintResult{Status: lint.Error} |
| 82 |
} |
| 83 |
} |
| 84 |
for _, i := range c.ExcludedIPAddresses { |
| 85 |
if i.Max != 0 { |
| 86 |
return &lint.LintResult{Status: lint.Error} |
| 87 |
} |
| 88 |
} |
| 89 |
for _, i := range c.PermittedDirectoryNames { |
| 90 |
if i.Max != 0 { |
| 91 |
return &lint.LintResult{Status: lint.Error} |
| 92 |
} |
| 93 |
} |
| 94 |
for _, i := range c.ExcludedDirectoryNames { |
| 95 |
if i.Max != 0 { |
| 96 |
return &lint.LintResult{Status: lint.Error} |
| 97 |
} |
| 98 |
} |
| 99 |
for _, i := range c.PermittedEdiPartyNames { |
| 100 |
if i.Max != 0 { |
| 101 |
return &lint.LintResult{Status: lint.Error} |
| 102 |
} |
| 103 |
} |
| 104 |
for _, i := range c.ExcludedEdiPartyNames { |
| 105 |
if i.Max != 0 { |
| 106 |
return &lint.LintResult{Status: lint.Error} |
| 107 |
} |
| 108 |
} |
| 109 |
for _, i := range c.PermittedRegisteredIDs { |
| 110 |
if i.Max != 0 { |
| 111 |
return &lint.LintResult{Status: lint.Error} |
| 112 |
} |
| 113 |
} |
| 114 |
for _, i := range c.ExcludedRegisteredIDs { |
| 115 |
if i.Max != 0 { |
| 116 |
return &lint.LintResult{Status: lint.Error} |
| 117 |
} |
| 118 |
} |
| 119 |
for _, i := range c.PermittedX400Addresses { |
| 120 |
if i.Max != 0 { |
| 121 |
return &lint.LintResult{Status: lint.Error} |
| 122 |
} |
| 123 |
} |
| 124 |
for _, i := range c.ExcludedX400Addresses { |
| 125 |
if i.Max != 0 { |
| 126 |
return &lint.LintResult{Status: lint.Error} |
| 127 |
} |
| 128 |
} |
| 129 |
return &lint.LintResult{Status: lint.Pass} |
| 130 |
} |