(self)
return jsonify({'objects': [sigma_rule], 'meta': metadata})
Handles POST request to the resource.

        Returns:
            JSON sigma rule
Handles POST request to the resource.
Handles POST request to the resource .
def post(self):
        """Handles POST request to the resource.

        Returns:
            JSON sigma rule
        """

        form = request.json
        if not form:
            form = request.data

        content = form.get('content')
        if not content:
            return abort(
                HTTP_STATUS_CODE_BAD_REQUEST,
                'Missing values from the request.')

        try:
            sigma_rule = ts_sigma_lib.get_sigma_rule_by_text(content)

        except ValueError:
            logger.error('Sigma Parsing error with the user provided rule',
                         exc_info=True)
            abort(
                HTTP_STATUS_CODE_BAD_REQUEST,
                'Error unable to parse the provided Sigma rule')

        except NotImplementedError as exception:
            logger.error(
                'Sigma Parsing error: Feature in the rule provided '
                ' is not implemented in this backend', exc_info=True)
            abort(
                HTTP_STATUS_CODE_BAD_REQUEST,
                'Error generating rule {0!s}'.format(exception))

        except sigma_exceptions.SigmaParseError as exception:
            logger.error(
                'Sigma Parsing error: unknown error', exc_info=True)
            abort(
                HTTP_STATUS_CODE_BAD_REQUEST,
                'Sigma parsing error generating rule  with error: {0!s}'.format(
                    exception))

        except yaml.parser.ParserError as exception:
            logger.error(
                'Sigma Parsing error: an invalid yml file has been provided',
                exc_info=True)
            abort(
                HTTP_STATUS_CODE_BAD_REQUEST,
                'Sigma parsing error: invalid yaml provided {0!s}'.format(
                    exception))

        if sigma_rule is None:
            abort(
                HTTP_STATUS_CODE_NOT_FOUND, 'No sigma was parsed')
        metadata = {'parsed': True}

        return jsonify({'objects': [sigma_rule], 'meta': metadata})
def post ( self ) : form = request . json if not form : form = request . data content = form . get ( 'content' ) if not content : return abort ( HTTP_STATUS_CODE_BAD_REQUEST , 'Missing values from the request.' ) try : sigma_rule = ts_sigma_lib . get_sigma_rule_by_text ( content ) except ValueError : logger . error ( 'Sigma Parsing error with the user provided rule' , exc_info = True ) abort ( HTTP_STATUS_CODE_BAD_REQUEST , 'Error unable to parse the provided Sigma rule' ) except NotImplementedError as exception : logger . error ( 'Sigma Parsing error: Feature in the rule provided ' ' is not implemented in this backend' , exc_info = True ) abort ( HTTP_STATUS_CODE_BAD_REQUEST , 'Error generating rule {0!s}' . format ( exception ) ) except sigma_exceptions . SigmaParseError as exception : logger . error ( 'Sigma Parsing error: unknown error' , exc_info = True ) abort ( HTTP_STATUS_CODE_BAD_REQUEST , 'Sigma parsing error generating rule  with error: {0!s}' . format ( exception ) ) except yaml . parser . ParserError as exception : logger . error ( 'Sigma Parsing error: an invalid yml file has been provided' , exc_info = True ) abort ( HTTP_STATUS_CODE_BAD_REQUEST , 'Sigma parsing error: invalid yaml provided {0!s}' . format ( exception ) ) if sigma_rule is None : abort ( HTTP_STATUS_CODE_NOT_FOUND , 'No sigma was parsed' ) metadata = { 'parsed' : True } return jsonify ( { 'objects' : [ sigma_rule ] , 'meta' : metadata } )