def file_to_queue(self, file_tuple): working_dir, filename = file_tuple for cve in self.ijson_handler.fetch(filename=filename, prefix=self.prefix): x = 0 for key, val in cve.items(): entry_dict = {"id": key} entry_dict.update(val) self.process_item(item=entry_dict) x += 1 self.logger.debug("Processed {} items from file: {}".format( x, filename)) with open(filename, "rb") as input_file: data = json.loads(input_file.read().decode("utf-8")) setColInfo("via4", "sources", data["metadata"]["sources"]) setColInfo("via4", "searchables", data["metadata"]["searchables"]) self.logger.debug( "Processed metadata from file: {}".format(filename)) try: self.logger.debug("Removing working dir: {}".format(working_dir)) shutil.rmtree(working_dir) except Exception as err: self.logger.error( "Failed to remove working dir; error produced: {}".format(err))
def verifyCode(): post_data = dict(request.json) ret = subprocess.run(["signal-cli", "-u", post_data['phone'], "verify", post_data['code']], capture_output=True) if ret.returncode == 0: setColInfo('subscriptions', 'registeredPhone', post_data['phone']) return jsonify({"status": "phone_registered"}) else: return jsonify({"status": "unknown_error"})
def changeThresholds(): post_data = dict(request.json) setColInfo('watchlist', 'threshold_entity', post_data['thresh_entity']) setColInfo('watchlist', 'threshold_critical', post_data['thresh_critical']) setColInfo('watchlist', 'w_threshold_entity', post_data['w_thresh_entity']) setColInfo('watchlist', 'w_threshold_critical', post_data['w_thresh_critical']) return jsonify({"status": "thresholds_updated"})
def admin_home(): if getInfo('subscriptions') is None or 'registeredPhone' not in getInfo('subscriptions'): setColInfo('subscriptions', 'registeredPhone', '') return render_template("admin.html", status="default", **adminInfo())