haveibeenbreached

package module
v0.0.0-...-a5f8d6a Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 24, 2021 License: MIT Imports: 9 Imported by: 0

README

haveibeenbreached

A simple clone of haveibeenpwned written in Go, and implemented using the AWS stack and the Serverless Framework:

  • Serverless framework
  • Cloudformation
  • Lambda
  • DynamoDB
  • Simple Queue Service

Getting started

You'll need an AWS account before proceeding with the remaining steps.

Install the Serverless Framework

$ npm install -g serverless

Configure your AWS credentials

https://www.serverless.com/framework/docs/providers/aws/cli-reference/config-credentials/

Deploy haveibeenbreached

$ make deploy

Lambda functions

createBreach

Creates a new breach.

$ sls invoke -f createBreach -l --path exampleEvents/createBreach.json
addAccountsToBreach

Adds a list of email accounts to an existing breach.

$ sls invoke -f addAccountsToBreach -l --path exampleEvents/addAccountsToBreach.json
findAccount

Retrieves an existing email account that has been involved in any breaches.

$ sls invoke -f findAccount -l --path exampleEvents/findAccount.json
notifyMe

Subscribes an email for breach notifications. It sends a subscription message to SQS.

$ sls invoke -f notifyMe -l --path exampleEvents/notifyMe.json
sendSubscriptionEmail

Processes subscription messages on SQS, and sends subscription confirmation emails (not implemented) to subscribers.

notifySubscribersOfBreach

Send emails to subscribers whose emails are involved in a given breach.

$ sls invoke -f notifySubscribersOfBreach -l --path exampleEvents/notifySubscribersOfBreach.json

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BreachPartitionKey

func BreachPartitionKey(breachName string) string

func BreachSortKey

func BreachSortKey(breachName string) string

func IsValidEmail

func IsValidEmail(email string) bool

Types

type Account

type Account struct {
	Username Username
	Breaches []string
}

func (Account) Item

func (a Account) Item() AccountItem

func (Account) ToItem

func (a Account) ToItem() DBItem

type AccountItem

type AccountItem struct {
	PK       string
	SK       string
	Type     string
	Username string
	Breaches []string
}

func (AccountItem) GetUsername

func (a AccountItem) GetUsername() (Username, error)

func (AccountItem) ToAccount

func (a AccountItem) ToAccount() (Account, error)

type Breach

type Breach struct {
	BreachName       string
	Title            string
	Domain           string
	Description      string
	BreachDate       time.Time
	BreachedAccounts []string
}

/ Breach represents the breach domain model.

func (Breach) AddAccounts

func (b Breach) AddAccounts(accounts []string) Breach

func (Breach) Item

func (b Breach) Item() BreachItem

func (Breach) PartitionKey

func (b Breach) PartitionKey() string

func (Breach) SortKey

func (b Breach) SortKey() string

func (Breach) ToItem

func (b Breach) ToItem() DBItem

type BreachItem

type BreachItem struct {
	PK               string
	SK               string
	Type             string
	BreachName       string
	Title            string
	Domain           string
	Description      string
	BreachDate       time.Time
	BreachedAccounts []string
}

/ BreachItem represents the schema stored in the database.

func (BreachItem) ToBreach

func (b BreachItem) ToBreach() Breach

type DBItem

type DBItem interface {
	// contains filtered or unexported methods
}

type EmailAccount

type EmailAccount struct {
	Domain string
	Alias  string
}

func NewEmailAccount

func NewEmailAccount(emailStr string) (EmailAccount, error)

func (EmailAccount) PartitionKey

func (e EmailAccount) PartitionKey() string

func (EmailAccount) SortKey

func (e EmailAccount) SortKey() string

func (EmailAccount) String

func (e EmailAccount) String() string

type Itemable

type Itemable interface {
	ToItem() DBItem
}

type MessageQueue

type MessageQueue struct {
	// contains filtered or unexported fields
}

func NewMessageQueue

func NewMessageQueue(queue *sqs.SQS) MessageQueue

func (MessageQueue) SendMessage

func (m MessageQueue) SendMessage(input SendMessageInput) error

type Repo

type Repo struct {
	// contains filtered or unexported fields
}

func NewRepo

func NewRepo(db *dynamodb.DynamoDB) Repo

func (Repo) GetAccount

func (r Repo) GetAccount(username Username) (*Account, error)

func (Repo) GetBreach

func (r Repo) GetBreach(breachName string) (*Breach, error)

func (Repo) PutItem

func (r Repo) PutItem(itemable Itemable) error

func (Repo) PutItems

func (r Repo) PutItems(items []Itemable) error

type SendMessageInput

type SendMessageInput struct {
	MessageBody string
	QueueURL    string
}

type Subscriber

type Subscriber struct {
	Email string
}

func NewSubscriber

func NewSubscriber(email string) (Subscriber, error)

func (Subscriber) Item

func (s Subscriber) Item() SubscriberItem

func (Subscriber) PartitionKey

func (s Subscriber) PartitionKey() string

func (Subscriber) SortKey

func (s Subscriber) SortKey() string

func (Subscriber) ToItem

func (s Subscriber) ToItem() DBItem

type SubscriberItem

type SubscriberItem struct {
	PK    string
	SK    string
	Type  string
	Email string
}

func (SubscriberItem) ToSubscriber

func (s SubscriberItem) ToSubscriber() Subscriber

type Username

type Username interface {
	String() string
	PartitionKey() string
	SortKey() string
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL