MCPcopy
hub / github.com/moonD4rk/HackBrowserData / Write

Method Write

output/output.go:59–78  ·  view source on GitHub ↗

Write aggregates all accumulated data by category and writes each non-empty category to its own file (e.g. password.csv, cookie.json).

()

Source from the content-addressed store, hash-verified

57// Write aggregates all accumulated data by category and writes each
58// non-empty category to its own file (e.g. password.csv, cookie.json).
59func (o *Writer) Write() error {
60 if err := os.MkdirAll(o.dir, 0o750); err != nil {
61 return fmt.Errorf("create output dir: %w", err)
62 }
63 agg := o.aggregate()
64 for _, cs := range agg {
65 if err := o.writeFile(cs.name, cs.rows); err != nil {
66 return err
67 }
68 }
69 if len(agg) > 0 {
70 fmt.Fprintln(os.Stderr)
71 log.Infof("Exported to %s/", o.dir)
72 for _, cs := range agg {
73 filename := fmt.Sprintf("%s.%s", cs.name, o.formatter.ext())
74 log.Infof(" %-24s %d entries", filename, len(cs.rows))
75 }
76 }
77 return nil
78}
79
80// categoryRows holds one category's aggregated rows for writing.
81type categoryRows struct {

Callers 15

formatMethod · 0.95
TestWrite_CSV_PasswordFunction · 0.95
TestWrite_CSV_CookieFunction · 0.95
TestWrite_CSV_HistoryFunction · 0.95
TestWrite_CSV_UTF8BOMFunction · 0.95
TestWrite_JSON_PasswordFunction · 0.95
TestWrite_JSON_CookieFunction · 0.95
TestWrite_JSON_NoBOMFunction · 0.95
TestWrite_CookieEditorFunction · 0.95
TestWrite_NoDataFunction · 0.95

Calls 5

aggregateMethod · 0.95
writeFileMethod · 0.95
InfofFunction · 0.92
ErrorfMethod · 0.80
extMethod · 0.65

Tested by 14

TestWrite_CSV_PasswordFunction · 0.76
TestWrite_CSV_CookieFunction · 0.76
TestWrite_CSV_HistoryFunction · 0.76
TestWrite_CSV_UTF8BOMFunction · 0.76
TestWrite_JSON_PasswordFunction · 0.76
TestWrite_JSON_CookieFunction · 0.76
TestWrite_JSON_NoBOMFunction · 0.76
TestWrite_CookieEditorFunction · 0.76
TestWrite_NoDataFunction · 0.76
buildTestBinaryCookiesFunction · 0.64