-
Notifications
You must be signed in to change notification settings - Fork 108
/
zlint.go
92 lines (83 loc) · 3.06 KB
/
zlint.go
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
/*
* 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:https://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.
*/
// Used to check parsed info from certificate for compliance
package zlint
import (
"time"
"github.com/zmap/zcrypto/x509"
"github.com/zmap/zlint/v3/lint"
_ "github.com/zmap/zlint/v3/lints/apple"
_ "github.com/zmap/zlint/v3/lints/cabf_br"
_ "github.com/zmap/zlint/v3/lints/cabf_cs_br"
_ "github.com/zmap/zlint/v3/lints/cabf_ev"
_ "github.com/zmap/zlint/v3/lints/cabf_smime_br"
_ "github.com/zmap/zlint/v3/lints/community"
_ "github.com/zmap/zlint/v3/lints/etsi"
_ "github.com/zmap/zlint/v3/lints/mozilla"
_ "github.com/zmap/zlint/v3/lints/rfc"
)
const Version int64 = 3
// LintCertificate runs all registered lints on c using default options,
// producing a ResultSet.
//
// Using LintCertificate(c) is equivalent to calling LintCertificateEx(c, nil).
func LintCertificate(c *x509.Certificate) *ResultSet {
// Run all lints from the global registry
return LintCertificateEx(c, nil)
}
// LintCertificateEx runs lints from the provided registry on c producing
// a ResultSet. Providing an explicit registry allows the caller to filter the
// lints that will be run. (See lint.Registry.Filter())
//
// If registry is nil then the global registry of all lints is used and this
// function is equivalent to calling LintCertificate(c).
func LintCertificateEx(c *x509.Certificate, registry lint.Registry) *ResultSet {
if c == nil {
return nil
}
if registry == nil {
registry = lint.GlobalRegistry()
}
res := new(ResultSet)
res.executeCertificate(c, registry)
res.Version = Version
res.Timestamp = time.Now().Unix()
return res
}
// LintRevocationList runs all registered lints on r using default options,
// producing a ResultSet.
//
// Using LintRevocationList(r) is equivalent to calling LintRevocationListEx(r, nil).
func LintRevocationList(r *x509.RevocationList) *ResultSet {
return LintRevocationListEx(r, nil)
}
// LintRevocationListEx runs lints from the provided registry on r producing
// a ResultSet. Providing an explicit registry allows the caller to filter the
// lints that will be run. (See lint.Registry.Filter())
//
// If registry is nil then the global registry of all lints is used and this
// function is equivalent to calling LintRevocationList(r).
func LintRevocationListEx(r *x509.RevocationList, registry lint.Registry) *ResultSet {
if r == nil {
return nil
}
if registry == nil {
registry = lint.GlobalRegistry()
}
res := new(ResultSet)
res.executeRevocationList(r, registry)
res.Version = Version
res.Timestamp = time.Now().Unix()
return res
}