mirror of
https://github.com/optim-enterprises-bv/databunker.git
synced 2025-11-02 02:48:05 +00:00
format go code
This commit is contained in:
@@ -33,7 +33,7 @@ func decrypt(masterKey []byte, userKey []byte, data []byte) ([]byte, error) {
|
||||
// DO NOT USE THE FOLLOWING LINE. It is broken!!!
|
||||
//key := append(masterKey, userKey...)
|
||||
la := len(masterKey)
|
||||
key := make([]byte, la + len(userKey))
|
||||
key := make([]byte, la+len(userKey))
|
||||
copy(key, masterKey)
|
||||
copy(key[la:], userKey)
|
||||
|
||||
@@ -59,7 +59,7 @@ func encrypt(masterKey []byte, userKey []byte, plaintext []byte) ([]byte, error)
|
||||
// comprising 24 master key
|
||||
// and 8 bytes record key
|
||||
la := len(masterKey)
|
||||
key := make([]byte, la + len(userKey))
|
||||
key := make([]byte, la+len(userKey))
|
||||
copy(key, masterKey)
|
||||
copy(key[la:], userKey)
|
||||
|
||||
@@ -81,7 +81,7 @@ func encrypt(masterKey []byte, userKey []byte, plaintext []byte) ([]byte, error)
|
||||
// apppend random nonce bvalue to the end
|
||||
//ciphertext := append(ciphertext0, nonce...)
|
||||
la = len(ciphertext0)
|
||||
ciphertext := make([]byte, la + len(nonce))
|
||||
ciphertext := make([]byte, la+len(nonce))
|
||||
copy(ciphertext, ciphertext0)
|
||||
copy(ciphertext[la:], nonce)
|
||||
return ciphertext, nil
|
||||
@@ -91,7 +91,7 @@ func basicStringEncrypt(plaintext string, masterKey []byte, code []byte) (string
|
||||
//log.Printf("Going to encrypt %s", plaintext)
|
||||
nonce := []byte("$DataBunker$")
|
||||
la := len(masterKey)
|
||||
key := make([]byte, la + len(code))
|
||||
key := make([]byte, la+len(code))
|
||||
copy(key, masterKey)
|
||||
copy(key[la:], code)
|
||||
|
||||
@@ -118,7 +118,7 @@ func basicStringDecrypt(data string, masterKey []byte, code []byte) (string, err
|
||||
}
|
||||
nonce := []byte("$DataBunker$")
|
||||
la := len(masterKey)
|
||||
key := make([]byte, la + len(code))
|
||||
key := make([]byte, la+len(code))
|
||||
copy(key, masterKey)
|
||||
copy(key[la:], code)
|
||||
block, err := aes.NewCipher(key)
|
||||
|
||||
@@ -2,10 +2,10 @@ package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"time"
|
||||
"strings"
|
||||
"net/http/httptest"
|
||||
"strings"
|
||||
"testing"
|
||||
"time"
|
||||
)
|
||||
|
||||
func helpGetExpStatus(utoken string) (map[string]interface{}, error) {
|
||||
@@ -130,7 +130,7 @@ func TestExpCancel(t *testing.T) {
|
||||
|
||||
func TestExpAuto(t *testing.T) {
|
||||
userJSON := `{"login":"william4"}`
|
||||
now := int32(time.Now().Unix())+1
|
||||
now := int32(time.Now().Unix()) + 1
|
||||
raw, _ := helpCreateUser(userJSON)
|
||||
if _, ok := raw["status"]; !ok || raw["status"].(string) != "ok" {
|
||||
t.Fatalf("Failed to create user")
|
||||
|
||||
@@ -5,16 +5,16 @@ import (
|
||||
"net"
|
||||
"net/http"
|
||||
"strings"
|
||||
|
||||
"github.com/gobuffalo/packr"
|
||||
"github.com/oschwald/geoip2-golang"
|
||||
)
|
||||
|
||||
var (
|
||||
geoipBytes []byte
|
||||
geoip * geoip2.Reader
|
||||
geoip *geoip2.Reader
|
||||
)
|
||||
|
||||
|
||||
func initGeoIP() {
|
||||
var err error
|
||||
box := packr.NewBox("../ui")
|
||||
|
||||
@@ -20,8 +20,10 @@ var userSchema *jsonschema.Schema
|
||||
|
||||
// IsAdmin - admin/DPO approval is required
|
||||
type IsAdmin bool
|
||||
|
||||
// IsLocked - variable is locked from changes
|
||||
type IsLocked bool
|
||||
|
||||
// IsPreserve variable can never be deleted
|
||||
type IsPreserve bool
|
||||
|
||||
|
||||
@@ -176,13 +176,14 @@ func (dbobj *SQLiteDB) CloseDB() {
|
||||
|
||||
// BackupDB function backups existing database and prints database structure to http.ResponseWriter
|
||||
func (dbobj SQLiteDB) BackupDB(w http.ResponseWriter) {
|
||||
/*
|
||||
/*
|
||||
err := sqlite3dump.DumpDB(dbobj.db, w)
|
||||
|
||||
if err != nil {
|
||||
w.WriteHeader(http.StatusInternalServerError)
|
||||
log.Printf("error in backup: %s", err)
|
||||
}
|
||||
*/
|
||||
*/
|
||||
}
|
||||
|
||||
func (dbobj SQLiteDB) escapeName(name string) string {
|
||||
|
||||
@@ -42,7 +42,7 @@ func (dbobj dbcon) deleteUserApp(userTOKEN string, appName string, conf Config)
|
||||
|
||||
func (dbobj dbcon) deleteUserApps(userTOKEN string, conf Config) {
|
||||
if conf.Generic.UseSeparateAppTables == true {
|
||||
userApps, _:= dbobj.listAllAppsOnly(conf)
|
||||
userApps, _ := dbobj.listAllAppsOnly(conf)
|
||||
// delete all user app records
|
||||
for _, appName := range userApps {
|
||||
appNameFull := "app_" + appName
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"net/http/httptest"
|
||||
"encoding/json"
|
||||
"net/http/httptest"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
uuid "github.com/hashicorp/go-uuid"
|
||||
jsonpatch "github.com/evanphx/json-patch"
|
||||
uuid "github.com/hashicorp/go-uuid"
|
||||
)
|
||||
|
||||
func helpCreateUserApp(userTOKEN string, appName string, appJSON string) (map[string]interface{}, error) {
|
||||
|
||||
@@ -454,7 +454,6 @@ func (dbobj dbcon) dumpUserPII(email string, conf Config) (string, error) {
|
||||
return fullJSON, err
|
||||
}
|
||||
|
||||
|
||||
func (dbobj dbcon) getUserJSONByIndex(indexValue string, indexName string, conf Config) ([]byte, string, error) {
|
||||
userBson, err := dbobj.lookupUserRecordByIndex(indexName, indexValue, conf)
|
||||
if userBson == nil || err != nil {
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"log"
|
||||
"encoding/json"
|
||||
"log"
|
||||
"net/http/httptest"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
uuid "github.com/hashicorp/go-uuid"
|
||||
jsonpatch "github.com/evanphx/json-patch"
|
||||
uuid "github.com/hashicorp/go-uuid"
|
||||
)
|
||||
|
||||
func helpCreateUser(userJSON string) (map[string]interface{}, error) {
|
||||
|
||||
@@ -2,8 +2,8 @@ package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"log"
|
||||
"io/ioutil"
|
||||
"log"
|
||||
"net/http"
|
||||
"net/http/httptest"
|
||||
"strings"
|
||||
|
||||
Reference in New Issue
Block a user