NewMonitorPartnerHashDownloadCmd returns a command for downloading files from your monitor account.
()
| 109 | // NewMonitorPartnerHashDownloadCmd returns a command for downloading files from your |
| 110 | // monitor account. |
| 111 | func NewMonitorPartnerHashDownloadCmd() *cobra.Command { |
| 112 | cmd := &cobra.Command{ |
| 113 | Use: "download [sha256]...", |
| 114 | Short: "Download files from your monitor partner account", |
| 115 | Long: monitorPartnerHashDownloadCmdHelp, |
| 116 | Example: monitorPartnerHashDownloadCmdExample, |
| 117 | RunE: func(cmd *cobra.Command, args []string) error { |
| 118 | var argReader utils.StringReader |
| 119 | if len(args) == 0 { |
| 120 | return errors.New("No hash provided") |
| 121 | } else if len(args) == 1 && args[0] == "-" { |
| 122 | argReader = utils.NewStringIOReader(os.Stdin) |
| 123 | } else { |
| 124 | argReader = utils.NewStringArrayReader(args) |
| 125 | } |
| 126 | client, err := NewAPIClient() |
| 127 | if err != nil { |
| 128 | return err |
| 129 | } |
| 130 | re, _ := regexp.Compile("[[:xdigit:]]{64}") |
| 131 | monitorHashes := utils.NewFilteredStringReader(argReader, re) |
| 132 | |
| 133 | c := utils.NewCoordinator(viper.GetInt("threads")) |
| 134 | c.DoWithStringsFromReader( |
| 135 | &monitorPartnerDownloader{fileDownloader: newFileDownloader(client)}, |
| 136 | monitorHashes) |
| 137 | return err |
| 138 | }, |
| 139 | } |
| 140 | |
| 141 | addThreadsFlag(cmd.Flags()) |
| 142 | addOutputFlag(cmd.Flags()) |
| 143 | return cmd |
| 144 | } |
| 145 | |
| 146 | var monitorPartnerCmdHelp = `Manage your VirusTotal Monitor Partner account. |
| 147 |
no test coverage detected