Closed tschmidtb51 closed 3 years ago
We should also take that into account in #193 and #191.
+1 for implementing validation checks. I assume this could be baked into the existing parser library (https://github.com/oasis-open/csaf-parser), though I guess it should be updated to support CSAF 2.0 first. Or do we think the community would prefer a standalone library for parsing and validation for CSAF 2.0 (I don't really have an opinion on this)?
I'm not sure what the current status of the csaf-parser is and whether it is written in a way that it can be upgraded easily.
Maybe @sthagen can elaborate on that...
As a user, I would probably prefer a library which I can include in my own implementation...
I am open to support csaf-parser but it may have a lot of baggage from the past.
I will start to implement the suggested schematron like tests of this ticket in csaf-lint.
But, not tomorrow, as tomorrow I have a day off ... anything 😄
This is also related to #214. The following tests are mentioned there:
draft
number
of 0
or 0.y.z
MUST be removed from the document if the document status is final
./document/tracking/status
is final
.This is also related to #202. The following test is mentioned:
source_lang
must be present and set if the value translator
is used for /document/publisher/category
One question placed here may well be moved ... what is the expected value of the source_lang
field when translating more than once (not iterating but from language to language ...)?
Is the true source language the value of the lang
field from the very first advisory or just the "previous" one?
(source_lang, lang): (en, en) -> (en, fr) -> (en, de) ... (en, es)
or (I assume it can be this latter):
(source_lang, lang): (en, en) -> (en, fr) -> (fr, de) ... (pl, es)
Here is a list of potential "informational" tests:
cvss_v3
is given, otherwise skip)cwe
=> recommend adding onecve
=> recommend adding onedistribution
=> recommend adding TLP statementThis is also related to #239:
md5
should not be present alone => add second "strong" hashsha1
should not be present alone => add second "strong" hashAll the tests listed here make sense to me!
Couple more suggestions for informational tests:
We have some parts which can't be enforced be the schema itself but should be tested programmatically. Therefore, I suggest to add those tests to the standard to ease the pain. Here are some ideas:
Test whether definition of
product_id
exists"#/definitions/product_id_t"
(implicit:"#/definitions/products_t"
) which are not inside a Full Product Name (full_product_name_t
) and therefore reference an element within theproduct_tree
=> test whether the Full Product Name with theproduct_id
existsrelevant paths: click to expand
``` /product_tree/product_groups[]/product_ids[] /product_tree/relationships[]/product_reference /product_tree/relationships[]/relates_to_product_reference /vulnerabilities[]/product_status/first_affected[] /vulnerabilities[]/product_status/first_fixed[] /vulnerabilities[]/product_status/fixed[] /vulnerabilities[]/product_status/known_affected[] /vulnerabilities[]/product_status/known_not_affected[] /vulnerabilities[]/product_status/last_affected[] /vulnerabilities[]/product_status/recommended[] /vulnerabilities[]/product_status/under_investigation[] /vulnerabilities[]/remediations[]/product_ids[] /vulnerabilities[]/scores[]/products[] /vulnerabilities[]/threats[]/product_ids[] ```
Test whether the definition of
product_id
ends up in a circle Example:Test whether definition of
group_id
exists"#/definitions/product_group_id_t"
(implicit:"#/definitions/product_groups_t"
) which are not inside a Product Group (product_groups[]
) and therefore reference an element within theproduct_tree
=> test whether the Product Group with thegroup_id
existsrelevant paths: click to expand
``` /vulnerabilities[]/remediations[]/group_ids /vulnerabilities[]/threats[]/group_ids ```
Test whether
product_id
was already definedproduct_id
(type:"#/definitions/product_id_t"
) in Full Product Name elements (type:"#/definitions/full_product_name_t"
): was theproduct_id
already defined (within the document)?relevant paths: click to expand
``` /product_tree/branches[](/...)/product/product_id /product_tree/full_product_names[]/product_id /product_tree/relationships[]/full_product_name/product_id ```
Test whether
group_id
was already definedgroup_id
(type:"#/definitions/product_group_id_t"
) in Product Group elements (type:"product_tee/product_groups[]/"
): was thegroup_id
already defined (within the document)?relevant path: click to expand
``` /product_tree/product_groups[]/group_id ```
Test whether
product_status
has contradicting elementsproduct_id
should not be in contradicting arrays, e.g.fixed
andknown_affected
contradicting groups: click to expand
- Affected ``` /vulnerabilities[]/product_status/first_affected[] /vulnerabilities[]/product_status/known_affected[] /vulnerabilities[]/product_status/last_affected[] ``` - Not affected ``` /vulnerabilities[]/product_status/known_not_affected[] ``` - Fixed ``` /vulnerabilities[]/product_status/first_fixed[] /vulnerabilities[]/product_status/fixed[] ``` - Under investigation ``` /vulnerabilities[]/product_status/under_investigation[] ``` Note: An issuer might `recommend`a version from any group - also from the affected group i.e. if it is harder to exploit.
Test whether
products
has elements in other items ofscores
within one vulnerabilityproduct_id
should not be listed with more then one CVSS-Vectors with the same version. Example:"CSAFPID-0017"
would break that testTest whether CVSS is valid (according to JSON schema)
Test whether CVSS is computed correctly
Test whether CWE exists and is valid
Test whether
language_t
is valid and existsTest whether
date
in elements ofrevision_history
are ascending when sorting the elements bynumber
(according toversion_t
schema)Test whether definition of
product_id
is used in the advisory