securityprefs

package
v0.11.0 Latest Latest
Warning

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

Go to latest
Published: Nov 29, 2026 License: MIT Imports: 5 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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

View Source
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.

View Source
const DefaultGenericSecrets = true

DefaultGenericSecrets is on: the read is one REST request a repository a day, free while nothing changed.

View Source
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

View Source
var ErrUnknownInterval = errors.New("unknown sweep interval")

ErrUnknownInterval is returned for a sweep interval that is not one of SweepIntervals.

Functions

func EncodeEnabled

func EncodeEnabled(on bool) map[string]string

EncodeEnabled is the write that stores the switch.

func EncodeGenericSecrets

func EncodeGenericSecrets(on bool) map[string]string

EncodeGenericSecrets is the write that stores Generic secrets.

func EncodeInterval

func EncodeInterval(seconds int) (map[string]string, error)

EncodeInterval is the write that stores the sweep's interval, or ErrUnknownInterval for one that is not one of SweepIntervals.

func Keys

func Keys() []string

Keys returns every key the settings are stored under.

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

func ValidInterval(seconds int) bool

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

func Decode(stored map[string]string) Config

Decode reads the stored settings. Each one missing, or holding a value its setter would refuse, reads as its default.

func Defaults

func Defaults() Config

Defaults returns the settings of a fresh database: off, sweeping every 30 minutes once turned on, generic secrets included.

func (Config) Every

func (c Config) Every() time.Duration

Every is how long the sweep waits after one sweep before the next.

Jump to

Keyboard shortcuts

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