<commit_before>package decorates

import (
	"bytes"
	"facemark/models"
	"fmt"
	"github.com/gorilla/mux"
	"io/ioutil"
	"net/http"
	"regexp"
)

func (inner Handler) Verify() Handler {
	return Handler(func(w http.ResponseWriter, r *http.Request) *models.APPError {
		sqlInjection, err := regexp.Compile(`(?:')|(?:--)|(/\\*(?:.|[\\n\\r])*?\\*/)|(\b(select|update|and|or|delete|insert|trancate|char|chr|into|substr|ascii|declare|exec|count|master|into|drop|execute)\b)`)
		if err != nil {
			return &models.APPError{err, "insecure params.", "INSECURE_PARAMES", 403}
		}
		result := []byte{}

		if r.Body != nil {
			result, err = ioutil.ReadAll(r.Body)
			r.ParseForm()
			r.Body = ioutil.NopCloser(bytes.NewBuffer(result))
		}
		if err != nil {
			return &models.APPError{err, "insecure params.", "INSECURE_PARAMES", 403}
		}
		if sqlInjection.MatchString(string(result)) {
			return &models.APPError{err, "insecure params.", "INSECURE_PARAMES", 403}
		}
		if sqlInjection.MatchString(fmt.Sprintf("%v", mux.Vars(r))) {
			return &models.APPError{err, "insecure params.", "INSECURE_PARAMES", 403}
		}
		if sqlInjection.MatchString(fmt.Sprintf("%v", r.Form)) {<commit_msg>reset route struts & request verify about sql injection<commit_after>package decorates

import (
	"bytes"
	"fmt"
	"github.com/gorilla/mux"
	"github.com/yang-f/beauty/models"
	"io/ioutil"
	"net/http"
	"regexp"
)

func (inner Handler) Verify() Handler {
	return Handler(func(w http.ResponseWriter, r *http.Request) *models.APPError {
		sqlInjection, err := regexp.Compile(`(?:')|(?:--)|(/\\*(?:.|[\\n\\r])*?\\*/)|(\b(select|update|and|or|delete|insert|trancate|char|chr|into|substr|ascii|declare|exec|count|master|into|drop|execute)\b)`)
		if err != nil {
			return &models.APPError{err, "insecure params.", "INSECURE_PARAMES", 403}
		}
		result := []byte{}

		if r.Body != nil {
			result, err = ioutil.ReadAll(r.Body)
			r.ParseForm()
			r.Body = ioutil.NopCloser(bytes.NewBuffer(result))
		}
		if err != nil {
			return &models.APPError{err, "insecure params.", "INSECURE_PARAMES", 403}
		}
		if sqlInjection.MatchString(string(result)) {
			return &models.APPError{err, "insecure params.", "INSECURE_PARAMES", 403}
		}
		if sqlInjection.MatchString(fmt.Sprintf("%v", mux.Vars(r))) {
			return &models.APPError{err, "insecure params.", "INSECURE_PARAMES", 403}
		}
		if sqlInjection.MatchString(fmt.Sprintf("%v", r.Form)) {
{'fraction_non_alphanumeric': 0.19288702928870294, 'fraction_numerical': 0.0100418410041841, 'mean_word_length': 4.817518248175182, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7177878', 'n_tokens_mistral': 1004, 'n_tokens_neox': 915, 'n_words': 153}