authsession

package
v0.5.2 Latest Latest
Warning

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

Go to latest
Published: Oct 3, 2026 License: MIT Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AgentSessionConfigToAuthenticationHostnames

func AgentSessionConfigToAuthenticationHostnames(cfg *agenttypes.AgentSessionConfig, projectUUID, scanUUID, hostname, source string) []*database.AuthenticationHostname

AgentSessionConfigToAuthenticationHostnames converts an AgentSessionConfig (from source analysis output) into a slice of database.AuthenticationHostname rows ready for persistence.

func AgentSessionConfigToSessions

func AgentSessionConfigToSessions(cfg *agenttypes.AgentSessionConfig) []*authentication.Session

AgentSessionConfigToSessions converts an AgentSessionConfig to native authentication.Session objects. This is used by `vigolium session load` to import agent-discovered session files.

func AuthHeadersFromAuthenticationHostnames

func AuthHeadersFromAuthenticationHostnames(rows []*database.AuthenticationHostname) map[string]string

AuthHeadersFromAuthenticationHostnames extracts auth headers from DB AuthenticationHostname rows. It prefers the row with role "primary"; if none exists, it falls back to the first row that has non-empty Headers.

func CleanupSessionDirs

func CleanupSessionDirs(sessionsDir string, maxAge time.Duration) (int, error)

CleanupSessionDirs removes session directories under sessionsDir that are older than maxAge. It returns the number of directories deleted.

func ExtractSessionAuth

func ExtractSessionAuth(sessionHeaders map[string]string) (auth map[string]string, original map[string]string)

ExtractSessionAuth filters sessionHeaders to only auth headers, returning two maps: lowercase name -> value, and lowercase name -> original cased name. Returns nil, nil if no auth headers are found.

func IsAuthHeader

func IsAuthHeader(name string) bool

IsAuthHeader returns true if the header name (case-insensitive) is an auth header.

func IsValidContentType

func IsValidContentType(ct string) bool

IsValidContentType checks if a content type string is a reasonable MIME type. It catches garbled types like "application/rest/user/login".

func LooksLikeJSON

func LooksLikeJSON(s string) bool

LooksLikeJSON returns true if the string looks like it could be a JSON object or array.

func ReplaceAuthHeadersInHTTPRR

func ReplaceAuthHeadersInHTTPRR(records []*httpmsg.HttpRequestResponse, sessionHeaders map[string]string)

ReplaceAuthHeadersInHTTPRR replaces Authorization and Cookie headers in httpmsg.HttpRequestResponse slices with headers from session data. Modifies records in place.

func ReplaceAuthHeadersInRecords

func ReplaceAuthHeadersInRecords(records []agenttypes.AgentHTTPRecord, sessionHeaders map[string]string) []agenttypes.AgentHTTPRecord

ReplaceAuthHeadersInRecords replaces Authorization and Cookie headers in AgentHTTPRecord slices with headers from authentication_hostnames DB rows. Only replaces if sessionHeaders is non-empty; otherwise returns records unchanged.

func ReprobeUnprobedRecords

func ReprobeUnprobedRecords(ctx context.Context, repo *database.Repository, projectUUID, hostname string, authHeaders map[string]string, source string)

ReprobeUnprobedRecords queries the database for HTTP records that have no response (has_response=false) for the given source and hostname, then probes them concurrently to populate status codes and response bodies.

func SanitizeSessionEntry

func SanitizeSessionEntry(entry *agenttypes.AgentSessionEntry)

SanitizeSessionEntry attempts to fix common LLM output issues in-place.

func SessionConfigToHTTPRecords

func SessionConfigToHTTPRecords(cfg *agenttypes.AgentSessionConfig) []agenttypes.AgentHTTPRecord

SessionConfigToHTTPRecords converts login flows from an AgentSessionConfig into AgentHTTPRecord entries suitable for ingestion into the http_records table. Each session entry with a login flow produces one HTTP record for the login URL.

func TruncateForLog

func TruncateForLog(s string, maxLen int) string

TruncateForLog truncates a string for log output, adding ellipsis if truncated.

func ValidateLoginFlow

func ValidateLoginFlow(login *agenttypes.AgentLoginFlow) []string

ValidateLoginFlow checks a login flow for garbled or invalid fields.

func ValidateSessionConfig

func ValidateSessionConfig(cfg *agenttypes.AgentSessionConfig) *agenttypes.AgentSessionConfig

ValidateSessionConfig validates each session entry, attempts to sanitize fixable issues (like double-escaped JSON bodies), and drops entries that are beyond repair. Returns nil if no valid sessions remain.

func ValidateSessionEntry

func ValidateSessionEntry(entry agenttypes.AgentSessionEntry) []string

ValidateSessionEntry checks a single session entry for common corruption patterns. Returns a list of validation errors (empty if valid).

Types

type InvalidSessionEntry

type InvalidSessionEntry struct {
	Entry  agenttypes.AgentSessionEntry
	Errors []string
}

InvalidSessionEntry pairs a dropped session entry with its validation errors.

type SessionValidationResult

type SessionValidationResult struct {
	Valid   []agenttypes.AgentSessionEntry
	Invalid []InvalidSessionEntry
}

SessionValidationResult holds the outcome of session config validation, separating valid entries from invalid ones that may be repaired.

func ValidateSessionConfigDetailed

func ValidateSessionConfigDetailed(cfg *agenttypes.AgentSessionConfig) SessionValidationResult

ValidateSessionConfigDetailed validates each session entry and returns both valid and invalid entries. This enables partial repair of invalid entries while preserving entries that already pass validation.

Jump to

Keyboard shortcuts

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