-
-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1116 from sundowndev/feat/remotelibapi
Add scanners cli command
- Loading branch information
Showing
17 changed files
with
146 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
package cmd | ||
|
||
import ( | ||
"fmt" | ||
"github.com/spf13/cobra" | ||
"github.com/sundowndev/phoneinfoga/v2/lib/filter" | ||
"github.com/sundowndev/phoneinfoga/v2/lib/remote" | ||
) | ||
|
||
type ScannersCmdOptions struct { | ||
Plugin []string | ||
} | ||
|
||
func init() { | ||
opts := &ScannersCmdOptions{} | ||
scannersCmd := NewScannersCmd(opts) | ||
|
||
fl := scannersCmd.Flags() | ||
fl.StringSliceVar(&opts.Plugin, "plugin", []string{}, "Output file") | ||
|
||
rootCmd.AddCommand(scannersCmd) | ||
} | ||
|
||
func NewScannersCmd(opts *ScannersCmdOptions) *cobra.Command { | ||
cmd := &cobra.Command{ | ||
Use: "scanners", | ||
Example: "phoneinfoga scanners", | ||
Short: "Display list of loaded scanners", | ||
Run: func(cmd *cobra.Command, args []string) { | ||
for _, p := range opts.Plugin { | ||
err := remote.OpenPlugin(p) | ||
if err != nil { | ||
exitWithError(err) | ||
} | ||
} | ||
|
||
remoteLibrary := remote.NewLibrary(filter.NewEngine()) | ||
remote.InitScanners(remoteLibrary) | ||
|
||
for i, s := range remoteLibrary.GetAllScanners() { | ||
fmt.Printf("%s\n%s\n", s.Name(), s.Description()) | ||
if i < len(remoteLibrary.GetAllScanners()) { | ||
fmt.Printf("\n") | ||
} | ||
} | ||
}, | ||
} | ||
return cmd | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.