diff --git a/src/agreements_api.go b/src/agreements_api.go index 36af39c7..20c247b2 100644 --- a/src/agreements_api.go +++ b/src/agreements_api.go @@ -82,7 +82,7 @@ func (e mainEnv) agreementAccept(w http.ResponseWriter, r *http.Request, ps http if len(status) == 0 { status = "yes" } else { - status = utils.NormalizeConsentStatus(status) + status = utils.NormalizeConsentValue(status) } if value, ok := records["expiration"]; ok { switch records["expiration"].(type) { diff --git a/src/storage/mysql-storage.go b/src/storage/mysql-storage.go index 149b7aff..b5526361 100644 --- a/src/storage/mysql-storage.go +++ b/src/storage/mysql-storage.go @@ -139,9 +139,6 @@ func (dbobj *MySQLDB) OpenDB(dbname *string) error { } tx.Commit() fmt.Printf("tables: %s\n", allTables) - if isContainer() == true && len(os.Getenv("MYSQL_USER_PASS_FILE")) > 0 { - os.Remove(os.Getenv("MYSQL_USER_PASS_FILE")) - } return nil } diff --git a/src/storage/pgsql-storage.go b/src/storage/pgsql-storage.go index d726e993..6ffe0f8a 100644 --- a/src/storage/pgsql-storage.go +++ b/src/storage/pgsql-storage.go @@ -141,9 +141,6 @@ func (dbobj *PGSQLDB) OpenDB(dbname *string) error { } tx.Commit() fmt.Printf("tables: %s\n", allTables) - if isContainer() == true && len(os.Getenv("PGSQL_USER_PASS_FILE")) > 0 { - os.Remove(os.Getenv("PGSQL_USER_PASS_FILE")) - } return nil } diff --git a/src/storage/storage.go b/src/storage/storage.go index acb008ab..fc6af9ea 100644 --- a/src/storage/storage.go +++ b/src/storage/storage.go @@ -151,16 +151,3 @@ func SliceContains(slice []string, item string) bool { _, ok := set[item] return ok } - -func isContainer() bool { - //if _, err := os.Stat("/.dockerenv"); err == nil { - // return true - //} - if len(os.Getenv("KUBERNETES_SERVICE_HOST")) > 0 { - return true - } - if _, err := os.Stat("/var/run/secrets/kubernetes.io"); err == nil { - return true - } - return false -} diff --git a/src/utils/utils.go b/src/utils/utils.go index 0d055353..bf513c3c 100644 --- a/src/utils/utils.go +++ b/src/utils/utils.go @@ -29,6 +29,9 @@ var ( regexAppName = regexp.MustCompile("^[a-z][a-z0-9\\_]{1,30}$") regexExpiration = regexp.MustCompile("^([0-9]+)([mhds])?$") regexHex = regexp.MustCompile("^[a-zA-F0-9]+$") + letters = []rune("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ") + numbers = []rune("0123456789") + numbers0 = []rune("123456789") indexNames = map[string]bool{ "custom": true, "email": true, @@ -36,7 +39,7 @@ var ( "phone": true, "token": true, } - consentYesStatuses = map[string]bool{ + consentValueTypes = map[string]bool{ "1": true, "accept": true, "agree": true, @@ -49,7 +52,7 @@ var ( "y": true, "yes": true, } - basisTypes = map[string]bool{ + legalBasisTypes = map[string]bool{ "consent": true, "contract": true, "legal-requirement": true, @@ -151,17 +154,17 @@ func HashString(md5Salt []byte, src string) string { return base64.StdEncoding.EncodeToString(hashed[:]) } -func NormalizeConsentStatus(status string) string { +func NormalizeConsentValue(status string) string { status = strings.ToLower(status) - if consentYesStatuses[status] { + if consentValueTypes[status] { return "yes" } return "no" } -func normalizeBasisType(status string) string { +func NormalizeLegalBasisType(status string) string { status = strings.ToLower(status) - if basisTypes[status] { + if legalBasisTypes[status] { return status } return "consent" @@ -211,24 +214,6 @@ func ParseFields(fields string) []string { return strings.Split(fields, ",") } -// Binary search implementation for a sorted array of strings -func binarySearch(arr []string, target string) bool { - low := 0 - high := len(arr) - 1 - - for low <= high { - mid := (low + high) / 2 - if arr[mid] == target { - return true - } else if arr[mid] < target { - low = mid + 1 - } else { - high = mid - 1 - } - } - return false -} - func SliceContains(slice []string, item string) bool { set := make(map[string]bool, len(slice)) for _, s := range slice { @@ -352,19 +337,6 @@ func CheckValidHex(hex1 string) bool { return regexHex.MatchString(hex1) } -func isContainer() bool { - //if _, err := os.Stat("/.dockerenv"); err == nil { - // return true - //} - if len(os.Getenv("KUBERNETES_SERVICE_HOST")) > 0 { - return true - } - if _, err := os.Stat("/var/run/secrets/kubernetes.io"); err == nil { - return true - } - return false -} - // StringPatternMatch looks for basic human patterns like "*", "*abc*", etc... func StringPatternMatch(pattern string, value string) bool { if len(pattern) == 0 { @@ -563,8 +535,6 @@ func GetUserJSONStruct(r *http.Request, defaultCountry string) (UserJSONStruct, return result, err } -var letters = []rune("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ") - func RandSeq(n int) string { b := make([]rune, n) for i := range b { @@ -573,9 +543,6 @@ func RandSeq(n int) string { return string(b) } -var numbers0 = []rune("123456789") -var numbers = []rune("0123456789") - func RandNum(n int) int32 { b := make([]rune, n) for i := range b {