mirror of
https://github.com/optim-enterprises-bv/databunker.git
synced 2025-10-30 17:37:50 +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 {
|
if len(status) == 0 {
|
||||||
status = "yes"
|
status = "yes"
|
||||||
} else {
|
} else {
|
||||||
status = utils.NormalizeConsentStatus(status)
|
status = utils.NormalizeConsentValue(status)
|
||||||
}
|
}
|
||||||
if value, ok := records["expiration"]; ok {
|
if value, ok := records["expiration"]; ok {
|
||||||
switch records["expiration"].(type) {
|
switch records["expiration"].(type) {
|
||||||
|
|||||||
@@ -139,9 +139,6 @@ func (dbobj *MySQLDB) OpenDB(dbname *string) error {
|
|||||||
}
|
}
|
||||||
tx.Commit()
|
tx.Commit()
|
||||||
fmt.Printf("tables: %s\n", allTables)
|
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
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -141,9 +141,6 @@ func (dbobj *PGSQLDB) OpenDB(dbname *string) error {
|
|||||||
}
|
}
|
||||||
tx.Commit()
|
tx.Commit()
|
||||||
fmt.Printf("tables: %s\n", allTables)
|
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
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -151,16 +151,3 @@ func SliceContains(slice []string, item string) bool {
|
|||||||
_, ok := set[item]
|
_, ok := set[item]
|
||||||
return ok
|
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}$")
|
regexAppName = regexp.MustCompile("^[a-z][a-z0-9\\_]{1,30}$")
|
||||||
regexExpiration = regexp.MustCompile("^([0-9]+)([mhds])?$")
|
regexExpiration = regexp.MustCompile("^([0-9]+)([mhds])?$")
|
||||||
regexHex = regexp.MustCompile("^[a-zA-F0-9]+$")
|
regexHex = regexp.MustCompile("^[a-zA-F0-9]+$")
|
||||||
|
letters = []rune("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ")
|
||||||
|
numbers = []rune("0123456789")
|
||||||
|
numbers0 = []rune("123456789")
|
||||||
indexNames = map[string]bool{
|
indexNames = map[string]bool{
|
||||||
"custom": true,
|
"custom": true,
|
||||||
"email": true,
|
"email": true,
|
||||||
@@ -36,7 +39,7 @@ var (
|
|||||||
"phone": true,
|
"phone": true,
|
||||||
"token": true,
|
"token": true,
|
||||||
}
|
}
|
||||||
consentYesStatuses = map[string]bool{
|
consentValueTypes = map[string]bool{
|
||||||
"1": true,
|
"1": true,
|
||||||
"accept": true,
|
"accept": true,
|
||||||
"agree": true,
|
"agree": true,
|
||||||
@@ -49,7 +52,7 @@ var (
|
|||||||
"y": true,
|
"y": true,
|
||||||
"yes": true,
|
"yes": true,
|
||||||
}
|
}
|
||||||
basisTypes = map[string]bool{
|
legalBasisTypes = map[string]bool{
|
||||||
"consent": true,
|
"consent": true,
|
||||||
"contract": true,
|
"contract": true,
|
||||||
"legal-requirement": true,
|
"legal-requirement": true,
|
||||||
@@ -151,17 +154,17 @@ func HashString(md5Salt []byte, src string) string {
|
|||||||
return base64.StdEncoding.EncodeToString(hashed[:])
|
return base64.StdEncoding.EncodeToString(hashed[:])
|
||||||
}
|
}
|
||||||
|
|
||||||
func NormalizeConsentStatus(status string) string {
|
func NormalizeConsentValue(status string) string {
|
||||||
status = strings.ToLower(status)
|
status = strings.ToLower(status)
|
||||||
if consentYesStatuses[status] {
|
if consentValueTypes[status] {
|
||||||
return "yes"
|
return "yes"
|
||||||
}
|
}
|
||||||
return "no"
|
return "no"
|
||||||
}
|
}
|
||||||
|
|
||||||
func normalizeBasisType(status string) string {
|
func NormalizeLegalBasisType(status string) string {
|
||||||
status = strings.ToLower(status)
|
status = strings.ToLower(status)
|
||||||
if basisTypes[status] {
|
if legalBasisTypes[status] {
|
||||||
return status
|
return status
|
||||||
}
|
}
|
||||||
return "consent"
|
return "consent"
|
||||||
@@ -211,24 +214,6 @@ func ParseFields(fields string) []string {
|
|||||||
return strings.Split(fields, ",")
|
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 {
|
func SliceContains(slice []string, item string) bool {
|
||||||
set := make(map[string]bool, len(slice))
|
set := make(map[string]bool, len(slice))
|
||||||
for _, s := range slice {
|
for _, s := range slice {
|
||||||
@@ -352,19 +337,6 @@ func CheckValidHex(hex1 string) bool {
|
|||||||
return regexHex.MatchString(hex1)
|
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...
|
// StringPatternMatch looks for basic human patterns like "*", "*abc*", etc...
|
||||||
func StringPatternMatch(pattern string, value string) bool {
|
func StringPatternMatch(pattern string, value string) bool {
|
||||||
if len(pattern) == 0 {
|
if len(pattern) == 0 {
|
||||||
@@ -563,8 +535,6 @@ func GetUserJSONStruct(r *http.Request, defaultCountry string) (UserJSONStruct,
|
|||||||
return result, err
|
return result, err
|
||||||
}
|
}
|
||||||
|
|
||||||
var letters = []rune("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ")
|
|
||||||
|
|
||||||
func RandSeq(n int) string {
|
func RandSeq(n int) string {
|
||||||
b := make([]rune, n)
|
b := make([]rune, n)
|
||||||
for i := range b {
|
for i := range b {
|
||||||
@@ -573,9 +543,6 @@ func RandSeq(n int) string {
|
|||||||
return string(b)
|
return string(b)
|
||||||
}
|
}
|
||||||
|
|
||||||
var numbers0 = []rune("123456789")
|
|
||||||
var numbers = []rune("0123456789")
|
|
||||||
|
|
||||||
func RandNum(n int) int32 {
|
func RandNum(n int) int32 {
|
||||||
b := make([]rune, n)
|
b := make([]rune, n)
|
||||||
for i := range b {
|
for i := range b {
|
||||||
|
|||||||
Reference in New Issue
Block a user