From 07662d9403eb85b39e1ffcf91014bbf36efd1c5a Mon Sep 17 00:00:00 2001 From: s Date: Thu, 13 Nov 2025 22:25:02 -0500 Subject: refactor: break down large osint.go file into separate command modules and add helper functions --- cmd/breachforum.go | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 cmd/breachforum.go (limited to 'cmd/breachforum.go') 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()) +} -- cgit v1.2.3