Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update single email if present #808

Merged
Merged
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
6c23670
lint about the encoding of qcstatements for PSD2
Feb 4, 2020
4666bb7
Revert "lint about the encoding of qcstatements for PSD2"
Feb 4, 2020
01996c6
Merge https://github.com/zmap/zlint
Aug 26, 2020
28481cc
Merge https://github.com/zmap/zlint
Sep 1, 2021
749d896
Merge https://github.com/zmap/zlint
Oct 21, 2021
e56e2a0
util: gtld_map autopull updates for 2021-10-21T07:25:20 UTC
web-flow Oct 21, 2021
8600050
Merge pull request #1 from mtgag/zlint-gtld-update
mtgag Oct 21, 2021
30b096e
Merge https://github.com/zmap/zlint
mtgag Apr 19, 2023
92e659c
always check and perform the operation in the execution
mtgag Apr 27, 2023
351a379
Merge branch 'master' into master
christopher-henderson May 14, 2023
b52111b
Merge https://github.com/zmap/zlint
mtgag May 16, 2023
526f9be
Merge https://github.com/zmap/zlint
mtgag Jun 9, 2023
92902fc
Merge https://github.com/zmap/zlint
mtgag Jul 1, 2023
1652cfa
synchronised with project
mtgag Jul 5, 2023
d4f2f9f
synchronised with project
mtgag Aug 30, 2023
88c933e
Merge https://github.com/zmap/zlint
mtgag Aug 30, 2023
cee805f
Merge https://github.com/zmap/zlint
mtgag Dec 3, 2023
2408543
synchronised with project
mtgag Dec 14, 2023
67537e9
synchronised with project
mtgag Dec 14, 2023
e77fae1
synchronised with project
mtgag Jan 24, 2024
51d498f
synchronised with project
mtgag Feb 13, 2024
31e1845
Merge https://github.com/zmap/zlint
mtgag Feb 25, 2024
2c3b27a
added same lint for subject values instead of SAN values
mtgag Feb 25, 2024
ccfd13d
resolved conflict issue
mtgag Feb 25, 2024
c285b53
Merge branch 'master' into update_single_email_subject_if_present
christopher-henderson Feb 25, 2024
0648260
Merge branch 'master' into update_single_email_subject_if_present
christopher-henderson Feb 25, 2024
632fda5
addressed review comments and hint to citation from #795
mtgag Feb 29, 2024
f0fa0ef
Merge branch 'update_single_email_subject_if_present' of https://gith…
mtgag Feb 29, 2024
dd340e5
addressing issue #795 and review comments of PR #802
mtgag Mar 1, 2024
7e73f1d
Merge branch 'master' into update_single_email_if_present
christopher-henderson Mar 17, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 26 additions & 13 deletions v3/lints/cabf_smime_br/lint_single_email_if_present.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,33 @@ import (
"github.com/zmap/zlint/v3/util"
)

/*************************************************************************
7.1.4.2.1 Subject alternative name extension

All Mailbox Addresses in the subject field or entries of type dirName of this extension SHALL be
repeated as rfc822Name or otherName values of type id-on-SmtpUTF8Mailbox in this
extension.

7.1.4.2.2 Subject distinguished name fields

h. Certificate Field: subject:emailAddress (1.2.840.113549.1.9.1) Contents: If present, the
subject:emailAddress SHALL contain a single Mailbox Address as verified under
Section 3.2.2.

Combining these requirements, this lint checks for malformed email addresses in SAN entries
covering the case of a non-single Mailbox Address.
*************************************************************************/

func init() {
lint.RegisterCertificateLint(&lint.CertificateLint{
LintMetadata: lint.LintMetadata{
Name: "e_single_email_if_present",
Description: "If present, the subject:emailAddress SHALL contain a single Mailbox Address",
Citation: "7.1.4.2.h",
Description: "If present, the subject:emailAddress SHALL contain a single Mailbox Address. All Mailbox Addresses in the subject field SHALL be repeated as rfc822Name or otherName values of type id-on-SmtpUTF8Mailbox in SAN extension.",
Citation: "7.1.4.2.1 and 7.1.4.2.2.h",
Source: lint.CABFSMIMEBaselineRequirements,
EffectiveDate: util.CABF_SMIME_BRs_1_0_0_Date,
},
Lint: func() lint.LintInterface { return &singleEmailIfPresent{} },
Lint: NewSingleEmailIfPresent,
})
}

Expand All @@ -43,22 +60,18 @@ func NewSingleEmailIfPresent() lint.LintInterface {
}

func (l *singleEmailIfPresent) CheckApplies(c *x509.Certificate) bool {
return util.IsSubscriberCert(c) && c.EmailAddresses != nil && len(c.EmailAddresses) != 0 && util.IsSMIMEBRCertificate(c)
addresses := c.EmailAddresses
return util.IsSubscriberCert(c) && addresses != nil && len(addresses) != 0 && util.IsSMIMEBRCertificate(c)
}

func (l *singleEmailIfPresent) Execute(c *x509.Certificate) *lint.LintResult {
for _, email := range c.EmailAddresses {
_, err := mail.ParseAddress(email)
if err != nil {
if _, err := mail.ParseAddress(email); err != nil {
return &lint.LintResult{
Status: lint.Error,
Details: fmt.Sprintf("subject:emailAddress was present and contained an invalid email address (%s)", email),
LintMetadata: lint.LintMetadata{},
Status: lint.Error,
Details: fmt.Sprintf("san:emailAddress was present and contained an invalid email address (%s)", email),
}
}
}

return &lint.LintResult{
Status: lint.Pass,
}
return &lint.LintResult{Status: lint.Pass}
}
Loading