Repository: zmap/zlint
Pull request #315 (2019-09-11 11:39:42)

Fixed two bugs in QcEuLimitValue - QC Statement

zakird: Thanks for getting this fixed up and adding the new unit test. 

Patch:
diff --git a/lints/lint_qcstatem_qclimitvalue_valid.go b/lints/lint_qcstatem_qclimitvalue_valid.go
index 4dac4229..6675ee70 100644
--- a/lints/lint_qcstatem_qclimitvalue_valid.go
+++ b/lints/lint_qcstatem_qclimitvalue_valid.go
@@ -25,7 +25,7 @@ import (
 type qcStatemQcLimitValueValid struct{}
 
 func (this *qcStatemQcLimitValueValid) getStatementOid() *asn1.ObjectIdentifier {
-	return &util.IdEtsiQcsQcSSCD
+	return &util.IdEtsiQcsQcLimitValue
 }
 
 func (l *qcStatemQcLimitValueValid) Initialize() error {
diff --git a/util/qc_stmt.go b/util/qc_stmt.go
index 98ce1fd7..6fb2d4a8 100644
--- a/util/qc_stmt.go
+++ b/util/qc_stmt.go
@@ -98,14 +98,14 @@ type EtsiQcSscd struct {
 }
 
 type EtsiMonetaryValueAlph struct {
-	iso4217CurrencyCodeAlph string `asn1:"printable"`
-	amount                  int
-	exponent                int
+	Iso4217CurrencyCodeAlph string `asn1:"printable"`
+	Amount                  int
+	Exponent                int
 }
 type EtsiMonetaryValueNum struct {
-	iso4217CurrencyCodeNum int
-	amount                 int
-	exponent               int
+	Iso4217CurrencyCodeNum int
+	Amount                 int
+	Exponent               int
 }
 
 type EtsiQcLimitValue struct {
@@ -217,9 +217,9 @@ func ParseQcStatem(extVal []byte, sought asn1.ObjectIdentifier) EtsiQcStmtIf {
 				numErr = true
 			} else {
 				etsiObj.IsNum = true
-				etsiObj.Amount = numeric.amount
-				etsiObj.Exponent = numeric.exponent
-				etsiObj.CurrencyNum = numeric.iso4217CurrencyCodeNum
+				etsiObj.Amount = numeric.Amount
+				etsiObj.Exponent = numeric.Exponent
+				etsiObj.CurrencyNum = numeric.Iso4217CurrencyCodeNum
 
 			}
 			if numErr {
@@ -228,9 +228,9 @@ func ParseQcStatem(extVal []byte, sought asn1.ObjectIdentifier) EtsiQcStmtIf {
 					alphErr = true
 				} else {
 					etsiObj.IsNum = false
-					etsiObj.Amount = alphabetic.amount
-					etsiObj.Exponent = alphabetic.exponent
-					etsiObj.CurrencyAlph = alphabetic.iso4217CurrencyCodeAlph
+					etsiObj.Amount = alphabetic.Amount
+					etsiObj.Exponent = alphabetic.Exponent
+					etsiObj.CurrencyAlph = alphabetic.Iso4217CurrencyCodeAlph
 					AppendToStringSemicolonDelim(&etsiObj.errorInfo,
 						checkAsn1Reencoding(reflect.ValueOf(alphabetic).Interface(),
 							statem.Any.FullBytes, "error with ASN.1 encoding, possibly a wrong ASN.1 string type was used"))


Test patch:
diff --git a/lints/lint_qcstatem_qclimitvalue_valid_test.go b/lints/lint_qcstatem_qclimitvalue_valid_test.go
index 5f8721ab..f275caaa 100644
--- a/lints/lint_qcstatem_qclimitvalue_valid_test.go
+++ b/lints/lint_qcstatem_qclimitvalue_valid_test.go
@@ -19,6 +19,20 @@ import (
 )
 
 func TestQcStatemQcLimitValueValid(t *testing.T) {
+	m := map[string]LintStatus{
+		"QcStmtValidLimitValue.pem": Pass,
+	}
+	for inputPath, expected := range m {
+		inputPath = "../testlint/testCerts/" + inputPath
+		out := Lints["e_qcstatem_qclimitvalue_valid"].Execute(ReadCertificate(inputPath))
+
+		if out.Status != expected {
+			t.Errorf("%s: expected %s, got %s", inputPath, expected, out.Status)
+		}
+	}
+}
+
+func TestQcStatemQcLimitValueInvalid(t *testing.T) {
 	m := map[string]LintStatus{
 		"QcStmtInvalidLimitValue.pem": Error,
 	}
diff --git a/testlint/testCerts/QcStmtInvalidLimitValue.pem b/testlint/testCerts/QcStmtInvalidLimitValue.pem
index 53ee3a57..9ec76e69 100644
--- a/testlint/testCerts/QcStmtInvalidLimitValue.pem
+++ b/testlint/testCerts/QcStmtInvalidLimitValue.pem
@@ -1,45 +1,31 @@
 -----BEGIN CERTIFICATE-----
-MIIH9DCCBdygAwIBAgIUSdoOEheYrV3jVyQ92o9dT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BwQA
+jkYBBgEGBwQAjkYBBgIGBwQAjkYBBgMwDQYJKoZIhvcNAQELBQADggEBAA8lmEyM
+7xm8yG1G33tJh0jcY6GnLoVlkC4cl/1Hx2eYXWC+6LCL8L1rvNYRohivRKNNu/Vt
+GHsSeKqfdGCMxvJIyryu1yGxS5mJwn+/vLFx3Lx/cP2/FtdXE1pgtvsbmIMQlrx5
+BsFlaRKWZZA3PmGI4pVFUO8CHIp4KU/fE3pN+kSGfJnDapF1E6wmlrfUWuIe99if
+OzElsnYnxDGFIvn0irbcO3Iwc3+kOVxZFmNLkLWNPOxCEZXXs8GvQmQEkrWhFc0O
+1E7Dsy0m5mBEMyivLIjumfkY1fOmVOO7kmdnAvvv0kAbnwENAof7Zzdjt7wAnwN9
+EIUG5Vh3vVneLWg=
+-----END CERTIFICATE-----
\ No newline at end of file
diff --git a/testlint/testCerts/QcStmtValidLimitValue.pem b/testlint/testCerts/QcStmtValidLimitValue.pem
new file mode 100644
index 00000000..b59615ef
--- /dev/null
+++ b/testlint/testCerts/QcStmtValidLimitValue.pem
@@ -0,0 +1,31 @@
+-----BEGIN CERTIFICATE-----
+MIIFRjCCBC6gAwIBAgIMHv2nPE8W61evcLlPMA0GCSqGSIb3DQEBCwUAMEAxCzAJ
+BgNVBAYTAlBLMRQwEgYDVQQKEwtEZXZlbG9wbWVudDEbMBkGA1UEAxMSRGV2ZWxv
+cG1lbnQgU3ViIENBMB4XDTE5MDkyNTA5MzExOFoXDTI5MTAyNjA5MzExOFowgYEx
+CzAJBgNVBAYTAlBLMRQwEgYDVQQKEwtEZXZlbG9wbWVudDESMBAGA1UEBRMJNTc4
+NjExNjc1MRcwFQYDVQQqEw5NdWhhbW1hZCBCaWxhbDEPMA0GA1UEBBMGQXNocmFm
+MR4wHAYDVQQDExVNdWhhbW1hZCBCaWxhbCBBc2hyYWYwggEiMA0GCSqGSIb3DQEB
+AQUAA4IBDwAwggEKAoIBAQD+aEoTA2HVDA9a/mrarw+x5VyjEyHFooyKl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