Revision 16th of November

This commit is contained in:
Michael Chen 2022-11-22 16:30:44 +01:00
parent b6389f747f
commit 7b06820170
Signed by: cnml
GPG Key ID: 5845BF3F82D5F629

View File

@ -93,11 +93,13 @@ properties:
items:
type: integer""")
def check_security_rules(security_rules: dict[Any, Any]) -> dict[int, SecurityRule]:
def check_security_rules(security_rules: dict[Any, Any] | None) -> dict[int, SecurityRule]:
if security_rules is None:
raise Exception("Security rules file is empty!")
for n in range(1, 19):
try:
rule = security_rules.get(n, None)
if rule is None: raise Exception('No result for rule {}'.format(n))
if rule is None: raise jsonschema.ValidationError('Rule {} is not evaluated'.format(n))
jsonschema.validate(rule, rule_schema)
except jsonschema.ValidationError as e:
error("Security rule {n}: {msg} at $.{n}.{path}".format(n=n, msg=e.message, path=e.json_path))
@ -139,7 +141,7 @@ def write_model_readmes(dataset: dict[str, Any]):
info['forks'] = forks
info['owner_name'] = owner_name
info['owner_slug'] = owner_slug
security_rules_file = dir / 'security_rules.yaml'
security_rules_file = dataset_path / model_id / 'security_rules.yaml'
try:
with open(security_rules_file, 'r') as f:
security_rules = yaml.safe_load(f)
@ -147,6 +149,9 @@ def write_model_readmes(dataset: dict[str, Any]):
except FileNotFoundError:
warning("Security rules file not found at {}".format(security_rules_file))
security_rules = {}
except Exception as e:
warning("Security rules file at {} is invalid: {}".format(security_rules_file, e))
security_rules = {}
print(f"Writing readme file {readme}")
dir.mkdir(exist_ok=True)
with open(readme, 'w', encoding="utf-8") as f:
@ -184,14 +189,14 @@ Total Items | {info['t']}
### Diagram
The below diagram is generated from the corresponding [model file](/dataset/{model_id}/{model_id}.py).
The below diagram is generated from the corresponding [model file](../../dataset/{model_id}/{model_id}.py).
Formats:
- [PlantUML Model](/dataset/{model_id}/{model_id}/{model_id}.txt)
- [SVG Vector Image](/dataset/{model_id}/{model_id}/{model_id}.svg)
- [PNG Raster Image](/dataset/{model_id}/{model_id}/{model_id}.png)
- [PlantUML Model](../../dataset/{model_id}/{model_id}/{model_id}.txt)
- [SVG Vector Image](../../dataset/{model_id}/{model_id}/{model_id}.svg)
- [PNG Raster Image](../../dataset/{model_id}/{model_id}/{model_id}.png)
![Data Flow Diagram](/dataset/{model_id}/{model_id}/{model_id}.svg)""")
![Data Flow Diagram](../../dataset/{model_id}/{model_id}/{model_id}.svg)""")
def write_root_readme(dataset: dict[str, Any]):
print(f"Writing main readme file")