Skip to content
This repository was archived by the owner on Aug 25, 2024. It is now read-only.

Commit 51799da

Browse files
committed
source: dataset: threat modeling: threat dragon: Add manifest metadata
Signed-off-by: John Andersen <[email protected]>
1 parent 7969de3 commit 51799da

File tree

1 file changed

+28
-3
lines changed

1 file changed

+28
-3
lines changed

dffml/source/dataset/threat_modeling.py

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,10 @@
88

99
@dataset_source("owasp.threat-dragon")
1010
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",
1215
):
1316
r"""
1417
Examples
@@ -29,15 +32,37 @@ async def threat_dragon(
2932
>>> records[0].export()
3033
{'key': '0', 'features': {'SepalLength': 6.4, 'SepalWidth': 2.8, 'PetalLength': 5.6, 'PetalWidth': 2.2, 'classification': 2}, 'extra': {}}
3134
"""
35+
if format_version is None:
36+
format_version = "1.0.0"
37+
# Read in the file
3238
contents = filepath.read_text()
39+
# Load the contents
3340
threat_model_dict = json.loads(contents)
34-
# TODO(security) Validate JSON schema
41+
# TODO(security) Validate using JSON schema before accessing properties
3542
title = threat_model_dict["summary"]["title"]
3643
yield MemorySource(
3744
records=[
3845
Record(
3946
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+
},
4166
)
4267
],
4368
)

0 commit comments

Comments
 (0)