diff --git a/cmd/scan.go b/cmd/scan.go index 805e737..2d181bd 100644 --- a/cmd/scan.go +++ b/cmd/scan.go @@ -77,6 +77,7 @@ type fileScanner struct { printer *utils.Printer showInVT bool waitForCompletion bool + password string } func (s *fileScanner) Do(path interface{}, ds *utils.DoerState) string { @@ -100,7 +101,13 @@ func (s *fileScanner) Do(path interface{}, ds *utils.DoerState) string { } defer f.Close() - analysis, err := s.scanner.ScanFile(f, progressCh) + var analysis *vt.Object + if s.password != "" { + analysis, err = s.scanner.ScanFileWithParameters( + f, progressCh, map[string]string{"password": s.password}) + } else { + analysis, err = s.scanner.ScanFile(f, progressCh) + } if err != nil { return err.Error() } @@ -173,6 +180,7 @@ func NewScanFileCmd() *cobra.Command { scanner: client.NewFileScanner(), showInVT: viper.GetBool("open"), waitForCompletion: viper.GetBool("wait"), + password: viper.GetString("password"), printer: p, cli: client} c.DoWithStringsFromReader(s, argReader) @@ -182,6 +190,7 @@ func NewScanFileCmd() *cobra.Command { addThreadsFlag(cmd.Flags()) addOpenInVTFlag(cmd.Flags()) + addPasswordFlag(cmd.Flags()) addWaitForCompletionFlag(cmd.Flags()) addIncludeExcludeFlags(cmd.Flags()) cmd.MarkZshCompPositionalArgumentFile(1) @@ -308,3 +317,9 @@ func addWaitForCompletionFlag(flags *pflag.FlagSet) { "wait", "w", false, "Wait until the analysis is completed and show the analysis results") } + +func addPasswordFlag(flags *pflag.FlagSet) { + flags.StringP( + "password", "p", "", + "Password of the protected file") +} diff --git a/go.mod b/go.mod index e158a29..2c040ce 100644 --- a/go.mod +++ b/go.mod @@ -3,7 +3,7 @@ module github.com/VirusTotal/vt-cli go 1.14 require ( - github.com/VirusTotal/vt-go v0.0.0-20220413144842-e010bf48aaee + github.com/VirusTotal/vt-go v0.0.0-20230717142150-8431ff2cc00f github.com/briandowns/spinner v1.7.0 github.com/cavaliercoder/grab v2.0.0+incompatible github.com/dustin/go-humanize v1.0.0 diff --git a/go.sum b/go.sum index 7f33849..edf30d7 100644 --- a/go.sum +++ b/go.sum @@ -17,6 +17,8 @@ github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU= github.com/VirusTotal/vt-go v0.0.0-20220413144842-e010bf48aaee h1:JDhi0dS8y9QLMJZA7ezLyXHxYaMlyzX6MDkq0SSc304= github.com/VirusTotal/vt-go v0.0.0-20220413144842-e010bf48aaee/go.mod h1:u1+HeRyl/gQs67eDgVEWNE7+x+zCyXhdtNVrRJR5YPE= +github.com/VirusTotal/vt-go v0.0.0-20230717142150-8431ff2cc00f h1:49xl3zKS625gxmIRCfmwkXcTzB4cr4FcayRw/RcxhZs= +github.com/VirusTotal/vt-go v0.0.0-20230717142150-8431ff2cc00f/go.mod h1:u1+HeRyl/gQs67eDgVEWNE7+x+zCyXhdtNVrRJR5YPE= github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0= github.com/armon/circbuf v0.0.0-20150827004946-bbbad097214e/go.mod h1:3U/XgcO3hCbHZ8TKRvWD2dDTCfh9M9ya+I9JpbB7O8o=