Documentation
¶
Overview ¶
Package securityprefs declares the Security tab's settings: Security alerts (beta), the Labs switch that turns all of it on, off on every install until the user turns it on; how often its sweep reads the alerts again; and Generic secrets, whether it reads the generic secret types GitHub's default secret list leaves out. The settings package writes them, under the keys declared here, and the secalerts package reads them.
It is a leaf: it imports only prefval, never the store or a service, so settings writes the keys without depending on secalerts, nor secalerts on settings.
Index ¶
Constants ¶
const ( // KeyEnabled is Security alerts (beta): off, the default, the window shows none of the // Security tab, and no sweep runs, so no alert is read from GitHub. KeyEnabled = "security.enabled" // KeySweepInterval is how often, in seconds, the sweep reads the alerts again on its // own: one of SweepIntervals. KeySweepInterval = "security.sweepInterval" // KeyGenericSecrets is Generic secrets: on, the default, the sweep also reads, once a // day, the secret types GitHub's default list leaves out (passwords, generic API keys, // and high-entropy strings), where secret scanning is on. KeyGenericSecrets = "security.genericSecrets" )
The preferences the settings are stored under. Settings writes them.
const DefaultGenericSecrets = true
DefaultGenericSecrets is on: the read is one REST request a repository a day, free while nothing changed.
const DefaultSweepInterval = 1800
DefaultSweepInterval is how often a fresh database sweeps, in seconds: every 30 minutes. A sweep that finds nothing changed costs about a GraphQL point for every 50 repositories, and its code and secret scanning reads are free (GitHub answers 304 Not Modified).
Variables ¶
var ErrUnknownInterval = errors.New("unknown sweep interval")
ErrUnknownInterval is returned for a sweep interval that is not one of SweepIntervals.
Functions ¶
func EncodeEnabled ¶
EncodeEnabled is the write that stores the switch.
func EncodeGenericSecrets ¶
EncodeGenericSecrets is the write that stores Generic secrets.
func EncodeInterval ¶
EncodeInterval is the write that stores the sweep's interval, or ErrUnknownInterval for one that is not one of SweepIntervals.
func SweepIntervals ¶
func SweepIntervals() []int
SweepIntervals returns the intervals the sweep can be set to, in seconds, shortest first: 10 and 15 minutes, half an hour, an hour, and two hours. There is no off: the Labs switch is.
func ValidInterval ¶
ValidInterval reports whether seconds is one of SweepIntervals.
Types ¶
type Config ¶
type Config struct {
// Enabled is Security alerts (beta): off, the tab is hidden and no sweep runs.
Enabled bool `json:"enabled"`
// SweepInterval is how often, in seconds, the sweep reads the alerts again.
SweepInterval int `json:"sweepInterval"`
// GenericSecrets is Generic secrets: on, the sweep also reads the generic secret types
// once a day, and the Security tab shows them; off, it reads none and shows none.
GenericSecrets bool `json:"genericSecrets"`
}
Config is the Security tab's settings, as Settings shows them.
func Decode ¶
Decode reads the stored settings. Each one missing, or holding a value its setter would refuse, reads as its default.