@@ -85,106 +85,110 @@ func (d distributionPoint) FullNames() []string {
8585type Extension struct {
8686 Name string `json:"-"`
8787 Details []string `json:"-"`
88- json map [string ]interface {}
88+ json map [string ]any
8989}
9090
9191func (e * Extension ) MarshalJSON () ([]byte , error ) {
9292 return json .Marshal (e .json )
9393}
9494
95- func (e * Extension ) AddDetailf (format string , args ... interface {} ) {
95+ func (e * Extension ) AddDetailf (format string , args ... any ) {
9696 e .Details = append (e .Details , fmt .Sprintf (format , args ... ))
9797}
9898
99+ func (e * Extension ) AddDetail (detail string ) {
100+ e .Details = append (e .Details , detail )
101+ }
102+
99103func newExtension (e pkix.Extension ) Extension {
100104 var ext Extension
101105 switch {
102106 case e .Id .Equal (oidExtensionReasonCode ):
103107 ext .Name = "X509v3 CRL Reason Code:"
104108 value := parseReasonCode (e .Value )
105- ext .AddDetailf (value )
106- ext .json = map [string ]interface {} {
109+ ext .AddDetail (value )
110+ ext .json = map [string ]any {
107111 "crl_reason_code" : value ,
108112 }
109113
110114 case e .Id .Equal (oidExtensionCRLNumber ):
111115 ext .Name = "X509v3 CRL Number:"
112116 var n * big.Int
113117 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 {
116120 "crl_number" : n .String (),
117121 }
118122 } 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 {
121125 "crl_number" : e .Value ,
122126 }
123127 }
124128
125129 case e .Id .Equal (oidExtensionAuthorityKeyID ):
126130 var v authorityKeyID
127131 ext .Name = "X509v3 Authority Key Identifier:"
128- ext .json = map [string ]interface {} {
132+ ext .json = map [string ]any {
129133 "authority_key_id" : hex .EncodeToString (e .Value ),
130134 }
131135 if _ , err := asn1 .Unmarshal (e .Value , & v ); err == nil {
132136 var s string
133137 for _ , b := range v .ID {
134138 s += fmt .Sprintf (":%02X" , b )
135139 }
136- ext .AddDetailf ("keyid" + s )
140+ ext .AddDetail ("keyid" + s )
137141 } else {
138- ext .AddDetailf (sanitizeBytes (e .Value ))
142+ ext .AddDetail (sanitizeBytes (e .Value ))
139143 }
140144 case e .Id .Equal (oidExtensionIssuingDistributionPoint ):
141145 ext .Name = "X509v3 Issuing Distribution Point:"
142146
143147 var v distributionPoint
144148 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 {
147151 "issuing_distribution_point" : e .Value ,
148152 }
149153 } else {
150154 names := v .FullNames ()
151155 if len (names ) > 0 {
152- ext .AddDetailf ("Full Name:" )
156+ ext .AddDetail ("Full Name:" )
153157 for _ , n := range names {
154- ext .AddDetailf (" " + n )
158+ ext .AddDetail (" " + n )
155159 }
156160 }
157- js := map [string ]interface {} {
161+ js := map [string ]any {
158162 "full_names" : names ,
159163 }
160164
161165 // Only one of this should be set to true. But for inspect we
162166 // will allow more than one.
163167 if v .OnlyContainsUserCerts {
164- ext .AddDetailf ("Only User Certificates" )
168+ ext .AddDetail ("Only User Certificates" )
165169 js ["only_user_certificates" ] = true
166170 }
167171 if v .OnlyContainsCACerts {
168- ext .AddDetailf ("Only CA Certificates" )
172+ ext .AddDetail ("Only CA Certificates" )
169173 js ["only_ca_certificates" ] = true
170174 }
171175 if v .OnlyContainsAttributeCerts {
172- ext .AddDetailf ("Only Attribute Certificates" )
176+ ext .AddDetail ("Only Attribute Certificates" )
173177 js ["only_attribute_certificates" ] = true
174178 }
175179 if len (v .OnlySomeReasons .Bytes ) > 0 {
176180 ext .AddDetailf ("Reasons: %x" , v .OnlySomeReasons .Bytes )
177181 js ["only_some_reasons" ] = v .OnlySomeReasons .Bytes
178182 }
179183
180- ext .json = map [string ]interface {} {
184+ ext .json = map [string ]any {
181185 "issuing_distribution_point" : js ,
182186 }
183187 }
184188 default :
185189 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 {
188192 ext .Name : e .Value ,
189193 }
190194 }
0 commit comments