config

package
v0.0.0-...-2f0a4f1 Latest Latest
Warning

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

Go to latest
Published: Jul 1, 2023 License: AGPL-3.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const FamedLabelKey = "famed"

FamedLabelKey is the label used in GitHub to tell our backend that this issue should be tracked by famed. // Todo: make it configurable.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	App struct {
		Host     string    `koanf:"host"`
		Port     string    `koanf:"port"`
		URL      string    `koanf:"url"`
		LogLevel log.Level `koanf:"loglevel"`
	} `koanf:"app"`

	DB struct {
		TimeOut time.Duration `koanf:"timeout"`
		URL     string        `koanf:"url"`
		Name    string        `koanf:"name"`
	} `koanf:"db"`

	NewRelic struct {
		Name    string `koanf:"name"`
		Key     string `koanf:"key"`
		Enabled bool   `koanf:"enabled"`
	} `koanf:"newrelic"`

	// Scanners allows you to choose which scanners will be activated. If no scanners is enabled then the web handler will also be disabled
	Scanners struct {
		DockerHost   string `koanf:"dockerhost"`
		DockerCacert string `koanf:"dockercacert"`
		DockerCert   string `koanf:"dockercert"`
		DockerKey    string `koanf:"dockerkey"`
		TestSSL      bool   `koanf:"testssl"`
		Slither      bool   `koanf:"slither"`
		Semgrep      bool   `koanf:"semgrep"`
	} `koanf:"scanners"`

	Email struct {
		URL string `koanf:"url"`
	}

	Github struct {
		Host          string `koanf:"host"`
		Key           string `koanf:"key"`
		KeyEnclave    *memguard.Enclave
		WebhookSecret string `koanf:"webhooksecret"`
		AppID         int64  `koanf:"appid"`
		BotLogin      string `koanf:"botlogin"`
	} `koanf:"github"`

	Famed struct {
		Labels                   map[string]model.Label          `koanf:"labels"`
		Rewards                  map[model.IssueSeverity]float64 `koanf:"rewards"`
		Currency                 string                          `koanf:"currency"`
		DaysToFix                int                             `koanf:"daystofix"`
		UpdateFrequency          int                             `koanf:"updatefrequency"`
		InstallationPRBranchName string                          `koanf:"installationPRBranchName"`
		ScannerWorkflowPath      string                          `koanf:"scannerWorkflowPath"`
		PRAuthorEmail            string                          `koanf:"prAuthorEmail"`
	} `koanf:"famed"`

	// TODO this should probably not be in memory
	RedTeamLogins map[string]string `koanf:"redteamlogins"`

	Admin struct {
		Username string `koanf:"username"`
		Password string `koanf:"password"`
	} `koanf:"admin"`
}

Config is the complete representation of the configuration, it is authoritative on configuration names, hierarchy, structure and type.

func NewConfig

func NewConfig(filePath string) (config *Config, err error)

NewConfig returns a fully initialized(? maybe not the best word) configuration. The configuration can be set and loaded from different sources. The following load order is used: Defaults values, which can be overridden by JSON config from XDG path, which can be overridden by dotenv file (./.env file), which can be overridden by environment variables.

Jump to

Keyboard shortcuts

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