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

Commit

Permalink
source: dataset: threat modeling: threat dragon: Add manifest metadata
Browse files Browse the repository at this point in the history
Signed-off-by: John Andersen <[email protected]>
  • Loading branch information
pdxjohnny committed Jun 11, 2022
1 parent 7969de3 commit 51799da
Showing 1 changed file with 28 additions and 3 deletions.
31 changes: 28 additions & 3 deletions dffml/source/dataset/threat_modeling.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@

@dataset_source("owasp.threat-dragon")
async def threat_dragon(
filepath: pathlib.Path, feature_name: str = "threat_model",
filepath: pathlib.Path,
feature_name: str = "threat_model",
schema_url: str = "https://github.com/OWASP/threat-dragon/raw/1.6.2/docs/development/schema/owasp.threat-dragon.schema.json",
format_version: str = "1.0.0",
):
r"""
Examples
Expand All @@ -29,15 +32,37 @@ async def threat_dragon(
>>> records[0].export()
{'key': '0', 'features': {'SepalLength': 6.4, 'SepalWidth': 2.8, 'PetalLength': 5.6, 'PetalWidth': 2.2, 'classification': 2}, 'extra': {}}
"""
if format_version is None:
format_version = "1.0.0"
# Read in the file
contents = filepath.read_text()
# Load the contents
threat_model_dict = json.loads(contents)
# TODO(security) Validate JSON schema
# TODO(security) Validate using JSON schema before accessing properties
title = threat_model_dict["summary"]["title"]
yield MemorySource(
records=[
Record(
key=title,
data={"features": {feature_name: threat_model_dict,},},
data={"features": {feature_name: threat_model_dict}},
extra={
"open-architecture": {
"features": {
feature_name: {
"manifest_metadata": {
"schema": schema_url,
"format_name": threat_dragon.source.ENTRY_POINT_LABEL,
"format_version": format_version,
},
"extra": {
"dffml": {
"source": threat_dragon.source.ENTRY_POINT_LABEL,
},
},
},
},
},
},
)
],
)

0 comments on commit 51799da

Please sign in to comment.