| 1 |
package community |
| 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 SubjectDNTrailingSpace struct{} |
| 24 |
|
| 25 |
func init() { |
| 26 |
lint.RegisterCertificateLint(&lint.CertificateLint{ |
| 27 |
LintMetadata: lint.LintMetadata{ |
| 28 |
Name: "w_subject_dn_trailing_whitespace", |
| 29 |
Description: "AttributeValue in subject RelativeDistinguishedName sequence SHOULD NOT have trailing whitespace", |
| 30 |
Citation: "lint.AWSLabs certlint", |
| 31 |
Source: lint.Community, |
| 32 |
EffectiveDate: util.ZeroDate, |
| 33 |
}, |
| 34 |
Lint: NewSubjectDNTrailingSpace, |
| 35 |
}) |
| 36 |
} |
| 37 |
|
| 38 |
func NewSubjectDNTrailingSpace() lint.LintInterface { |
| 39 |
return &SubjectDNTrailingSpace{} |
| 40 |
} |
| 41 |
|
| 42 |
func (l *SubjectDNTrailingSpace) CheckApplies(c *x509.Certificate) bool { |
| 43 |
return true |
| 44 |
} |
| 45 |
|
| 46 |
func (l *SubjectDNTrailingSpace) Execute(c *x509.Certificate) *lint.LintResult { |
| 47 |
_, trailing, err := util.CheckRDNSequenceWhiteSpace(c.RawSubject) |
| 48 |
if err != nil { |
| 49 |
return &lint.LintResult{Status: lint.Fatal} |
| 50 |
} |
| 51 |
if trailing { |
| 52 |
return &lint.LintResult{Status: lint.Warn} |
| 53 |
} |
| 54 |
return &lint.LintResult{Status: lint.Pass} |
| 55 |
} |