Repository: zmap/zlint
Pull request #311 (2019-08-24 11:43:25)

allow single quotes in subjects
https://github.com/zmap/zlint/pull/309 missed the single quote character in its regex of valid characters. This PR fixes the regex and adds a test case. This PR addresses the comment here: https://github.com/zmap/zlint/pull/309#discussion_r317297206


Patch:
diff --git a/lints/lint_subject_printable_string_badalpha.go b/lints/lint_subject_printable_string_badalpha.go
index b60e76f6..764e6950 100644
--- a/lints/lint_subject_printable_string_badalpha.go
+++ b/lints/lint_subject_printable_string_badalpha.go
@@ -30,7 +30,7 @@ var (
 	//   character set: the lowercase letters 'a' through 'z', uppercase
 	//   letters 'A' through 'Z', the digits '0' through '9', eleven special
 	//   characters ' = ( ) + , - . / : ? and space.
-	printableStringRegex = regexp.MustCompile(`^[a-zA-Z0-9\=\(\)\+,\-.\/:\? ]+$`)
+	printableStringRegex = regexp.MustCompile(`^[a-zA-Z0-9\=\(\)\+,\-.\/:\? ']+$`)
 )
 
 // validatePrintableString returns an error if the provided encoded printable


Test patch:
diff --git a/lints/lint_subject_printable_string_badalpha_test.go b/lints/lint_subject_printable_string_badalpha_test.go
index e993eaf5..514c1d72 100644
--- a/lints/lint_subject_printable_string_badalpha_test.go
+++ b/lints/lint_subject_printable_string_badalpha_test.go
@@ -20,6 +20,15 @@ func TestSubjectPrintableStringBadAlpha(t *testing.T) {
 				Status: Pass,
 			},
 		},
+		{
+			name: "valid subject with single quote",
+			// A RawSubject containing 8 PrintableString attributes all adhering to
+			// the expected character set.
+			filename: "subjectWithSingleQuote.pem",
+			expected: LintResult{
+				Status: Pass,
+			},
+		},
 		{
 			name: "invalid subj. CN PrintableString",
 			// A RawSubject containing a single PrintableString attribute (OID
diff --git a/testlint/testCerts/subjectWithSingleQuote.pem b/testlint/testCerts/subjectWithSingleQuote.pem
new file mode 100644
index 00000000..1f0bbee7
--- /dev/null
+++ b/testlint/testCerts/subjectWithSingleQuote.pem
@@ -0,0 +1,32 @@
+-----BEGIN CERTIFICATE-----
+MIIFjTCCBHWgAwIBAgIQD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