github.com/zmap/zlint@v1.1.0/lints/lint_qcstatem_mandatory_etsi_statems.go (about) 1 /* 2 * ZLint Copyright 2017 Regents of the University of Michigan 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 * use this file except in compliance with the License. You may obtain a copy 6 * of the License at http://www.apache.org/licenses/LICENSE-2.0 7 * 8 * Unless required by applicable law or agreed to in writing, software 9 * distributed under the License is distributed on an "AS IS" BASIS, 10 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 11 * implied. See the License for the specific language governing 12 * permissions and limitations under the License. 13 */ 14 15 package lints 16 17 import ( 18 "encoding/asn1" 19 "github.com/zmap/zcrypto/x509" 20 "github.com/zmap/zlint/util" 21 ) 22 23 type qcStatemQcmandatoryEtsiStatems struct{} 24 25 func (l *qcStatemQcmandatoryEtsiStatems) Initialize() error { 26 return nil 27 } 28 29 func (l *qcStatemQcmandatoryEtsiStatems) CheckApplies(c *x509.Certificate) bool { 30 if !util.IsExtInCert(c, util.QcStateOid) { 31 return false 32 } 33 if util.IsAnyEtsiQcStatementPresent(util.GetExtFromCert(c, util.QcStateOid).Value) { 34 return true 35 } 36 return false 37 } 38 39 func (l *qcStatemQcmandatoryEtsiStatems) Execute(c *x509.Certificate) *LintResult { 40 errString := "" 41 ext := util.GetExtFromCert(c, util.QcStateOid) 42 43 oidList := make([]*asn1.ObjectIdentifier, 1) 44 oidList[0] = &util.IdEtsiQcsQcCompliance 45 46 for _, oid := range oidList { 47 r := util.ParseQcStatem(ext.Value, *oid) 48 util.AppendToStringSemicolonDelim(&errString, r.GetErrorInfo()) 49 if !r.IsPresent() { 50 util.AppendToStringSemicolonDelim(&errString, "missing mandatory ETSI QC statement") 51 } 52 } 53 54 if len(errString) == 0 { 55 return &LintResult{Status: Pass} 56 } else { 57 return &LintResult{Status: Error, Details: errString} 58 } 59 } 60 61 func init() { 62 RegisterLint(&Lint{ 63 Name: "e_qcstatem_mandatory_etsi_statems", 64 Description: "Checks that a QC Statement that contains at least one of the ETSI ESI statements, also features the set of mandatory ETSI ESI QC statements.", 65 Citation: "ETSI EN 319 412 - 5 V2.2.1 (2017 - 11) / Section 5", 66 Source: EtsiEsi, 67 EffectiveDate: util.EtsiEn319_412_5_V2_2_1_Date, 68 Lint: &qcStatemQcmandatoryEtsiStatems{}, 69 }) 70 }