From 495668385381f4af1fb9e413a12bdd4924215b61 Mon Sep 17 00:00:00 2001 From: Shiv Tyagi Date: Sun, 21 Apr 2024 21:37:04 +0530 Subject: [PATCH] app.py: validate remotes.json after loading file --- app.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/app.py b/app.py index 86e0e2e..62c5d83 100755 --- a/app.py +++ b/app.py @@ -17,6 +17,7 @@ import sys import re import requests +import jsonschema # run at lower priority os.nice(20) @@ -74,8 +75,11 @@ def ref_is_tag(commit_reference): def load_remotes(): # load file contianing vehicles listed to be built for each remote along with the braches/tags/commits on which the firmware can be built - with open(os.path.join(basedir, 'configs', 'remotes.json'), 'r') as f: + with open(os.path.join(basedir, 'configs', 'remotes.json'), 'r') as f, open(os.path.join(appdir, 'remotes.schema.json'), 'r') as s: remotes = json.loads(f.read()) + schema = json.loads(s.read()) + # validate schema + jsonschema.validate(remotes, schema=schema) set_remotes(remotes)