package security
import "github.com/gohugoio/hugo/config/security"
Index ¶
- Variables
- func IsAccessDenied(err error) bool
- type AccessDeniedError
- type Config
- func DecodeConfig(cfg config.Provider) (Config, error)
- func (c Config) CheckAllowedExec(name string) error
- func (c Config) CheckAllowedGetEnv(name string) error
- func (c Config) CheckAllowedHTTPMethod(method string) error
- func (c Config) CheckAllowedHTTPURL(url string) error
- func (c Config) ToSecurityMap() map[string]any
- func (c Config) ToTOML() string
- type Exec
- type Funcs
- type HTTP
- type Whitelist
Variables ¶
var DefaultConfig = Config{ Exec: Exec{ Allow: NewWhitelist( "^dart-sass-embedded$", "^go$", "^npx$", "^postcss$", ), OsEnv: NewWhitelist("(?i)^(PATH|PATHEXT|APPDATA|TMP|TEMP|TERM)$"), }, Funcs: Funcs{ Getenv: NewWhitelist("^HUGO_"), }, HTTP: HTTP{ URLs: NewWhitelist(".*"), Methods: NewWhitelist("(?i)GET|POST"), }, }
DefaultConfig holds the default security policy.
Functions ¶
func IsAccessDenied ¶
IsAccessDenied reports whether err is an AccessDeniedError
Types ¶
type AccessDeniedError ¶
type AccessDeniedError struct {
// contains filtered or unexported fields
}
AccessDeniedError represents a security policy conflict.
func (*AccessDeniedError) Error ¶
func (e *AccessDeniedError) Error() string
type Config ¶
type Config struct { // Restricts access to os.Exec. Exec Exec `json:"exec"` // Restricts access to certain template funcs. Funcs Funcs `json:"funcs"` // Restricts access to resources.Get, getJSON, getCSV. HTTP HTTP `json:"http"` // Allow inline shortcodes EnableInlineShortcodes bool `json:"enableInlineShortcodes"` }
Config is the top level security config.
func DecodeConfig ¶
DecodeConfig creates a privacy Config from a given Hugo configuration.
func (Config) CheckAllowedExec ¶
func (Config) CheckAllowedGetEnv ¶
func (Config) CheckAllowedHTTPMethod ¶
func (Config) CheckAllowedHTTPURL ¶
func (Config) ToSecurityMap ¶
ToSecurityMap converts c to a map with 'security' as the root key.
func (Config) ToTOML ¶
ToTOML converts c to TOML with security as the root.
type Exec ¶
Exec holds os/exec policies.
type Funcs ¶
type Funcs struct { // OS env keys allowed to query in os.Getenv. Getenv Whitelist `json:"getenv"` }
Funcs holds template funcs policies.
type HTTP ¶
type HTTP struct { // URLs to allow in remote HTTP (resources.Get, getJSON, getCSV). URLs Whitelist `json:"urls"` // HTTP methods to allow. Methods Whitelist `json:"methods"` }
type Whitelist ¶
type Whitelist struct {
// contains filtered or unexported fields
}
Whitelist holds a whitelist.
func NewWhitelist ¶
NewWhitelist creates a new Whitelist from zero or more patterns. An empty patterns list or a pattern with the value 'none' will create a whitelist that will Accept noone.
func (Whitelist) Accept ¶
Accepted reports whether name is whitelisted.
func (Whitelist) MarshalJSON ¶
func (Whitelist) String ¶
Source Files ¶
docshelper.go securityConfig.go whitelist.go
- Version
- v0.100.0
- Published
- May 31, 2022
- Platform
- js/wasm
- Imports
- 14 packages
- Last checked
- 14 minutes ago –
Tools for package owners.