jack5341 / super-dollop Goto Github PK
View Code? Open in Web Editor NEWEncrypt your files or notes by your GPG key and save to MinIO or AWS S3 easily!
License: Apache License 2.0
Encrypt your files or notes by your GPG key and save to MinIO or AWS S3 easily!
License: Apache License 2.0
You should guard against file names that look like options:
cmd := exec.Command("gpg", "--decrypt", filePath)
If filePath
happened to be --sign
then it would be accepted as an option and you'd get the wrong results, possibly silently. Put a --
before the file name to stop option processing:
cmd := exec.Command("gpg", "--decrypt", "--", filePath)
There's a bytes.NewReader
so you don't need to make an unneeded, extra copy of the user's data in memory:
var out []byte
// ...
r := strings.NewReader(string(out))
However, even better would be to stream the output of GnuPG straight into the bucket. The minio
interface already takes a reader, so you could just hook up its StdoutPipe()
. Set the length to -1.
Same goes for decryption: Connect minio
to the GnuPG process like a pipe. This avoids the need for (badly and dangerously) creating temporary files.
Strongly consider explicitly using GnuPG's "unattended" interface via --batch
and maybe --status-fd
and --with-colons
. That's how GnuPG is intended to be run non-interactively by other programs.
Silence is golden. Do you really need to print output when everything was successful? Consider how go build
itself prints nothing on success.
panic
is not an appropriate way to deal with everyday errors. Outside of OOM, regular users should never see panic messages. If PutObject
fails (e.g. network error), print a useful error message. (IMHO, also it would also be better style to pass this error up to the top level, or nearly so, and let it do the printing, rather than mingling UI with your business logic. Same goes for validating command line options.)
Always exit the process with an error status when an error terminates processing. Also, check the error results! Currently there a number of ways the program may silently lose data.
Never print errors on standard output, especially if the user is expecting their data on standard output. Combined with the lack of error exit status, this is a recipe for disaster. If something fails, the user will never see the error, nor have any way to know it failed. Instead they'll quietly have the wrong data. This is a programming cardinal sin.
Get more comfortable with byte slices, []byte
. There are lots of needless, and even incorrect, string conversions. For instance:
fmt.Println(string(data))
Just do this instead:
os.Stdout.Write(data)
Not only is it more efficient, it doesn't append a spurious newline to the user's data. Also check the error!
When I try to add a new flag to cli your project give me:
panic: unable to redefine 'n' shorthand in "super-dollop" flagset: it's already used for "name" flag │
│ jack5341@jack5341 ~
goroutine 1 [running]: │ jack5341@jack5341 ~ clear
github.com/spf13/pflag.(*FlagSet).AddFlag(0xc0000ba100, 0xc0001cd680) │
/home/jack5341/Nedim-Akar/Workspace/super-dollop/vendor/github.com/spf13/pflag/flag.go:874 +0x6f0│ jack5341@jack5341 ~ ws
github.com/spf13/pflag.(*FlagSet).VarPF(0xc0000ba100, 0x8f4ce0, 0xc000073dd0, 0x85cffa, 0x4, 0x85c6bf, 0x│ jack5341@jack5341 ~/Nedim-Akar/Workspace clear
1, 0x864431, 0x16, 0xc000073dd0) │
/home/jack5341/Nedim-Akar/Workspace/super-dollop/vendor/github.com/spf13/pflag/flag.go:831 +0x10b│ jack5341@jack5341 ~/Nedim-Akar/Workspace ls
github.com/spf13/pflag.(*FlagSet).VarP(...) │playground super-dollop
/home/jack5341/Nedim-Akar/Workspace/super-dollop/vendor/github.com/spf13/pflag/flag.go:837 │ jack5341@jack5341 ~/Nedim-Akar/Workspace cd playground
github.com/spf13/pflag.(*FlagSet).StringVarP(0xc0000ba100, 0xc000073dd0, 0x85cffa, 0x4, 0x85c6bf, 0x1, 0x│ jack5341@jack5341 ~/Nedim-Akar/Workspace/playground clear
0, 0x0, 0x864431, 0x16) │
/home/jack5341/Nedim-Akar/Workspace/super-dollop/vendor/github.com/spf13/pflag/string.go:42 +0xad│ jack5341@jack5341 ~/Nedim-Akar/Workspace/playground docker-compose up
github.com/spf13/pflag.(*FlagSet).StringP(...) │Starting playground_s3_1 ... done
/home/jack5341/Nedim-Akar/Workspace/super-dollop/vendor/github.com/spf13/pflag/string.go:67 │Attaching to playground_s3_1
github.com/super-dollop/cmd.init.1() │s3_1 |
/home/jack5341/Nedim-Akar/Workspace/super-dollop/cmd/encrypt.go:45 +0x134 │s3_1 | You are running an older version of MinIO released 2 days ago
exit status 2 │s3_1 | Update: Run `mc admin update`
System Information;
When I want to direct encrypt and print it see this error.
~/Desktop/Personal Projects/super-dollop master ❯ go run . enc --note=hello-world -p 21:58:58
panic: failed to connect to minio client
goroutine 1 [running]:
github.com/jack5341/super-dollop/pkg.Connect(0x1400007c058)
/Users/nedim/Desktop/Personal Projects/super-dollop/pkg/minio.go:18 +0x208
github.com/jack5341/super-dollop/cmd.Execute()
/Users/nedim/Desktop/Personal Projects/super-dollop/cmd/root.go:21 +0x20
main.main()
/Users/nedim/Desktop/Personal Projects/super-dollop/main.go:13 +0x20
exit status 2```
While trying to use command enc -n=helloworld
I take this prompt looks like this is a bug;
File '/dev/stdout' exists. Overwrite? (y/N)
Hi there. As stated, here's what happens when you start the binary under Windows 10 x64:
panic: Endpoint: does not follow ip address or domain name standards.
goroutine 1 [running]:
github.com/jack5341/super-dollop/pkg.Connect()
/home/runner/work/super-dollop/super-dollop/pkg/minio.go:18 +0xa7
github.com/jack5341/super-dollop/cmd.Execute()
/home/runner/work/super-dollop/super-dollop/cmd/root.go:21 +0x19
main.main()
/home/runner/work/super-dollop/super-dollop/main.go:8 +0x17
command dec
should include 3 flag store ,filename and download. --store
command is specify to target encrypted file is in minIO or on local machine. MinIO should be connected just while user using related flag. I use 2 encryption method at here GPG and AES256 you can take input for recognise is it GPG or AES256.
--store
flag initialised variable should be false [boolean]--filename
is for specify where is the target file. [string] (required)--download
flag if user didn't use this flag just print it to terminal. [string]A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.