Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

QCP-N-QSCD 411 1(411 2), 412-2 and 412 5 #129

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

breynders-cb
Copy link

@breynders-cb breynders-cb commented Oct 28, 2024

As previously mentioned in #124, a first PR which extends pkilint with QCP-N-QSCD for 411-1 (with restrictions of 411-2), 412-2 and 412-5.

I did my best in maintaining the existing structure of everything, please let me know where you'd want changes and we'll use this PR to get everything aligned as much as possible.

I've generated certificates as integration tests to validate most (or all) rules that I've added as part of the qcp-n-qscd profile.

Additionally:

  • I did not add tests, what's the testing policy? I see there's a lot of integration tests and I'm wondering if you have some tool/project set up that can already easily generate all these certificates in the right (i.e. wrong) format. If not I'll start building something for ourselves to generate some test cases for these types (but will take a bit).
  • For etsi the finding_metadata.csv seems to be empty, I tried to document all the sources (and changes) but is it on the roadmap to fill in that csv?

And some further questions inlined ⬇️

Comment on lines +371 to 375
# PR Question: Is this from 415_5.qcs-4.2? Needs different classifier?
allowances[en_319_412_5.id_etsi_qcs_QcCClegislation] = Rfc2119Word.MUST
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was wondering what the source was for this rule. I couldn't really find it other than the reference in 412-5 QCS 4.2. If so, would it need a different source in the validation finding?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See table 1A in EN 319 412 5, clause 4.2.1. The CCLegislation statement is needed for certs that are qualified but not in the EU.

@breynders-cb breynders-cb force-pushed the qcp-n-qscd-411-1(412-2)-and-412-5 branch from 0929950 to 0e59ab3 Compare October 29, 2024 12:48
@breynders-cb breynders-cb changed the title QCP-N-QSCD 411 1(412 2) and 412 5 QCP-N-QSCD 411 1(411 2) and 412 5 Oct 29, 2024
@breynders-cb breynders-cb force-pushed the qcp-n-qscd-411-1(412-2)-and-412-5 branch 2 times, most recently from e06fa2d to 6567785 Compare October 30, 2024 16:11
@breynders-cb breynders-cb changed the title QCP-N-QSCD 411 1(411 2) and 412 5 QCP-N-QSCD 411 1(411 2), 412-2 and 412 5 Oct 30, 2024
@breynders-cb breynders-cb force-pushed the qcp-n-qscd-411-1(412-2)-and-412-5 branch from 6567785 to caa9f65 Compare November 1, 2024 15:23
@breynders-cb breynders-cb marked this pull request as ready for review November 1, 2024 15:25
@breynders-cb
Copy link
Author

Moved to ready-for-review since the ETSI rules are now considered feature-complete from my end (and I'm going to shift towards implementing the POR rules now), looking forward to the feedback!

@CBonnell
Copy link
Collaborator

CBonnell commented Nov 4, 2024

Thank you this great contribution, @breynders-cb! I'm currently traveling for work this week, but will review this PR fully when I return next week.

As for the test case generation, we use der-ascii to generate test artifacts. It has a bit of learning curve to use, but quite powerful and flexible. The test case file format is the PEM text of the artifact followed by the CSV-formatted output of findings. This makes it relatively simple to write test case generation scripts.

We originally did not flesh out the ETSI finding_metadata.csv file, as the ETSI linter references the citation directly in the finding codes. We can certainly flesh out that file if that would be helpful. We are planning to revamp and improve the documentation for findings as part of #64, but haven't had the cycles yet do to so.

@breynders-cb
Copy link
Author

Thank you this great contribution, @breynders-cb! I'm currently traveling for work this week, but will review this PR fully when I return next week.

As for the test case generation, we use der-ascii to generate test artifacts. It has a bit of learning curve to use, but quite powerful and flexible. The test case file format is the PEM text of the artifact followed by the CSV-formatted output of findings. This makes it relatively simple to write test case generation scripts.

We originally did not flesh out the ETSI finding_metadata.csv file, as the ETSI linter references the citation directly in the finding codes. We can certainly flesh out that file if that would be helpful. We are planning to revamp and improve the documentation for findings as part of #64, but haven't had the cycles yet do to so.

Great, thanks! I'll add der-ascii to my list of tools, for now I spruced up some of our test code and generated test certificates through bouncy castle so all new rules should have tests in the PEM+csv format.

@breynders-cb breynders-cb force-pushed the qcp-n-qscd-411-1(412-2)-and-412-5 branch from caa9f65 to a0295ea Compare November 11, 2024 09:29
@breynders-cb breynders-cb force-pushed the qcp-n-qscd-411-1(412-2)-and-412-5 branch from a0295ea to dd6e770 Compare November 11, 2024 09:37
Copy link
Collaborator

@CBonnell CBonnell left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this contribution! Overall, I think this PR is in pretty good shape. I added some comments for relatively minor things.

In regard to the development of test cases, do you plan on adding more, or should I assist in creating them?

@@ -27,6 +27,7 @@ class CertificateType(enum.IntEnum):
QNCP_W_GEN_LEGAL_PERSON_NON_EIDAS_PRE_CERTIFICATE = auto()
QEVCP_W_PSD2_EIDAS_PRE_CERTIFICATE = auto()
QEVCP_W_PSD2_EIDAS_NON_BROWSER_PRE_CERTIFICATE = auto()
QCP_N_QSCD_PRE_CERTIFICATE = auto()
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Certificate Transparency for eSig/eSeal certs likely will not be a thing for a long time (if ever), so I think this type can be removed. That being said, we can keep it if we see value in having it.

@@ -256,6 +266,10 @@ def from_option_str(value):

NON_EU_QWAC_TYPES = QWAC_TYPES - EU_QWAC_TYPES

EU_SSCD = QCP_N_QSCD_CERTIFICATE_TYPES
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: rename to EU_SSCD_TYPES to match naming convention of other certificate type sets

@@ -256,6 +266,10 @@ def from_option_str(value):

NON_EU_QWAC_TYPES = QWAC_TYPES - EU_QWAC_TYPES

EU_SSCD = QCP_N_QSCD_CERTIFICATE_TYPES

EU = EU_QWAC_TYPES | EU_SSCD
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: rename to EU_TYPES to match naming convention of other certificate type sets

certificate.tbsCertificate.issuer.rdnSequence,LegalPersonIssuerAttributeAllowanceValidator,ERROR,etsi.en_319_412_2.gen-4.2.3.1-2.country_attribute_absent,
certificate.tbsCertificate.issuer.rdnSequence,LegalPersonIssuerAttributeAllowanceValidator,ERROR,etsi.en_319_412_2.gen-4.2.3.1-2.common_name_attribute_absent,
certificate.tbsCertificate.issuer.rdnSequence,LegalPersonIssuerAttributeAllowanceValidator,ERROR,etsi.en_319_412_2.gen-4.2.3.1-2.organization_name_attribute_absent,
certificate.tbsCertificate.extensions.2.extnValue.subjectKeyIdentifier,SubjectKeyIdentifierValidator,INFO,pkix.subject_key_identifier_method_1_identified,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: add newline to end of file


node_path,validator,severity,code,message
certificate.tbsCertificate.extensions,QcStatementPresenceValidator,ERROR,etsi.en_319_412_5.qcs-5.01,
certificate.tbsCertificate.extensions.1.extnValue.subjectKeyIdentifier,SubjectKeyIdentifierValidator,INFO,pkix.subject_key_identifier_method_1_identified,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: add newline to end of file

Comment on lines +371 to 375
# PR Question: Is this from 415_5.qcs-4.2? Needs different classifier?
allowances[en_319_412_5.id_etsi_qcs_QcCClegislation] = Rfc2119Word.MUST
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See table 1A in EN 319 412 5, clause 4.2.1. The CCLegislation statement is needed for certs that are qualified but not in the EU.

@@ -463,6 +463,10 @@ class QualifiedCertificatePoliciesValidator(validation.Validator):
etsi_constants.QNCP_W_GEN_NP_EIDAS_CERTIFICATE_TYPES,
en_319_411_2.id_qncp_web_gen,
),
(
etsi_constants.QCP_N_QSCD_CERTIFICATE_TYPES,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you remove or change the TODO comment on line 453 to note that QSCD certs are now supported?

@@ -312,6 +317,16 @@ def create_validators(
en_319_412_2.NaturalPersonSubjectAttributeAllowanceValidator()
)

if certificate_type in etsi_constants.EU:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this if statement can be removed, as the issuer requirements are applicable for non-EU certs as well.



class LegalPersonDuplicateAttributeAllowanceValidator(validation.Validator):
"""
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These citation comments should probably be moved to the appropriate sub-class so they document the validation finding declaration.

@@ -307,6 +309,24 @@ def __init__(self):
)


class QcStatementPresenceValidator(extension.ExtensionPresenceValidator):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this class is needed, as the NaturalPersonExtensionIdentifierAllowanceValidator flags when the QCStatements extension is missing.

@breynders-cb
Copy link
Author

Thanks for this contribution! Overall, I think this PR is in pretty good shape. I added some comments for relatively minor things.

In regard to the development of test cases, do you plan on adding more, or should I assist in creating them?

For test cases I worked mostly with integration tests by generating certificates so I'd like to leave it at that for this PR. I'll go through your comments and address them ASAP, thanks for the review!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants