Skip to content

Commit 0dd7d4c

Browse files
committed
exp: remove encryption experiment
1 parent c5d6f3b commit 0dd7d4c

File tree

19 files changed

+23
-508
lines changed

19 files changed

+23
-508
lines changed

cmd/genji/commands/app.go

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -27,15 +27,6 @@ func NewApp() *cli.App {
2727
NewPebbleCommand(),
2828
}
2929

30-
app.Flags = []cli.Flag{
31-
&cli.StringFlag{
32-
Name: "encryption-key",
33-
Aliases: []string{"k"},
34-
Usage: `Encryption key to use to encrypt/decrypt the database.
35-
The key must be a 32, 48 or 64 bytes long hexadecimal string.`,
36-
},
37-
}
38-
3930
// inject cancelable context to all commands (except the shell command)
4031
ch := make(chan os.Signal, 1)
4132
signal.Notify(ch, os.Interrupt, syscall.SIGTERM)
@@ -60,7 +51,7 @@ func NewApp() *cli.App {
6051
dbpath := c.Args().First()
6152

6253
if dbutil.CanReadFromStandardInput() {
63-
db, err := dbutil.OpenDB(c.Context, dbpath, c.String("encryption-key"))
54+
db, err := dbutil.OpenDB(c.Context, dbpath)
6455
if err != nil {
6556
return err
6657
}
@@ -70,8 +61,7 @@ func NewApp() *cli.App {
7061
}
7162

7263
return shell.Run(c.Context, &shell.Options{
73-
DBPath: dbpath,
74-
EncryptionKey: c.String("encryption-key"),
64+
DBPath: dbpath,
7565
})
7666
}
7767

cmd/genji/commands/bench.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ in the same transaction, use -t`,
9090

9191
path := c.String("path")
9292

93-
db, err := dbutil.OpenDB(c.Context, path, c.String("encryption-key"))
93+
db, err := dbutil.OpenDB(c.Context, path)
9494
if err != nil {
9595
return err
9696
}

cmd/genji/commands/dump.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ $ genji dump -f dump.sql my.db`,
5252
return errors.New(cmd.UsageText)
5353
}
5454

55-
db, err := dbutil.OpenDB(c.Context, dbPath, c.String("encryption-key"))
55+
db, err := dbutil.OpenDB(c.Context, dbPath)
5656
if err != nil {
5757
return err
5858
}

cmd/genji/commands/insert.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,12 +66,12 @@ $ curl https://api.github.com/repos/genjidb/genji/issues | genji insert --db myd
6666
dbPath := c.String("db")
6767
table := c.String("table")
6868
args := c.Args().Slice()
69-
return runInsertCommand(c.Context, dbPath, table, c.Bool("auto"), args, c.String("encryption-key"))
69+
return runInsertCommand(c.Context, dbPath, table, c.Bool("auto"), args)
7070
},
7171
}
7272
}
7373

74-
func runInsertCommand(ctx context.Context, dbPath, table string, auto bool, args []string, encKey string) error {
74+
func runInsertCommand(ctx context.Context, dbPath, table string, auto bool, args []string) error {
7575
generatedName := "data_" + strconv.FormatInt(time.Now().Unix(), 10)
7676
createTable := false
7777
if table == "" && auto {
@@ -83,7 +83,7 @@ func runInsertCommand(ctx context.Context, dbPath, table string, auto bool, args
8383
dbPath = generatedName
8484
}
8585

86-
db, err := dbutil.OpenDB(ctx, dbPath, encKey)
86+
db, err := dbutil.OpenDB(ctx, dbPath)
8787
if err != nil {
8888
return err
8989
}

cmd/genji/commands/pebble.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ func NewPebbleCommand() *cli.Command {
2929
cmd.Action = func(c *cli.Context) error {
3030
path := c.String("path")
3131

32-
db, err := dbutil.OpenDB(c.Context, path, c.String("encryption-key"))
32+
db, err := dbutil.OpenDB(c.Context, path)
3333
if err != nil {
3434
return err
3535
}

cmd/genji/dbutil/db.go

Lines changed: 2 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2,34 +2,17 @@ package dbutil
22

33
import (
44
"context"
5-
"encoding/hex"
65

7-
"github.com/cockroachdb/errors"
86
"github.com/genjidb/genji"
97
)
108

119
// OpenDB is a helper function that takes raw unvalidated parameters and opens a database.
12-
func OpenDB(ctx context.Context, dbPath string, encKey string) (*genji.DB, error) {
10+
func OpenDB(ctx context.Context, dbPath string) (*genji.DB, error) {
1311
if dbPath == "" {
1412
dbPath = ":memory:"
1513
}
1614

17-
// if an encryption key is provided, open the database with the experimental encryption feature.
18-
// the key must be a 32, 48 or 64 bytes long hexadecimal string.
19-
var key []byte
20-
if encKey != "" {
21-
var err error
22-
key, err = hex.DecodeString(encKey)
23-
if err != nil {
24-
return nil, errors.Wrap(err, "invalid encryption key")
25-
}
26-
}
27-
28-
db, err := genji.OpenWith(dbPath, &genji.Options{
29-
Experimental: struct{ EncryptionKey []byte }{
30-
EncryptionKey: key,
31-
},
32-
})
15+
db, err := genji.Open(dbPath)
3316
if err != nil {
3417
return nil, err
3518
}

cmd/genji/dbutil/restore.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ func Restore(ctx context.Context, db *genji.DB, dumpFile, dbPath string) error {
2828
defer file.Close()
2929

3030
if db == nil {
31-
db, err = OpenDB(ctx, dbPath, "")
31+
db, err = OpenDB(ctx, dbPath)
3232
if err != nil {
3333
return err
3434
}

cmd/genji/go.mod

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ require (
3636
github.com/mattn/go-runewidth v0.0.13 // indirect
3737
github.com/mattn/go-tty v0.0.4 // indirect
3838
github.com/matttproud/golang_protobuf_extensions v1.0.4 // indirect
39-
github.com/minio/sio v0.3.0 // indirect
4039
github.com/pkg/errors v0.9.1 // indirect
4140
github.com/pkg/term v1.2.0-beta.2 // indirect
4241
github.com/pmezard/go-difflib v1.0.0 // indirect
@@ -48,7 +47,6 @@ require (
4847
github.com/rogpeppe/go-internal v1.9.0 // indirect
4948
github.com/russross/blackfriday/v2 v2.1.0 // indirect
5049
go.uber.org/atomic v1.9.0 // indirect
51-
golang.org/x/crypto v0.5.0 // indirect
5250
golang.org/x/exp v0.0.0-20220613132600-b0d781184e0d // indirect
5351
golang.org/x/sys v0.4.0 // indirect
5452
golang.org/x/text v0.6.0 // indirect

cmd/genji/go.sum

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ github.com/gin-gonic/gin v1.4.0/go.mod h1:OW2EZn3DO8Ln9oIKOvM++LBO+5UPHJJDH72/q/
7171
github.com/go-check/check v0.0.0-20180628173108-788fd7840127/go.mod h1:9ES+weclKsC9YodN5RgxqK/VD9HM9JsCSh7rNhMZE98=
7272
github.com/go-errors/errors v1.0.1/go.mod h1:f4zRHt4oKfwPJE5k8C9vpYG+aDHdBFUsgrm6/TyX73Q=
7373
github.com/go-errors/errors v1.4.2 h1:J6MZopCL4uSllY1OfXM374weqZFFItUbrImctkmUxIA=
74+
github.com/go-errors/errors v1.4.2/go.mod h1:sIVyrIiJhuEF+Pj9Ebtd6P/rEYROXFi3BopGUQ5a5Og=
7475
github.com/go-martini/martini v0.0.0-20170121215854-22fa46961aab/go.mod h1:/P9AEU963A2AYjv4d1V5eVL1CQbEJq6aCNHDDjibzu8=
7576
github.com/gobwas/httphead v0.0.0-20180130184737-2c6c146eadee/go.mod h1:L0fX3K22YWvt/FAX9NnzrNzcI4wNYi9Yku4O0LKYflo=
7677
github.com/gobwas/pool v0.2.0/go.mod h1:q8bcK0KcYlCgd9e7WYLm9LpyS+YeLd8JVDW6WezmKEw=
@@ -180,8 +181,6 @@ github.com/matttproud/golang_protobuf_extensions v1.0.4 h1:mmDVorXM7PCGKw94cs5zk
180181
github.com/matttproud/golang_protobuf_extensions v1.0.4/go.mod h1:BSXmuO+STAnVfrANrmjBb36TMTDstsz7MSK+HVaYKv4=
181182
github.com/mediocregopher/radix/v3 v3.4.2/go.mod h1:8FL3F6UQRXHXIBSPUs5h0RybMF8i4n7wVopoX3x7Bv8=
182183
github.com/microcosm-cc/bluemonday v1.0.2/go.mod h1:iVP4YcDBq+n/5fb23BhYFvIMq/leAFZyRl6bYmGDlGc=
183-
github.com/minio/sio v0.3.0 h1:syEFBewzOMOYVzSTFpp1MqpSZk8rUNbz8VIIc+PNzus=
184-
github.com/minio/sio v0.3.0/go.mod h1:8b0yPp2avGThviy/+OCJBI6OMpvxoUuiLvE6F1lebhw=
185184
github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0=
186185
github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y=
187186
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
@@ -280,15 +279,12 @@ go.uber.org/multierr v1.7.0 h1:zaiO/rmgFjbmCXdSYJWQcdvOCsthmdaHfr3Gm2Kx4Ec=
280279
go.uber.org/multierr v1.7.0/go.mod h1:7EAYxJLBy9rStEaz58O2t4Uvip6FSURkq8/ppBp95ak=
281280
golang.org/x/crypto v0.0.0-20181203042331-505ab145d0a9/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
282281
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
283-
golang.org/x/crypto v0.0.0-20190513172903-22d7a77e9e5f/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
284282
golang.org/x/crypto v0.0.0-20190701094942-4def268fd1a4/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
285283
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
286284
golang.org/x/crypto v0.0.0-20191227163750-53104e6ec876/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
287285
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
288286
golang.org/x/crypto v0.0.0-20210322153248-0c34fe9e7dc2/go.mod h1:T9bdIzuCu7OtxOm1hfPfRQxPLYneinmdGuTeoZ9dtd4=
289287
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
290-
golang.org/x/crypto v0.5.0 h1:U/0M97KRkSFvyD/3FSmdP5W5swImpNgle/EHFhOsQPE=
291-
golang.org/x/crypto v0.5.0/go.mod h1:NK/OQwhpMQP3MwtdjgLlYHnH9ebylxKWv3e0fK+mkQU=
292288
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
293289
golang.org/x/exp v0.0.0-20220613132600-b0d781184e0d h1:vtUKgx8dahOomfFzLREU8nSv25YHnTgLBn4rDnWZdU0=
294290
golang.org/x/exp v0.0.0-20220613132600-b0d781184e0d/go.mod h1:Kr81I6Kryrl9sr8s2FK3vxD90NdsKWRuOIl2O4CvYbA=
@@ -413,6 +409,7 @@ gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8
413409
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
414410
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
415411
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
412+
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q=
416413
gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI=
417414
gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys=
418415
gopkg.in/go-playground/assert.v1 v1.2.1/go.mod h1:9RXL0bg/zibRAgZUYszZSwO/z8Y/a8bDuhia5mkpMnE=

cmd/genji/shell/command.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ func runIndexesCmd(db *genji.DB, tableName string, w io.Writer) error {
183183
// If a path already exists, existing values in the target database will be overwritten.
184184
func runSaveCmd(ctx context.Context, db *genji.DB, dbPath string) error {
185185
// Open the new database
186-
otherDB, err := dbutil.OpenDB(ctx, dbPath, "")
186+
otherDB, err := dbutil.OpenDB(ctx, dbPath)
187187
if err != nil {
188188
return err
189189
}

0 commit comments

Comments
 (0)