notifications

package
v0.0.0-...-b918271 Latest Latest
Warning

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

Go to latest
Published: Dec 10, 2024 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	NotificationSubject = fmt.Sprintf("rekor-monitor workflow results for %s", time.Now().Format(time.RFC822))
)

Functions

func GenerateEmailBody

func GenerateEmailBody(monitoredIdentities []identity.MonitoredIdentity) (string, error)

func TriggerNotifications

func TriggerNotifications(notificationPlatforms []NotificationPlatform, identities []identity.MonitoredIdentity) error

Types

type ConfigMonitoredValues

type ConfigMonitoredValues struct {
	// CertificateIdentities contains a list of subjects and issuers
	CertificateIdentities []identity.CertificateIdentity `yaml:"certIdentities"`
	// Fingerprints contains a list of key fingerprints. Values are as follows:
	// For keys, certificates, and minisign, hex-encoded SHA-256 digest
	// of the DER-encoded PKIX public key or certificate
	// For SSH and PGP, the standard for each ecosystem:
	// For SSH, unpadded base-64 encoded SHA-256 digest of the key
	// For PGP, hex-encoded SHA-1 digest of a key, which can be either
	// a primary key or subkey
	Fingerprints []string `yaml:"fingerprints"`
	// Subjects contains a list of subjects that are not specified in a
	// certificate, such as a SSH key or PGP key email address
	Subjects []string `yaml:"subjects"`
	// OIDMatchers represents a list of OID extension fields and associated values,
	// which includes those constructed directly, those supported by Fulcio, and any constructed via dot notation.
	// These OIDMatchers are parsed into one list of OID extensions and matching values before being passed into MatchedIndices.
	OIDMatchers extensions.OIDMatchers `yaml:"oidMatchers"`
}

ConfigMonitoredValues holds a set of values to compare against a given entry. ConfigMonitoredValues holds Object Identifier extensions and associated values that can be constructed either directly from asn1.ObjectIdentifier, via OID extensions supported by Fulcio, or via dot notation.

type EmailNotificationInput

type EmailNotificationInput struct {
	RecipientEmailAddress string        `yaml:"recipientEmailAddress"`
	SenderEmailAddress    string        `yaml:"senderEmailAddress"`
	SenderSMTPUsername    string        `yaml:"senderSMTPUsername"`
	SenderSMTPPassword    string        `yaml:"senderSMTPPassword"`
	SMTPHostURL           string        `yaml:"SMTPHostURL"`
	SMTPCustomOptions     []mail.Option `yaml:"SMTPCustomOptions"`
}

EmailNotificationInput extends the NotificationPlatform interface to support found identity notification by sending emails to a specified user.

func (EmailNotificationInput) Send

func (emailNotificationInput EmailNotificationInput) Send(ctx context.Context, monitoredIdentities []identity.MonitoredIdentity) error

Send takes in an EmailNotification input and attempts to send the following list of found identities to the given email address. It returns an error in the case of failure.

type GitHubIssueInput

type GitHubIssueInput struct {
	AssigneeUsername string `yaml:"assigneeUsername"`
	RepositoryOwner  string `yaml:"repositoryOwner"`
	RepositoryName   string `yaml:"repositoryName"`
	// The PAT or other access token to authenticate creating an issue.
	// The authentication token requires repo write and push access.
	AuthenticationToken string `yaml:"authenticationToken"`
	// For users who want to pass in a custom client.
	// If nil, a default client with the given authentication token will be instantiated.
	GitHubClient *github.Client `yaml:"githubClient"`
}

GitHubIssueInput extends the NotificationPlatform interface to support found identity notification via creating new GitHub issues in a given repo.

func (GitHubIssueInput) Send

func (gitHubIssueInput GitHubIssueInput) Send(ctx context.Context, monitoredIdentities []identity.MonitoredIdentity) error

Send takes in a GitHubIssueInput and attempts to create the specified issue denoting the following found identities. It returns an error in the case of failure.

type IdentityMonitorConfiguration

type IdentityMonitorConfiguration struct {
	StartIndex                *int                       `yaml:"startIndex"`
	EndIndex                  *int                       `yaml:"endIndex"`
	MonitoredValues           ConfigMonitoredValues      `yaml:"monitoredValues"`
	OutputIdentitiesFile      string                     `yaml:"outputIdentities"`
	LogInfoFile               string                     `yaml:"logInfoFile"`
	IdentityMetadataFile      *string                    `yaml:"identityMetadataFile"`
	GitHubIssue               *GitHubIssueInput          `yaml:"githubIssue"`
	EmailNotificationSMTP     *EmailNotificationInput    `yaml:"emailNotificationSMTP"`
	EmailNotificationMailgun  *MailgunNotificationInput  `yaml:"emailNotificationMailgun"`
	EmailNotificationSendGrid *SendGridNotificationInput `yaml:"emailNotificationSendGrid"`
}

IdentityMonitorConfiguration holds the configuration settings for an identity monitor workflow run.

type MailgunNotificationInput

type MailgunNotificationInput struct {
	RecipientEmailAddress string `yaml:"recipientEmailAddress"`
	SenderEmailAddress    string `yaml:"senderEmailAddress"`
	MailgunAPIKey         string `yaml:"mailgunAPIKey"`
	MailgunDomainName     string `yaml:"mailgunDomainName"`
}

MailgunNotificationInput extends the NotificationPlatform interface to support found identity notification by sending emails to a specified user via Mailgun.

func (MailgunNotificationInput) Send

func (mailgunNotificationInput MailgunNotificationInput) Send(ctx context.Context, monitoredIdentities []identity.MonitoredIdentity) error

Send takes in an MailgunNotificationInput and attempts to send the following list of found identities to the given email address. It returns an error in the case of failure.

type NotificationPlatform

type NotificationPlatform interface {
	Send(context.Context, []identity.MonitoredIdentity) error
}

NotificationPlatform provides the Send() method to handle alerting logic for the respective notification platform extending the interface.

func CreateNotificationPool

func CreateNotificationPool(config IdentityMonitorConfiguration) []NotificationPlatform

type SendGridNotificationInput

type SendGridNotificationInput struct {
	RecipientName         string `yaml:"recipientName"`
	RecipientEmailAddress string `yaml:"recipientEmailAddress"`
	SenderName            string `yaml:"senderName"`
	SenderEmailAddress    string `yaml:"senderEmailAddress"`
	SendGridAPIKey        string `yaml:"sendGridAPIKey"`
}

SendGrid extends the NotificationPlatform interface to support found identity notification by sending emails to a specified user via SendGrid.

func (SendGridNotificationInput) Send

func (sendGridNotificationInput SendGridNotificationInput) Send(ctx context.Context, monitoredIdentities []identity.MonitoredIdentity) error

Send takes in an SendGridNotificationInput and attempts to send the following list of found identities to the given email address. It returns an error in the case of failure.

Jump to

Keyboard shortcuts

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