Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add option "-k" to debug tool for encryption #5113

Merged
merged 3 commits into from
Apr 7, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 5 additions & 1 deletion dgraph/cmd/debug/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import (
"github.com/dgraph-io/badger/v2"
"github.com/dgraph-io/badger/v2/options"
"github.com/dgraph-io/dgraph/codec"
"github.com/dgraph-io/dgraph/ee/enc"
"github.com/dgraph-io/dgraph/posting"
"github.com/dgraph-io/dgraph/protos/pb"
"github.com/dgraph-io/dgraph/types"
Expand All @@ -55,6 +56,7 @@ type flagOptions struct {
readTs uint64
sizeHistogram bool
noKeys bool
badgerKeyFile string

// Options related to the WAL.
wdir string
Expand Down Expand Up @@ -85,6 +87,8 @@ func init() {
flag.StringVarP(&opt.pdir, "postings", "p", "", "Directory where posting lists are stored.")
flag.BoolVar(&opt.sizeHistogram, "histogram", false,
"Show a histogram of the key and value sizes.")
flag.StringVarP(&opt.badgerKeyFile, "encryption_key_file", "k", "",
"File where the encryption key is stored.")

flag.StringVarP(&opt.wdir, "wal", "w", "", "Directory where Raft write-ahead logs are stored.")
flag.Uint64VarP(&opt.wtruncateUntil, "truncate", "t", 0,
Expand Down Expand Up @@ -763,7 +767,7 @@ func run() {
}
bopts := badger.DefaultOptions(dir).
WithTableLoadingMode(options.MemoryMap).
WithReadOnly(opt.readOnly)
WithReadOnly(opt.readOnly).WithEncryptionKey(enc.ReadEncryptionKeyFile(opt.badgerKeyFile))

// TODO(Ibrahim): Remove this once badger is updated.
bopts.ZSTDCompressionLevel = 1
Expand Down