mirror of
https://github.com/optim-enterprises-bv/databunker.git
synced 2025-10-30 17:37:50 +00:00
cleanup warnings
This commit is contained in:
@@ -102,6 +102,9 @@ func (dbobj dbcon) getAuditEvents(userTOKEN string, offset int32, limit int32) (
|
||||
}
|
||||
var results []bson.M
|
||||
records, err := dbobj.getList(TblName.Audit, "record", userTOKEN, offset, limit)
|
||||
if err != nil {
|
||||
return nil, 0, err
|
||||
}
|
||||
for _, element := range records {
|
||||
element["more"] = false
|
||||
if _, ok := element["before"]; ok {
|
||||
@@ -119,7 +122,7 @@ func (dbobj dbcon) getAuditEvents(userTOKEN string, offset int32, limit int32) (
|
||||
results = append(results, element)
|
||||
}
|
||||
|
||||
resultJSON, err := json.Marshal(records)
|
||||
resultJSON, _ := json.Marshal(records)
|
||||
//fmt.Printf("Found multiple documents (array of pointers): %+v\n", results)
|
||||
return resultJSON, count, nil
|
||||
}
|
||||
|
||||
@@ -80,7 +80,13 @@ func (dbobj dbcon) updateAppRecord(jsonDataPatch []byte, userTOKEN string, appNa
|
||||
sig := record["md5"].(string)
|
||||
encData0 := record["data"].(string)
|
||||
encData, err := base64.StdEncoding.DecodeString(encData0)
|
||||
if err != nil {
|
||||
return userTOKEN, err
|
||||
}
|
||||
decrypted, err := decrypt(dbobj.masterKey, recordKey, encData)
|
||||
if err != nil {
|
||||
return userTOKEN, err
|
||||
}
|
||||
|
||||
// merge
|
||||
fmt.Printf("old json: %s\n", decrypted)
|
||||
@@ -125,6 +131,9 @@ func (dbobj dbcon) listUserApps(userTOKEN string) ([]byte, error) {
|
||||
return nil, err
|
||||
}
|
||||
allCollections, err := dbobj.getAllTables()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
var result []string
|
||||
for _, colName := range allCollections {
|
||||
if strings.HasPrefix(colName, "app_") {
|
||||
|
||||
@@ -28,6 +28,9 @@ func (dbobj dbcon) createUserRecord(parsedData userJSON, event *auditEvent) (str
|
||||
}
|
||||
//err = bson.UnmarshalExtJSON(jsonData, false, &bdoc)
|
||||
encoded, err := encrypt(dbobj.masterKey, recordKey, parsedData.jsonData)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
encodedStr := base64.StdEncoding.EncodeToString(encoded)
|
||||
fmt.Printf("data %s %s\n", parsedData.jsonData, encodedStr)
|
||||
bdoc["key"] = base64.StdEncoding.EncodeToString(recordKey)
|
||||
@@ -157,17 +160,24 @@ func (dbobj dbcon) updateUserRecordDo(parsedData userJSON, userTOKEN string, eve
|
||||
encData0 := oldUserBson["data"].(string)
|
||||
encData, err := base64.StdEncoding.DecodeString(encData0)
|
||||
decrypted, err := decrypt(dbobj.masterKey, recordKey, encData)
|
||||
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
// merge
|
||||
fmt.Printf("old json: %s\n", decrypted)
|
||||
jsonDataPatch := parsedData.jsonData
|
||||
fmt.Printf("json patch: %s\n", jsonDataPatch)
|
||||
newJSON, err := jsonpatch.MergePatch(decrypted, jsonDataPatch)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
fmt.Printf("result: %s\n", newJSON)
|
||||
|
||||
var raw map[string]interface{}
|
||||
err = json.Unmarshal(newJSON, &raw)
|
||||
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
bdel := bson.M{}
|
||||
sig := oldUserBson["md5"].(string)
|
||||
// create new user record
|
||||
@@ -204,7 +214,7 @@ func (dbobj dbcon) updateUserRecordDo(parsedData userJSON, userTOKEN string, eve
|
||||
}
|
||||
}
|
||||
|
||||
encoded, err := encrypt(dbobj.masterKey, recordKey, newJSON)
|
||||
encoded, _ := encrypt(dbobj.masterKey, recordKey, newJSON)
|
||||
encodedStr := base64.StdEncoding.EncodeToString(encoded)
|
||||
bdoc["key"] = userKey
|
||||
bdoc["data"] = encodedStr
|
||||
|
||||
@@ -325,6 +325,10 @@ func enforceUUID(w http.ResponseWriter, uuidCode string, event *auditEvent) bool
|
||||
|
||||
func getJSONPostData(r *http.Request) (map[string]interface{}, error) {
|
||||
cType, _, err := mime.ParseMediaType(r.Header.Get("Content-Type"))
|
||||
if err != nil {
|
||||
fmt.Printf("error to parse content-type: %s\n", err)
|
||||
return nil, err
|
||||
}
|
||||
cType = strings.ToLower(cType)
|
||||
records := make(map[string]interface{})
|
||||
//body, _ := ioutil.ReadAll(r.Body)
|
||||
|
||||
@@ -24,6 +24,9 @@ func (dbobj dbcon) getRootXtoken() (string, error) {
|
||||
|
||||
func (dbobj dbcon) createRootXtoken() (string, error) {
|
||||
rootToken, err := dbobj.getRootXtoken()
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
if len(rootToken) > 0 {
|
||||
return rootToken, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user