Exemple #1
0
    def remove_ipfix_threshold(thresh_id):
        """
        """
        logging.info("ipfix threshold remove")
        ipfix_thresholds = current_app.config['ipfix_thresholds']
        if thresh_id not in ipfix_thresholds:
            return make_response(jsonify({"error" : "threshold not found"}), 404)

        del ipfix_thresholds[thresh_id]
        current_app._threshold_to_file()
        return make_response(jsonify({"success" : "ok"}), 200)
Exemple #2
0
    def update_ipfix_threshold(thresh_id):
        """
        """
        logging.info("ipfix threshold update")
        ipfix_thresholds = current_app.config['ipfix_thresholds']

        if thresh_id not in ipfix_thresholds:
            return make_response(jsonify({"error" : "threshold not found"}), 404)

        if request.headers['Content-Type'] == 'application/json':
            req = request.json
            for key, val in req.items():
                ipfix_thresholds[thresh_id][key] = val
            current_app._threshold_to_file()
            return make_response(jsonify({"success" : "ok"}), 200)
        else:
            return make_response(jsonify({"error" : "no data"}), 400)
Exemple #3
0
    def add_snort_threshold(thresh_id):
        """
        """
        logging.info("snort threshold add")

        snort_thresholds = current_app.config['snort_thresholds']

        # check if already exists
        if thresh_id in snort_thresholds:
            return make_response(jsonify({"error" : "threshold exists"}), 400)

        if request.headers['Content-Type'] == 'application/json':

            # check for required fields
            req = request.json
            if not all(key in req for key in ['rule', 'treatment', 'priority']): 
                return make_response(jsonify({"error" : "missing value"}), 400)
            snort_thresholds[thresh_id] = req

            current_app._threshold_to_file()
            return make_response(jsonify({"success" : "ok"}), 200)
        else:
            return make_response(jsonify({"error" : "no data"}), 400)