Coverage for turvallisuusneuvonta/csaf/core/rules/mandatory/unique_product_ids.py: 100.00%

5 statements  

« prev     ^ index     » next       coverage.py v7.4.1, created at 2024-02-05 19:27:17 +00:00

1"""6.1.2 Multiple Definition of Product ID 

2 

3For each Product ID (type /$defs/product_id_t) in Full Product Name elements (type: /$defs/full_product_name_t) 

4it must be tested that the product_id was not already defined within the same document. 

5 

6The relevant paths for this test are: 

7 /product_tree/branches[](/branches[])*/product/product_id 

8 /product_tree/full_product_names[]/product_id 

9 /product_tree/relationships[]/full_product_name/product_id 

10 

11Example 41 which fails the test: 

12 

13 "product_tree": { 

14 "full_product_names": [ 

15 { 

16 "product_id": "CSAFPID-9080700", 

17 "name": "Product A" 

18 }, 

19 { 

20 "product_id": "CSAFPID-9080700", 

21 "name": "Product B" 

22 } 

23 ] 

24 } 

25 

26CSAFPID-9080700 was defined twice. 

27""" 

28 

29ID = (6, 1, 2) 

30TOPIC = 'Multiple Definition of Product ID' 

31CONDITION_PATHS = ( 

32 # '/product_tree/branches[](/branches[])*/product/product_id', # TODO(sthagen) recursion may require custom code 

33 '/product_tree/full_product_names[]/product_id', 

34 '/product_tree/relationships[]/full_product_name/product_id', 

35) 

36CONDITION_JMES_PATHS = tuple(path.lstrip('/').replace('/', '.') for path in CONDITION_PATHS) 

37PATHS = CONDITION_PATHS