summaryrefslogtreecommitdiffstats
path: root/cmd/breachforum.go
diff options
context:
space:
mode:
Diffstat (limited to 'cmd/breachforum.go')
-rw-r--r--cmd/breachforum.go39
1 files changed, 39 insertions, 0 deletions
diff --git a/cmd/breachforum.go b/cmd/breachforum.go
new file mode 100644
index 0000000..366092c
--- /dev/null
+++ b/cmd/breachforum.go
@@ -0,0 +1,39 @@
+package cmd
+
+import (
+ "git.db.org.ai/dborg/internal/formatter"
+ "git.db.org.ai/dborg/internal/models"
+ "github.com/spf13/cobra"
+)
+
+var breachforumCmd = &cobra.Command{
+ Use: "breachforum [search]",
+ Short: "Search BreachForum data",
+ Long: `Search breachdetect index for BreachForum messages and detections`,
+ Args: cobra.ExactArgs(1),
+ RunE: runBreachForumSearch,
+}
+
+func init() {
+ rootCmd.AddCommand(breachforumCmd)
+ breachforumCmd.Flags().IntP("max_hits", "m", 10, "Maximum number of hits to return")
+}
+
+func runBreachForumSearch(cmd *cobra.Command, args []string) error {
+ c, err := newUnauthenticatedClient()
+ if err != nil {
+ return err
+ }
+
+ params := &models.BreachForumSearchParams{
+ Search: args[0],
+ }
+ params.MaxHits, _ = cmd.Flags().GetInt("max_hits")
+
+ response, err := c.SearchBreachForum(params)
+ if err != nil {
+ return err
+ }
+
+ return formatter.FormatBreachForumResults(response, IsJSONOutput())
+}