-
Notifications
You must be signed in to change notification settings - Fork 110
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
Add lint for checking that a CRL contains the CRL Number extension #834
Merged
christopher-henderson
merged 36 commits into
zmap:master
from
defacto64:e_crl_missing_crl_number
Apr 28, 2024
Merged
Changes from 35 commits
Commits
Show all changes
36 commits
Select commit
Hold shift + click to select a range
0d4a7d5
Add files via upload
defacto64 9ae1760
Add files via upload
defacto64 c66f6f6
Add files via upload
defacto64 3bd2334
Add files via upload
defacto64 95e89c8
Update lint_invalid_subject_rdn_order_test.go
defacto64 7230486
Update lint_invalid_subject_rdn_order.go
defacto64 983a0df
Merge branch 'master' into master
christopher-henderson 36682ed
Update v3/lints/cabf_br/lint_invalid_subject_rdn_order.go
defacto64 fc81ece
Update lint_invalid_subject_rdn_order.go
defacto64 9e54f08
Update lint_invalid_subject_rdn_order_test.go
defacto64 e61235c
Merge branch 'master' into master
defacto64 8ca486a
Update time.go
defacto64 1df8c9b
Add files via upload
defacto64 ae29a40
Add files via upload
defacto64 9f657b2
Merge branch 'zmap:master' into master
defacto64 faa938d
Revised according to Chris and Corey suggestions
defacto64 d2aa5b1
Add files via upload
defacto64 b827d18
Add files via upload
defacto64 89e0ed1
Merge branch 'zmap:master' into master
defacto64 e2f2f0e
Delete v3/lints/cabf_br/lint_e_invalid_cps_uri.go
defacto64 126e1ac
Delete v3/lints/cabf_br/lint_e_invalid_cps_uri_test.go
defacto64 a7fbe52
Delete v3/testdata/invalid_cps_uri_ko_01.pem
defacto64 b289660
Delete v3/testdata/invalid_cps_uri_ko_02.pem
defacto64 b5af6be
Delete v3/testdata/invalid_cps_uri_ko_03.pem
defacto64 d9fea03
Delete v3/testdata/invalid_cps_uri_ok_01.pem
defacto64 a324160
Delete v3/testdata/invalid_cps_uri_ok_02.pem
defacto64 9ef6f60
Delete v3/testdata/invalid_cps_uri_ok_03.pem
defacto64 949d3ca
Merge branch 'master' into master
christopher-henderson c827e99
Merge branch 'zmap:master' into master
defacto64 e0e1bdf
Add files via upload
defacto64 86ef81d
Add files via upload
defacto64 2c70763
Add files via upload
defacto64 782ea66
Add files via upload
defacto64 14203a3
Update oid.go
defacto64 9366be3
Merge branch 'master' into e_crl_missing_crl_number
christopher-henderson 281aeba
Update v3/util/oid.go
christopher-henderson File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
/* | ||
* ZLint Copyright 2024 Regents of the University of Michigan | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not | ||
* use this file except in compliance with the License. You may obtain a copy | ||
* of the License at http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or | ||
* implied. See the License for the specific language governing | ||
* permissions and limitations under the License. | ||
*/ | ||
|
||
/* | ||
* Contributed by Adriano Santoni <adriano.santoni@staff.aruba.it> | ||
* of ACTALIS S.p.A. (www.actalis.com). | ||
*/ | ||
|
||
package rfc | ||
|
||
import ( | ||
"github.com/zmap/zcrypto/x509" | ||
"github.com/zmap/zlint/v3/lint" | ||
"github.com/zmap/zlint/v3/util" | ||
) | ||
|
||
func init() { | ||
lint.RegisterRevocationListLint(&lint.RevocationListLint{ | ||
LintMetadata: lint.LintMetadata{ | ||
Name: "e_crl_missing_crl_number", | ||
Description: "CRL issuers conforming to this profile MUST include this extension in all CRLs", | ||
Citation: "RFC5280 §5.2.3", | ||
Source: lint.RFC5280, | ||
EffectiveDate: util.RFC5280Date, | ||
}, | ||
Lint: NewMissingCRLNumber, | ||
}) | ||
} | ||
|
||
type missingCRLNumber struct{} | ||
|
||
func NewMissingCRLNumber() lint.RevocationListLintInterface { | ||
return &missingCRLNumber{} | ||
} | ||
|
||
func (l *missingCRLNumber) CheckApplies(c *x509.RevocationList) bool { | ||
return true | ||
} | ||
|
||
func (l *missingCRLNumber) Execute(c *x509.RevocationList) *lint.LintResult { | ||
for _, e := range c.Extensions { | ||
if e.Id.Equal(util.CRLNumberOID) { | ||
return &lint.LintResult{Status: lint.Pass} | ||
} | ||
} | ||
|
||
return &lint.LintResult{ | ||
Status: lint.Error, | ||
Details: "This CRL lacks the mandatory CRL Number extension", | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
/* | ||
* ZLint Copyright 2024 Regents of the University of Michigan | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not | ||
* use this file except in compliance with the License. You may obtain a copy | ||
* of the License at http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or | ||
* implied. See the License for the specific language governing | ||
* permissions and limitations under the License. | ||
*/ | ||
|
||
package rfc | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/zmap/zlint/v3/lint" | ||
"github.com/zmap/zlint/v3/test" | ||
) | ||
|
||
func TestMissingCRLNumberOK(t *testing.T) { | ||
inputPath := "crl_missing_crl_number_ok.pem" | ||
expected := lint.Pass | ||
out := test.TestRevocationListLint(t, "e_crl_missing_crl_number", inputPath) | ||
if out.Status != expected { | ||
t.Errorf("%s: expected %s, got %s", inputPath, expected, out.Status) | ||
} | ||
} | ||
|
||
func TestMissingCRLNumberKO(t *testing.T) { | ||
inputPath := "crl_missing_crl_number_ko.pem" | ||
expected := lint.Error | ||
out := test.TestRevocationListLint(t, "e_crl_missing_crl_number", inputPath) | ||
if out.Status != expected { | ||
t.Errorf("%s: expected %s, got %s", inputPath, expected, out.Status) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
-----BEGIN X509 CRL----- | ||
MIIBojCBiwIBATANBgkqhkiG9w0BAQsFADBDMQswCQYDVQQGEwJFVTEQMA4GA1UE | ||
ChMHU29tZSBDQTEiMCAGA1UEAxMZRmFrZSBDQSBmb3IgemxpbnQgdGVzdGluZxcN | ||
MjQwNDE4MDcyMDM0WhcNMjQwNDE5MDcyMDM0WqAUMBIwEAYDVR0jBAkwB4AFAQID | ||
BAUwDQYJKoZIhvcNAQELBQADggEBAItG2rOL7KnlKCOnEwZh1DUMGb1R9MGamQse | ||
Yz+XLuP6MOAVlZno/61Jjea4uKQWSPdTX6jE7BTW67CFFlnFLQLu7PODd6pSvqRo | ||
hvw4LrI5y/+FeIqkwGNxQKyxYUdLfC8ybouKgQF4S0l31oAeW61fQ4QVh2bNU4y7 | ||
EdgODmwnsIjhaCOSVh25CnEG4V/XdbZQhQjl/S/C6Emd2tFHjyRdxAk+dEdJhAJV | ||
4p6PFGXlapyEjb+lTSTy/Tub4hrVEJiQsVgLXSsZRZBBrtRow68SSwCyEzLD6OZt | ||
fjVl4W3Tkio7dudTEHvlLSmoXB7SFVIRZ79KChryyPorrjijRNA= | ||
-----END X509 CRL----- | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
-----BEGIN X509 CRL----- | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
MIIBrzCBmAIBATANBgkqhkiG9w0BAQsFADBDMQswCQYDVQQGEwJFVTEQMA4GA1UE | ||
ChMHU29tZSBDQTEiMCAGA1UEAxMZRmFrZSBDQSBmb3IgemxpbnQgdGVzdGluZxcN | ||
MjQwNDE4MDcxOTA5WhcNMjQwNDE5MDcxOTA5WqAhMB8wEAYDVR0jBAkwB4AFAQID | ||
BAUwCwYDVR0UBAQCAhI0MA0GCSqGSIb3DQEBCwUAA4IBAQBKeHtcc4thnELs6EiQ | ||
Cm/BvDmbz6k4F0jBEV/vMbSomp0+lrM8mJDpyos/cU+Ug8EWgS2/789ujm+aHPEJ | ||
84A66/lmg77/iJZFwTtgOURSBbMmaEeFLpZy1ZJRbGOgn2c1SxHcd7m4Hb1BfTe1 | ||
yCFanjwX6aB7RWDXFKlpZ77VGvLTqX36MbEWaiifMdmrH+wQ22njDi9PT0qMScNv | ||
2vZ4s4f9tjQLxWnr+mqeeZhU4wa0uv98SWzoSzx+0gdLsPeYyw7ethYonPu9kNsM | ||
6DEBZ6i1QjzilR8aIYKZ3JOB4PY7McMjI9iJIJp71hoXAZsiFbhKeydq+VppBzxf | ||
BquN | ||
-----END X509 CRL----- | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just to keep consistent with the rest of our test certs which print the human readable version.
For reference, I got this via OpenSSL.