github.com/zmap/zlint@v1.1.0/lints/lint_qcstatem_etsi_present_qcs_critical.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 qcStatemQcEtsiPresentQcsCritical struct{} 24 25 func (this *qcStatemQcEtsiPresentQcsCritical) getStatementOid() *asn1.ObjectIdentifier { 26 return &util.IdEtsiQcsQcCompliance 27 } 28 29 func (l *qcStatemQcEtsiPresentQcsCritical) Initialize() error { 30 return nil 31 } 32 33 func (l *qcStatemQcEtsiPresentQcsCritical) CheckApplies(c *x509.Certificate) bool { 34 if !util.IsExtInCert(c, util.QcStateOid) { 35 return false 36 } 37 if util.IsAnyEtsiQcStatementPresent(util.GetExtFromCert(c, util.QcStateOid).Value) { 38 return true 39 } 40 return false 41 } 42 43 func (l *qcStatemQcEtsiPresentQcsCritical) Execute(c *x509.Certificate) *LintResult { 44 errString := "" 45 ext := util.GetExtFromCert(c, util.QcStateOid) 46 if ext.Critical { 47 errString = "ETSI QC Statement is present and QC Statements extension is marked critical" 48 } 49 50 if len(errString) == 0 { 51 return &LintResult{Status: Pass} 52 } else { 53 return &LintResult{Status: Error, Details: errString} 54 } 55 } 56 57 func init() { 58 RegisterLint(&Lint{ 59 Name: "e_qcstatem_etsi_present_qcs_critical", 60 Description: "Checks that a QC Statement which contains any of the id-etsi-qcs-... QC Statements is not marked critical", 61 Citation: "ETSI EN 319 412 - 5 V2.2.1 (2017 - 11) / Section 4.1", 62 Source: EtsiEsi, 63 EffectiveDate: util.EtsiEn319_412_5_V2_2_1_Date, 64 Lint: &qcStatemQcEtsiPresentQcsCritical{}, 65 }) 66 }