From ed22012bf1dfce0d9ab925d39e9eafd0f941f960 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Victor=20N=C3=A4slund?= Date: Sat, 19 Nov 2022 19:06:38 +0100 Subject: Updated schema with tags and better logic for the 'result' tag, lets force description --- src/soc_collector/soc_collector_cli.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'src/soc_collector/soc_collector_cli.py') diff --git a/src/soc_collector/soc_collector_cli.py b/src/soc_collector/soc_collector_cli.py index 4929655..85afce1 100644 --- a/src/soc_collector/soc_collector_cli.py +++ b/src/soc_collector/soc_collector_cli.py @@ -8,7 +8,7 @@ from sys import exit as app_exit import json import requests -from .schema import object_id_from_data +from .schema import object_id_from_data, valid_schema ROOT_CA_FILE = __file__.replace("soc_collector_cli.py", "data/collector_root_ca.crt") @@ -136,6 +136,9 @@ def replace_action(data: str, api_key: str, base_url: str = "https://collector-d print("ERROR: Valid '_id' key not in data") app_exit(1) + if not valid_schema(json_data): + app_exit(1) + req = requests.put( f"{base_url}/sc/v0", json=json_data, headers={"API-KEY": api_key}, timeout=5, verify=ROOT_CA_FILE ) @@ -166,6 +169,9 @@ def insert_action(data: str, api_key: str, base_url: str = "https://collector-de print("ERROR: '_id' key in data") app_exit(1) + if not valid_schema(json_data): + app_exit(1) + req = requests.post( f"{base_url}/sc/v0", json=json_data, headers={"API-KEY": api_key}, timeout=5, verify=ROOT_CA_FILE ) -- cgit v1.1