pcmt/modules/localbreach/breach.go
surtur cd2a7ed6de
All checks were successful
continuous-integration/drone/push Build is passing
localbreach: add hashPeppered field
2023-08-07 22:06:18 +02:00

52 lines
1.2 KiB
Go

// Copyright 2023 wanderer <a_mirre at utb dot cz>
// SPDX-License-Identifier: AGPL-3.0-only
package localbreach
import (
"os"
"time"
"gopkg.in/yaml.v2"
)
type BreachDataSchema struct {
Name string `yaml:"name" validate:"required,name"`
Time time.Time `yaml:"time"`
IsVerified bool `yaml:"isVerified"`
ContainsPasswords bool `yaml:"containsPasswds"`
ContainsHashes bool `yaml:"containsHashes"`
HashType string `yaml:"hashType"`
HashSalted bool `yaml:"hashSalted"`
HashPeppered bool `yaml:"hashPeppered"`
ContainsUsernames bool `yaml:"containsUsernames"`
ContainsEmails bool `yaml:"containsEmails"`
Data any `yaml:"data"`
}
// Load loads local breach data.
func Load(path string) (*BreachDataSchema, error) {
b, err := os.ReadFile(path)
if err != nil {
return nil, err
}
localBreach, err := loadLocalBreach(b)
if err != nil {
return nil, err
}
return localBreach, nil
}
func loadLocalBreach(b []byte) (*BreachDataSchema, error) {
localBreach := new(BreachDataSchema)
err := yaml.Unmarshal(b, localBreach)
if err != nil {
return nil, err
}
return localBreach, nil
}