8
8
9
9
@dataset_source ("owasp.threat-dragon" )
10
10
async def threat_dragon (
11
- filepath : pathlib .Path , feature_name : str = "threat_model" ,
11
+ filepath : pathlib .Path ,
12
+ feature_name : str = "threat_model" ,
13
+ schema_url : str = "https://github.com/OWASP/threat-dragon/raw/1.6.2/docs/development/schema/owasp.threat-dragon.schema.json" ,
14
+ format_version : str = "1.0.0" ,
12
15
):
13
16
r"""
14
17
Examples
@@ -29,15 +32,37 @@ async def threat_dragon(
29
32
>>> records[0].export()
30
33
{'key': '0', 'features': {'SepalLength': 6.4, 'SepalWidth': 2.8, 'PetalLength': 5.6, 'PetalWidth': 2.2, 'classification': 2}, 'extra': {}}
31
34
"""
35
+ if format_version is None :
36
+ format_version = "1.0.0"
37
+ # Read in the file
32
38
contents = filepath .read_text ()
39
+ # Load the contents
33
40
threat_model_dict = json .loads (contents )
34
- # TODO(security) Validate JSON schema
41
+ # TODO(security) Validate using JSON schema before accessing properties
35
42
title = threat_model_dict ["summary" ]["title" ]
36
43
yield MemorySource (
37
44
records = [
38
45
Record (
39
46
key = title ,
40
- data = {"features" : {feature_name : threat_model_dict ,},},
47
+ data = {"features" : {feature_name : threat_model_dict }},
48
+ extra = {
49
+ "open-architecture" : {
50
+ "features" : {
51
+ feature_name : {
52
+ "manifest_metadata" : {
53
+ "schema" : schema_url ,
54
+ "format_name" : threat_dragon .source .ENTRY_POINT_LABEL ,
55
+ "format_version" : format_version ,
56
+ },
57
+ "extra" : {
58
+ "dffml" : {
59
+ "source" : threat_dragon .source .ENTRY_POINT_LABEL ,
60
+ },
61
+ },
62
+ },
63
+ },
64
+ },
65
+ },
41
66
)
42
67
],
43
68
)
0 commit comments