@@ -85,106 +85,110 @@ func (d distributionPoint) FullNames() []string {
85
85
type Extension struct {
86
86
Name string `json:"-"`
87
87
Details []string `json:"-"`
88
- json map [string ]interface {}
88
+ json map [string ]any
89
89
}
90
90
91
91
func (e * Extension ) MarshalJSON () ([]byte , error ) {
92
92
return json .Marshal (e .json )
93
93
}
94
94
95
- func (e * Extension ) AddDetailf (format string , args ... interface {} ) {
95
+ func (e * Extension ) AddDetailf (format string , args ... any ) {
96
96
e .Details = append (e .Details , fmt .Sprintf (format , args ... ))
97
97
}
98
98
99
+ func (e * Extension ) AddDetail (detail string ) {
100
+ e .Details = append (e .Details , detail )
101
+ }
102
+
99
103
func newExtension (e pkix.Extension ) Extension {
100
104
var ext Extension
101
105
switch {
102
106
case e .Id .Equal (oidExtensionReasonCode ):
103
107
ext .Name = "X509v3 CRL Reason Code:"
104
108
value := parseReasonCode (e .Value )
105
- ext .AddDetailf (value )
106
- ext .json = map [string ]interface {} {
109
+ ext .AddDetail (value )
110
+ ext .json = map [string ]any {
107
111
"crl_reason_code" : value ,
108
112
}
109
113
110
114
case e .Id .Equal (oidExtensionCRLNumber ):
111
115
ext .Name = "X509v3 CRL Number:"
112
116
var n * big.Int
113
117
if _ , err := asn1 .Unmarshal (e .Value , & n ); err == nil {
114
- ext .AddDetailf (n .String ())
115
- ext .json = map [string ]interface {} {
118
+ ext .AddDetail (n .String ())
119
+ ext .json = map [string ]any {
116
120
"crl_number" : n .String (),
117
121
}
118
122
} else {
119
- ext .AddDetailf (sanitizeBytes (e .Value ))
120
- ext .json = map [string ]interface {} {
123
+ ext .AddDetail (sanitizeBytes (e .Value ))
124
+ ext .json = map [string ]any {
121
125
"crl_number" : e .Value ,
122
126
}
123
127
}
124
128
125
129
case e .Id .Equal (oidExtensionAuthorityKeyID ):
126
130
var v authorityKeyID
127
131
ext .Name = "X509v3 Authority Key Identifier:"
128
- ext .json = map [string ]interface {} {
132
+ ext .json = map [string ]any {
129
133
"authority_key_id" : hex .EncodeToString (e .Value ),
130
134
}
131
135
if _ , err := asn1 .Unmarshal (e .Value , & v ); err == nil {
132
136
var s string
133
137
for _ , b := range v .ID {
134
138
s += fmt .Sprintf (":%02X" , b )
135
139
}
136
- ext .AddDetailf ("keyid" + s )
140
+ ext .AddDetail ("keyid" + s )
137
141
} else {
138
- ext .AddDetailf (sanitizeBytes (e .Value ))
142
+ ext .AddDetail (sanitizeBytes (e .Value ))
139
143
}
140
144
case e .Id .Equal (oidExtensionIssuingDistributionPoint ):
141
145
ext .Name = "X509v3 Issuing Distribution Point:"
142
146
143
147
var v distributionPoint
144
148
if _ , err := asn1 .Unmarshal (e .Value , & v ); err != nil {
145
- ext .AddDetailf (sanitizeBytes (e .Value ))
146
- ext .json = map [string ]interface {} {
149
+ ext .AddDetail (sanitizeBytes (e .Value ))
150
+ ext .json = map [string ]any {
147
151
"issuing_distribution_point" : e .Value ,
148
152
}
149
153
} else {
150
154
names := v .FullNames ()
151
155
if len (names ) > 0 {
152
- ext .AddDetailf ("Full Name:" )
156
+ ext .AddDetail ("Full Name:" )
153
157
for _ , n := range names {
154
- ext .AddDetailf (" " + n )
158
+ ext .AddDetail (" " + n )
155
159
}
156
160
}
157
- js := map [string ]interface {} {
161
+ js := map [string ]any {
158
162
"full_names" : names ,
159
163
}
160
164
161
165
// Only one of this should be set to true. But for inspect we
162
166
// will allow more than one.
163
167
if v .OnlyContainsUserCerts {
164
- ext .AddDetailf ("Only User Certificates" )
168
+ ext .AddDetail ("Only User Certificates" )
165
169
js ["only_user_certificates" ] = true
166
170
}
167
171
if v .OnlyContainsCACerts {
168
- ext .AddDetailf ("Only CA Certificates" )
172
+ ext .AddDetail ("Only CA Certificates" )
169
173
js ["only_ca_certificates" ] = true
170
174
}
171
175
if v .OnlyContainsAttributeCerts {
172
- ext .AddDetailf ("Only Attribute Certificates" )
176
+ ext .AddDetail ("Only Attribute Certificates" )
173
177
js ["only_attribute_certificates" ] = true
174
178
}
175
179
if len (v .OnlySomeReasons .Bytes ) > 0 {
176
180
ext .AddDetailf ("Reasons: %x" , v .OnlySomeReasons .Bytes )
177
181
js ["only_some_reasons" ] = v .OnlySomeReasons .Bytes
178
182
}
179
183
180
- ext .json = map [string ]interface {} {
184
+ ext .json = map [string ]any {
181
185
"issuing_distribution_point" : js ,
182
186
}
183
187
}
184
188
default :
185
189
ext .Name = e .Id .String ()
186
- ext .AddDetailf (sanitizeBytes (e .Value ))
187
- ext .json = map [string ]interface {} {
190
+ ext .AddDetail (sanitizeBytes (e .Value ))
191
+ ext .json = map [string ]any {
188
192
ext .Name : e .Value ,
189
193
}
190
194
}
0 commit comments