mirror of
				https://github.com/optim-enterprises-bv/databunker.git
				synced 2025-10-31 01:47:57 +00:00 
			
		
		
		
	code cleanup - remove leftovers
This commit is contained in:
		| @@ -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) { | ||||
|   | ||||
| @@ -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 | ||||
| } | ||||
|  | ||||
|   | ||||
| @@ -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 | ||||
| } | ||||
|  | ||||
|   | ||||
| @@ -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 | ||||
| } | ||||
|   | ||||
| @@ -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 { | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 yuli
					yuli