Documentation ¶
Index ¶
- Constants
- Variables
- func ActiveSecurityLevel() uint8
- func AddToDebugInfo(di *debug.Info)
- func DeleteMitigationLevel(id string)
- func IsValidSecurityLevel(level uint8) bool
- func IsValidSecurityLevelMask(level uint8) bool
- func NetworkRatingEnabled() bool
- func SecurityLevelString(level uint8) string
- func SelectedSecurityLevel() uint8
- func SetMitigationLevel(id string, mitigation uint8)
- func SetNetworkRating(enabled bool) error
- type SecurityLevelOptionFunc
- type SelectedSecurityLevelRecord
- type SystemStatusRecord
- type Threat
- type ThreatPayload
Constants ¶
const ( SecurityLevelOff uint8 = 0 SecurityLevelNormal uint8 = 1 SecurityLevelHigh uint8 = 2 SecurityLevelExtreme uint8 = 4 SecurityLevelsNormalAndHigh uint8 = SecurityLevelNormal | SecurityLevelHigh SecurityLevelsNormalAndExtreme uint8 = SecurityLevelNormal | SecurityLevelExtreme SecurityLevelsHighAndExtreme uint8 = SecurityLevelHigh | SecurityLevelExtreme SecurityLevelsAll uint8 = SecurityLevelNormal | SecurityLevelHigh | SecurityLevelExtreme )
Security levels.
const DisplayHintSecurityLevel string = "security level"
DisplayHintSecurityLevel is an external option hint for security levels. It's meant to be used as a value for config.DisplayHintAnnotation.
Variables ¶
var AllSecurityLevelValues = append([]config.PossibleValue{ { Name: "Off", Value: SecurityLevelOff, Description: "Setting is always disabled.", }, }, SecurityLevelValues..., )
AllSecurityLevelValues is like SecurityLevelValues but also includes Off.
var (
CfgEnableNetworkRatingSystemKey = "core/enableNetworkRating"
)
Configuration Keys.
var SecurityLevelValues = []config.PossibleValue{ { Name: "Trusted / Home Network", Value: SecurityLevelsAll, Description: "Setting is always enabled.", }, { Name: "Untrusted / Public Network", Value: SecurityLevelsHighAndExtreme, Description: "Setting is enabled in untrusted and dangerous networks.", }, { Name: "Danger / Hacked Network", Value: SecurityLevelExtreme, Description: "Setting is enabled only in dangerous networks.", }, }
SecurityLevelValues defines all possible security levels.
Functions ¶
func ActiveSecurityLevel ¶
func ActiveSecurityLevel() uint8
ActiveSecurityLevel returns the currently active security level.
func AddToDebugInfo ¶ added in v0.6.6
AddToDebugInfo adds the system status to the given debug.Info.
func DeleteMitigationLevel ¶ added in v0.6.0
func DeleteMitigationLevel(id string)
DeleteMitigationLevel deletes the mitigation level for id.
func IsValidSecurityLevel ¶ added in v0.6.0
IsValidSecurityLevel returns true if level is a valid, single security level. Level is also invalid if it's a bitmask with more that one security level set.
func IsValidSecurityLevelMask ¶ added in v0.6.0
IsValidSecurityLevelMask returns true if level is a valid security level mask. It's like IsValidSecurityLevel but also allows bitmask combinations.
func NetworkRatingEnabled ¶ added in v0.7.19
func NetworkRatingEnabled() bool
NetworkRatingEnabled returns true if the network rating system has been enabled.
func SecurityLevelString ¶ added in v0.6.0
SecurityLevelString returns the given security level as a string.
func SelectedSecurityLevel ¶
func SelectedSecurityLevel() uint8
SelectedSecurityLevel returns the security level as selected by the user.
func SetMitigationLevel ¶ added in v0.6.0
SetMitigationLevel sets the mitigation level for id to mitigation. If mitigation is SecurityLevelOff the mitigation record will be removed. If mitigation is an invalid level the call to SetMitigationLevel is a no-op.
func SetNetworkRating ¶ added in v0.7.19
SetNetworkRating enables or disables the network rating system.
Types ¶
type SecurityLevelOptionFunc ¶ added in v0.6.0
SecurityLevelOptionFunc can be called with a minimum security level and returns whether or not a given security option is enabled or not. Use SecurityLevelOption() to get a SecurityLevelOptionFunc for a specific option.
func SecurityLevelOption ¶
func SecurityLevelOption(name string) SecurityLevelOptionFunc
SecurityLevelOption returns a function to check if the option identified by name is active at a given minimum security level. The returned function is safe for concurrent use with configuration updates.
type SelectedSecurityLevelRecord ¶ added in v0.6.0
SelectedSecurityLevelRecord is used as a dummy record.Record to provide a simply runtime-configuration for the user. It is write-only and exposed at "runtime:system/security-level".
type SystemStatusRecord ¶ added in v0.6.0
type SystemStatusRecord struct { record.Base sync.Mutex // ActiveSecurityLevel holds the currently // active security level. ActiveSecurityLevel uint8 // SelectedSecurityLevel holds the security level // as selected by the user. SelectedSecurityLevel uint8 // ThreatMitigationLevel holds the security level // as selected by the auto-pilot. ThreatMitigationLevel uint8 // OnlineStatus holds the current online status as // seen by the netenv package. OnlineStatus netenv.OnlineStatus // CaptivePortal holds all information about the captive // portal of the network the portmaster is currently // connected to, if any. CaptivePortal *netenv.CaptivePortal }
SystemStatusRecord describes the overall status of the Portmaster. It's a read-only record exposed via runtime:system/status.
type Threat ¶
type Threat struct {
*notifications.Notification
}
Threat represents a threat to the system. A threat is basically a notification with strong typed EventData. Use the methods expored on Threat to manipulate the EventData field and push updates of the notification. Do not use EventData directly!
func NewThreat ¶ added in v0.6.0
NewThreat returns a new threat. Note that the threat only gets published once Publish is called.
Example:
threat := NewThreat("portscan", "Someone is scanning you"). SetData(portscanResult). SetMitigationLevel(SecurityLevelExtreme). Publish() // Once you're done, delete the threat threat.Delete().Publish()
func (*Threat) Payload ¶ added in v0.6.0
func (t *Threat) Payload() ThreatPayload
Payload returns a copy of the threat payload.
func (*Threat) Publish ¶ added in v0.6.0
Publish publishes the current threat. Publish should always be called when changes to the threat are recorded.
func (*Threat) SetMitigationLevel ¶ added in v0.6.0
SetMitigationLevel sets the mitigation level of the threat data.
type ThreatPayload ¶ added in v0.6.0
type ThreatPayload struct { // MitigationLevel holds the recommended security // level to mitigate the threat. MitigationLevel uint8 // Started holds the UNIX epoch timestamp in seconds // at which the threat has been detected the first time. Started int64 // Ended holds the UNIX epoch timestamp in seconds // at which the threat has been detected the last time. Ended int64 // Data may holds threat-specific data. Data interface{} }
ThreatPayload holds threat related information.