exchange

package
v3.1.0-rc.3 Latest Latest
Warning

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

Go to latest
Published: Jul 16, 2026 License: GPL-3.0 Imports: 6 Imported by: 0

Documentation

Overview

Package exchange defines the public runtime exchange keyspace shared by Nauthilus plugins.

Index

Constants

View Source
const (
	// Prefix is the top-level runtime key prefix for standard exchange values.
	Prefix = "plugin.exchange."

	// KeyDecisionSources stores stable analytics source names selected by policy-aware components.
	KeyDecisionSources = Prefix + "decision_sources"

	// KeyFeaturePrefix is the prefix for standard feature-marker runtime keys.
	KeyFeaturePrefix = Prefix + "feature."

	// KeyGeoIP stores GeoIP and ASN enrichment fields.
	KeyGeoIP = Prefix + "geoip"

	// KeyGeoIPReputation stores reputation scores and decision hints.
	KeyGeoIPReputation = Prefix + "geoip_reputation"

	// KeyFailedLoginHotspot stores failed-login hotspot counters.
	KeyFailedLoginHotspot = Prefix + "failed_login_hotspot"

	// KeyAccountProtection stores account-protection state.
	KeyAccountProtection = Prefix + "account_protection"

	// KeyGlobalPattern stores global pattern counters.
	KeyGlobalPattern = Prefix + "global_pattern"

	// KeyDynamicResponse stores dynamic response diagnostics.
	KeyDynamicResponse = Prefix + "dynamic_response"

	// KeyHaveIBeenPwned stores safe Have I Been Pwned result fields.
	KeyHaveIBeenPwned = Prefix + "haveibeenpwnd"
)
View Source
const (
	// FeatureBlocklist identifies external blocklist policy decisions.
	FeatureBlocklist = "blocklist"

	// FeatureRBL identifies built-in RBL policy decisions.
	FeatureRBL = "rbl"

	// FeatureBruteForce identifies built-in brute-force policy decisions.
	FeatureBruteForce = "brute_force"

	// FeatureGeoIPPolicy identifies delegated GeoIP policy decisions.
	FeatureGeoIPPolicy = "geoip_policyd"

	// FeatureFailedLoginHotspot identifies failed-login hotspot decisions.
	FeatureFailedLoginHotspot = "failed_login_hotspot"

	// FeatureAccountProtection identifies account-protection policy decisions.
	FeatureAccountProtection = "account_protection"

	// FeatureGeoIPReputation identifies reputation-based GeoIP decisions.
	FeatureGeoIPReputation = "geoip_reputation"

	// FeatureGlobalPattern identifies global-pattern policy decisions.
	FeatureGlobalPattern = "global_pattern"

	// FeatureDynamicResponse identifies dynamic response decisions.
	FeatureDynamicResponse = "dynamic_response"

	// FeatureHaveIBeenPwned identifies Have I Been Pwned decisions.
	FeatureHaveIBeenPwned = "haveibeenpwnd"
)
View Source
const (
	// FieldTriggered marks a feature marker as contributing to the selected decision.
	FieldTriggered = "triggered"

	// FieldDecision stores a bounded decision hint such as "suspicious".
	FieldDecision = "decision"

	// FieldSource stores a low-cardinality producer or data-source name.
	FieldSource = "source"

	// FieldReason stores an optional bounded reason string.
	FieldReason = "reason"

	// FieldHashInfo stores the HIBP short prefix/count value used by analytics.
	FieldHashInfo = "hash_info"

	// FieldLeaked stores whether HIBP reported a leaked password hash.
	FieldLeaked = "leaked"

	// FieldCount stores a non-negative HIBP leak count.
	FieldCount = "count"
)
View Source
const (
	// FieldPrivacyLookupState stores the privacy lookup availability state.
	FieldPrivacyLookupState = "privacy_lookup_state"
	// FieldPrivacyDetected stores the aggregate privacy detection result.
	FieldPrivacyDetected = "privacy_detected"
	// FieldPrivacyClasses stores stable matched privacy classes.
	FieldPrivacyClasses = "privacy_classes"
	// FieldPrivacyPrimaryClass stores the selected primary privacy class.
	FieldPrivacyPrimaryClass = "privacy_primary_class"
	// FieldPrivacyConfidence stores evidence confidence, not authentication risk.
	FieldPrivacyConfidence = "privacy_confidence"
	// FieldPrivacySourceAuthorities stores stable evidence authority classes.
	FieldPrivacySourceAuthorities = "privacy_source_authorities"
	// FieldPrivacyDataStale stores whether the evaluated evidence is stale.
	FieldPrivacyDataStale = "privacy_data_stale"
	// FieldPrivacyDataAgeSeconds stores the non-negative evidence age.
	FieldPrivacyDataAgeSeconds = "privacy_data_age_seconds"
	// FieldIsTorExitNode stores official Tor exit evidence.
	FieldIsTorExitNode = "is_tor_exit_node"
	// FieldIsKnownVPNExit stores known VPN exit evidence.
	FieldIsKnownVPNExit = "is_known_vpn_exit"
	// FieldIsCommunityVPNExit stores community VPN exit evidence.
	FieldIsCommunityVPNExit = "is_community_vpn_exit"
	// FieldIsPublicProxy stores public proxy evidence.
	FieldIsPublicProxy = "is_public_proxy"
	// FieldIsPrivacyRelay stores privacy relay evidence.
	FieldIsPrivacyRelay = "is_privacy_relay"
	// FieldIsHostingNetwork stores hosting or cloud network evidence.
	FieldIsHostingNetwork = "is_hosting_network"
	// FieldIsSharedEgress stores operator-approved shared public egress evidence.
	FieldIsSharedEgress = "is_shared_egress"
)

Variables

This section is empty.

Functions

func FeatureKey

func FeatureKey(name string) string

FeatureKey returns the standard runtime key for a feature marker.

func FeatureMarkerValue

func FeatureMarkerValue(marker FeatureMarker) map[string]any

FeatureMarkerValue builds a JSON-compatible feature-marker map.

func FeatureRuntimeDelta

func FeatureRuntimeDelta(name string, marker FeatureMarker) pluginapi.RuntimeDelta

FeatureRuntimeDelta builds a runtime delta for one feature marker.

func GeoIPReputationRuntimeDelta

func GeoIPReputationRuntimeDelta(fields map[string]any) pluginapi.RuntimeDelta

GeoIPReputationRuntimeDelta builds a runtime delta for GeoIP reputation exchange data.

func GeoIPReputationValue

func GeoIPReputationValue(fields map[string]any) map[string]any

GeoIPReputationValue returns a defensive copy of GeoIP reputation exchange fields.

func GeoIPRuntimeDelta

func GeoIPRuntimeDelta(fields map[string]any) pluginapi.RuntimeDelta

GeoIPRuntimeDelta builds a runtime delta for GeoIP exchange data.

func GeoIPValue

func GeoIPValue(fields map[string]any) map[string]any

GeoIPValue returns a defensive copy of GeoIP exchange fields.

func HIBPRuntimeDelta

func HIBPRuntimeDelta(result HIBPResult) pluginapi.RuntimeDelta

HIBPRuntimeDelta builds a runtime delta for HIBP exchange data.

func HIBPValue

func HIBPValue(result HIBPResult) map[string]any

HIBPValue builds a JSON-compatible HIBP exchange map.

func MapValue

func MapValue(value any) map[string]any

MapValue returns a defensive string-keyed map copy when value is map-like.

func StringList

func StringList(value any) []string

StringList normalizes string-list exchange values with deterministic map ordering.

func StringValue

func StringValue(value any) string

StringValue converts scalar optional values to strings.

func Truthy

func Truthy(value any) bool

Truthy reports whether a runtime or fact value is true.

Types

type FeatureMarker

type FeatureMarker struct {
	Triggered bool
	Decision  string
	Source    string
	Reason    string
}

FeatureMarker describes one standard feature marker value.

type GeoIPAnalytics

type GeoIPAnalytics struct {
	Fields          map[string]any
	Privacy         GeoIPPrivacyAnalytics
	MalformedFields []string
}

GeoIPAnalytics is a defensive typed view over standard GeoIP exchange data.

type GeoIPPrivacyAnalytics

type GeoIPPrivacyAnalytics struct {
	Classes            []string
	SourceAuthorities  []string
	LookupState        string
	PrimaryClass       string
	Detected           *bool
	Confidence         *float64
	DataStale          *bool
	DataAgeSeconds     *uint64
	IsTorExitNode      *bool
	IsKnownVPNExit     *bool
	IsCommunityVPNExit *bool
	IsPublicProxy      *bool
	IsPrivacyRelay     *bool
	IsHostingNetwork   *bool
	IsSharedEgress     *bool
}

GeoIPPrivacyAnalytics contains normalized nullable privacy evidence for analytics.

type HIBPResult

type HIBPResult struct {
	HashInfo string
	Leaked   *bool
	Count    *uint64
}

HIBPResult contains secret-safe Have I Been Pwned exchange fields.

type Snapshot

type Snapshot struct {
	// contains filtered or unexported fields
}

Snapshot is a read-only view over standard exchange runtime values and policy facts.

func NewSnapshot

func NewSnapshot(runtime pluginapi.RuntimeContext, facts []pluginapi.PolicyFact) Snapshot

NewSnapshot builds a standard exchange view from a runtime context and policy facts.

func NewSnapshotFromValues

func NewSnapshotFromValues(values map[string]any, facts []pluginapi.PolicyFact) Snapshot

NewSnapshotFromValues builds a standard exchange view from raw runtime values.

func (Snapshot) DecisionSources

func (s Snapshot) DecisionSources() []string

DecisionSources returns deterministic, deduplicated analytics source names.

func (Snapshot) DecisionSourcesString

func (s Snapshot) DecisionSourcesString() string

DecisionSourcesString returns DecisionSources joined for analytics row fields.

func (Snapshot) GeoIPAnalytics

func (s Snapshot) GeoIPAnalytics() GeoIPAnalytics

GeoIPAnalytics returns exchange-first GeoIP data with policy-fact privacy fallback.

func (Snapshot) GeoIPReputation

func (s Snapshot) GeoIPReputation() map[string]any

GeoIPReputation returns exchange reputation data or policy-fact fallback data.

func (Snapshot) HIBPHashInfo

func (s Snapshot) HIBPHashInfo() string

HIBPHashInfo returns the standard HIBP short hash information for analytics.

func (Snapshot) Map

func (s Snapshot) Map(key string) map[string]any

Map returns one standard exchange map value.

func (Snapshot) Value

func (s Snapshot) Value(key string) any

Value returns one cloned runtime value.

Jump to

Keyboard shortcuts

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