mirror of
https://github.com/moonD4rk/HackBrowserData.git
synced 2026-12-04 05:43:27 +01:00
A Stat error other than not-exist was reported as absent, and the --zip archive was readable by other users. The rest is review follow-up: export no longer prints, one runner type, shared name helpers, a trimmed log API.
67 lines
1.2 KiB
Go
67 lines
1.2 KiB
Go
package category
|
|
|
|
import "fmt"
|
|
|
|
// Numbering starts at 1, so the zero Category means "none".
|
|
type Category int
|
|
|
|
const (
|
|
Password Category = iota + 1
|
|
Cookie
|
|
Bookmark
|
|
History
|
|
Download
|
|
CreditCard
|
|
Extension
|
|
LocalStorage
|
|
SessionStorage
|
|
)
|
|
|
|
// String's values are the -c values and the output file names, so they cannot change.
|
|
func (c Category) String() string {
|
|
switch c {
|
|
case Password:
|
|
return "password"
|
|
case Cookie:
|
|
return "cookie"
|
|
case Bookmark:
|
|
return "bookmark"
|
|
case History:
|
|
return "history"
|
|
case Download:
|
|
return "download"
|
|
case CreditCard:
|
|
return "creditcard"
|
|
case Extension:
|
|
return "extension"
|
|
case LocalStorage:
|
|
return "localstorage"
|
|
case SessionStorage:
|
|
return "sessionstorage"
|
|
default:
|
|
return "unknown"
|
|
}
|
|
}
|
|
|
|
func All() []Category {
|
|
return []Category{Password, Cookie, Bookmark, History, Download, CreditCard, Extension, LocalStorage, SessionStorage}
|
|
}
|
|
|
|
func Names() []string {
|
|
all := All()
|
|
names := make([]string, len(all))
|
|
for i, c := range all {
|
|
names[i] = c.String()
|
|
}
|
|
return names
|
|
}
|
|
|
|
func Parse(s string) (Category, error) {
|
|
for _, c := range All() {
|
|
if c.String() == s {
|
|
return c, nil
|
|
}
|
|
}
|
|
return 0, fmt.Errorf("unknown category: %q", s)
|
|
}
|