@@ -77,6 +77,7 @@ type fileScanner struct {
7777 printer * utils.Printer
7878 showInVT bool
7979 waitForCompletion bool
80+ password string
8081}
8182
8283func (s * fileScanner ) Do (path interface {}, ds * utils.DoerState ) string {
@@ -100,7 +101,13 @@ func (s *fileScanner) Do(path interface{}, ds *utils.DoerState) string {
100101 }
101102 defer f .Close ()
102103
103- analysis , err := s .scanner .ScanFile (f , progressCh )
104+ var analysis * vt.Object
105+ if s .password != "" {
106+ analysis , err = s .scanner .ScanFileWithParameters (
107+ f , progressCh , map [string ]string {"password" : s .password })
108+ } else {
109+ analysis , err = s .scanner .ScanFile (f , progressCh )
110+ }
104111 if err != nil {
105112 return err .Error ()
106113 }
@@ -173,6 +180,7 @@ func NewScanFileCmd() *cobra.Command {
173180 scanner : client .NewFileScanner (),
174181 showInVT : viper .GetBool ("open" ),
175182 waitForCompletion : viper .GetBool ("wait" ),
183+ password : viper .GetString ("password" ),
176184 printer : p ,
177185 cli : client }
178186 c .DoWithStringsFromReader (s , argReader )
@@ -182,6 +190,7 @@ func NewScanFileCmd() *cobra.Command {
182190
183191 addThreadsFlag (cmd .Flags ())
184192 addOpenInVTFlag (cmd .Flags ())
193+ addPasswordFlag (cmd .Flags ())
185194 addWaitForCompletionFlag (cmd .Flags ())
186195 addIncludeExcludeFlags (cmd .Flags ())
187196 cmd .MarkZshCompPositionalArgumentFile (1 )
@@ -308,3 +317,9 @@ func addWaitForCompletionFlag(flags *pflag.FlagSet) {
308317 "wait" , "w" , false ,
309318 "Wait until the analysis is completed and show the analysis results" )
310319}
320+
321+ func addPasswordFlag (flags * pflag.FlagSet ) {
322+ flags .StringP (
323+ "password" , "p" , "" ,
324+ "Password of the protected file" )
325+ }
0 commit comments