security

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Jul 14, 2026 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AIDEInfo

type AIDEInfo struct {
	Installed      bool      `json:"installed"`
	Initialized    bool      `json:"initialized"`
	Version        string    `json:"version,omitempty"`
	DatabasePath   string    `json:"database_path,omitempty"`
	DatabaseExists bool      `json:"database_exists"`
	DatabaseAge    int       `json:"database_age_days"`
	LastCheck      time.Time `json:"last_check,omitempty"`
	ChangesFound   int       `json:"changes_found"`
	Status         string    `json:"status"`
}

AIDEInfo represents AIDE (Advanced Intrusion Detection Environment) status

type AppArmorInfo

type AppArmorInfo struct {
	Installed bool   `json:"installed"`
	Enabled   bool   `json:"enabled"`
	Profiles  int    `json:"profiles_loaded"`
	Mode      string `json:"mode"`
	Status    string `json:"status"`
}

AppArmorInfo represents AppArmor status

type AuthLogAnalysis

type AuthLogAnalysis struct {
	LogFile             string         `json:"log_file"`
	LogAvailable        bool           `json:"log_available"`
	AnalyzedLines       int            `json:"analyzed_lines"`
	TimeRange           string         `json:"time_range"`
	FailedLogins        int            `json:"failed_logins"`
	SuccessfulLogins    int            `json:"successful_logins"`
	FailedUsers         map[string]int `json:"failed_users"`
	SuccessfulUsers     map[string]int `json:"successful_users"`
	FailedIPs           map[string]int `json:"failed_ips"`
	SuspiciousActivity  []string       `json:"suspicious_activity,omitempty"`
	RootLoginAttempts   int            `json:"root_login_attempts"`
	InvalidUserAttempts int            `json:"invalid_user_attempts"`
}

AuthLogAnalysis represents authentication log analysis

type ChkrootkitInfo

type ChkrootkitInfo struct {
	Installed       bool      `json:"installed"`
	Version         string    `json:"version,omitempty"`
	LastScan        time.Time `json:"last_scan,omitempty"`
	InfectionsFound int       `json:"infections_found"`
	SuspiciousItems []string  `json:"suspicious_items,omitempty"`
	Status          string    `json:"status"`
}

ChkrootkitInfo represents chkrootkit status

type Fail2banJail

type Fail2banJail struct {
	Name        string `json:"name"`
	Enabled     bool   `json:"enabled"`
	BannedIPs   int    `json:"banned_ips"`
	TotalBanned int    `json:"total_banned"`
	TotalFailed int    `json:"total_failed"`
}

Fail2banJail represents a single fail2ban jail

type Fail2banStatus

type Fail2banStatus struct {
	Installed       bool           `json:"installed"`
	Running         bool           `json:"running"`
	Jails           []Fail2banJail `json:"jails,omitempty"`
	TotalBanned     int            `json:"total_banned"`
	ErrorMessage    string         `json:"error_message,omitempty"`
	Recommendations []string       `json:"recommendations,omitempty"`
	RiskLevel       string         `json:"risk_level"` // LOW, MEDIUM, HIGH, CRITICAL
}

Fail2banStatus represents the status of fail2ban installation and configuration

func AnalyzeFail2ban

func AnalyzeFail2ban() *Fail2banStatus

AnalyzeFail2ban checks fail2ban installation, status, and configuration

type FileChange

type FileChange struct {
	FilePath    string `json:"file_path"`
	ChangeType  string `json:"change_type"` // added, removed, modified, attributes
	Description string `json:"description"`
	Severity    string `json:"severity"` // CRITICAL, HIGH, MEDIUM, LOW
}

FileChange represents a detected file modification

type HardeningIssue

type HardeningIssue struct {
	Severity       string `json:"severity"` // CRITICAL, HIGH, MEDIUM, LOW
	Issue          string `json:"issue"`
	Recommendation string `json:"recommendation"`
}

HardeningIssue represents a system hardening security concern

type HardeningStatus

type HardeningStatus struct {
	SysctlChecks     []SysctlCheck     `json:"sysctl_checks"`
	KernelParameters []KernelParameter `json:"kernel_parameters"`
	SELinuxStatus    SELinuxInfo       `json:"selinux_status"`
	AppArmorStatus   AppArmorInfo      `json:"apparmor_status"`
	Issues           []HardeningIssue  `json:"issues"`
	RiskLevel        string            `json:"risk_level"`     // LOW, MEDIUM, HIGH, CRITICAL
	SecurityScore    int               `json:"security_score"` // 0-100
}

HardeningStatus represents system hardening configuration and security posture

func AnalyzeSystemHardening

func AnalyzeSystemHardening() *HardeningStatus

AnalyzeSystemHardening performs comprehensive system hardening checks

type IPCount

type IPCount struct {
	IP    string
	Count int
}

IPCount for sorting IPs by failure count

type IntegrityIssue

type IntegrityIssue struct {
	Severity       string `json:"severity"` // CRITICAL, HIGH, MEDIUM, LOW
	Issue          string `json:"issue"`
	Recommendation string `json:"recommendation"`
}

IntegrityIssue represents a file integrity security concern

type IntegrityStatus

type IntegrityStatus struct {
	AIDEStatus      AIDEInfo         `json:"aide"`
	Tripwire        TripwireInfo     `json:"tripwire,omitempty"`
	LastScanTime    time.Time        `json:"last_scan_time,omitempty"`
	ChangesDetected int              `json:"changes_detected"`
	ModifiedFiles   []FileChange     `json:"modified_files,omitempty"`
	Issues          []IntegrityIssue `json:"issues"`
	RiskLevel       string           `json:"risk_level"`     // LOW, MEDIUM, HIGH, CRITICAL
	SecurityScore   int              `json:"security_score"` // 0-100
}

IntegrityStatus represents file integrity monitoring status

func AnalyzeFileIntegrity

func AnalyzeFileIntegrity() *IntegrityStatus

AnalyzeFileIntegrity performs file integrity monitoring checks

type KernelParameter

type KernelParameter struct {
	Parameter   string `json:"parameter"`
	Value       string `json:"value"`
	Description string `json:"description"`
}

KernelParameter represents a kernel security parameter

type LogAnalysisStatus

type LogAnalysisStatus struct {
	AuthLog        AuthLogAnalysis   `json:"auth_log"`
	SudoLog        SudoLogAnalysis   `json:"sudo_log"`
	SystemLog      SystemLogAnalysis `json:"system_log,omitempty"`
	SecurityEvents []SecurityEvent   `json:"security_events"`
	Issues         []LogIssue        `json:"issues"`
	RiskLevel      string            `json:"risk_level"`     // LOW, MEDIUM, HIGH, CRITICAL
	SecurityScore  int               `json:"security_score"` // 0-100
}

LogAnalysisStatus represents system log analysis results

func AnalyzeLogs

func AnalyzeLogs() *LogAnalysisStatus

AnalyzeLogs performs comprehensive system log analysis

type LogIssue

type LogIssue struct {
	Severity       string `json:"severity"` // CRITICAL, HIGH, MEDIUM, LOW
	Issue          string `json:"issue"`
	Recommendation string `json:"recommendation"`
}

LogIssue represents a log analysis security concern

type LoginConfig

type LoginConfig struct {
	LoginTimeout  int    `json:"login_timeout_seconds"`
	LoginRetries  int    `json:"login_retries"`
	FailDelay     int    `json:"fail_delay_seconds"`
	UmaskValue    string `json:"umask"`
	CreateHomeDir bool   `json:"create_home_dir"`
	EncryptMethod string `json:"encrypt_method"`
}

LoginConfig represents login security settings

type PasswordPolicy

type PasswordPolicy struct {
	MinLength         int    `json:"min_length"`
	MaxDays           int    `json:"max_days"`
	MinDays           int    `json:"min_days"`
	WarnAge           int    `json:"warn_age"`
	RequireUppercase  bool   `json:"require_uppercase"`
	RequireLowercase  bool   `json:"require_lowercase"`
	RequireDigits     bool   `json:"require_digits"`
	RequireSpecial    bool   `json:"require_special"`
	RememberPasswords int    `json:"remember_passwords"`
	PolicySource      string `json:"policy_source"` // /etc/login.defs, PAM, etc.
}

PasswordPolicy represents system password policy settings

type RkhunterInfo

type RkhunterInfo struct {
	Installed       bool      `json:"installed"`
	Version         string    `json:"version,omitempty"`
	LastUpdate      time.Time `json:"last_update,omitempty"`
	LastScan        time.Time `json:"last_scan,omitempty"`
	DatabaseVersion string    `json:"database_version,omitempty"`
	WarningsFound   int       `json:"warnings_found"`
	SuspiciousFiles []string  `json:"suspicious_files,omitempty"`
	Status          string    `json:"status"`
}

RkhunterInfo represents rkhunter status

type RootkitIssue

type RootkitIssue struct {
	Severity       string `json:"severity"` // CRITICAL, HIGH, MEDIUM, LOW
	Issue          string `json:"issue"`
	Recommendation string `json:"recommendation"`
}

RootkitIssue represents a rootkit security concern

type RootkitStatus

type RootkitStatus struct {
	RkhunterStatus   RkhunterInfo     `json:"rkhunter"`
	ChkrootkitStatus ChkrootkitInfo   `json:"chkrootkit"`
	LastScanTime     time.Time        `json:"last_scan_time,omitempty"`
	Warnings         []RootkitWarning `json:"warnings"`
	Issues           []RootkitIssue   `json:"issues"`
	RiskLevel        string           `json:"risk_level"`     // LOW, MEDIUM, HIGH, CRITICAL
	SecurityScore    int              `json:"security_score"` // 0-100
}

RootkitStatus represents rootkit detection status

func AnalyzeRootkit

func AnalyzeRootkit() *RootkitStatus

AnalyzeRootkit performs rootkit detection checks

type RootkitWarning

type RootkitWarning struct {
	Tool        string `json:"tool"`     // rkhunter or chkrootkit
	Severity    string `json:"severity"` // CRITICAL, HIGH, MEDIUM, LOW
	Item        string `json:"item"`     // File, process, or check name
	Description string `json:"description"`
}

RootkitWarning represents a rootkit detection warning

type SELinuxInfo

type SELinuxInfo struct {
	Installed bool   `json:"installed"`
	Enabled   bool   `json:"enabled"`
	Mode      string `json:"mode"` // enforcing, permissive, disabled
	Status    string `json:"status"`
}

SELinuxInfo represents SELinux status

type SSHConfig

type SSHConfig struct {
	ConfigFile          string             `json:"config_file"`
	Port                int                `json:"port"`
	PermitRootLogin     string             `json:"permit_root_login"`
	PasswordAuth        string             `json:"password_authentication"`
	PubkeyAuth          string             `json:"pubkey_authentication"`
	PermitEmptyPassword string             `json:"permit_empty_passwords"`
	ChallengeResponse   string             `json:"challenge_response_auth"`
	Issues              []SSHSecurityIssue `json:"issues"`
	RiskLevel           string             `json:"risk_level"`     // LOW, MEDIUM, HIGH, CRITICAL
	SecurityScore       int                `json:"security_score"` // 0-100
}

SSHConfig represents SSH server configuration and security posture

func AnalyzeSSHConfig

func AnalyzeSSHConfig() *SSHConfig

AnalyzeSSHConfig reads and analyzes SSH server configuration

type SSHSecurityIssue

type SSHSecurityIssue struct {
	Severity       string `json:"severity"` // CRITICAL, HIGH, MEDIUM, LOW
	Issue          string `json:"issue"`
	Recommendation string `json:"recommendation"`
}

SSHSecurityIssue represents a specific SSH security concern

type SecurityEvent

type SecurityEvent struct {
	Timestamp   string `json:"timestamp"`
	Severity    string `json:"severity"` // CRITICAL, HIGH, MEDIUM, LOW
	Source      string `json:"source"`   // auth, sudo, system
	Event       string `json:"event"`
	Description string `json:"description"`
}

SecurityEvent represents a security-relevant event

type SudoCommand

type SudoCommand struct {
	Timestamp  string `json:"timestamp"`
	User       string `json:"user"`
	Command    string `json:"command"`
	Suspicious bool   `json:"suspicious"`
	Reason     string `json:"reason,omitempty"`
}

SudoCommand represents a sudo command execution

type SudoConfig

type SudoConfig struct {
	SudoersFile       string   `json:"sudoers_file"`
	NoPasswordUsers   []string `json:"nopasswd_users"`
	PasswordlessCount int      `json:"passwordless_count"`
	SudoGroupMembers  []string `json:"sudo_group_members"`
	CustomSudoers     []string `json:"custom_sudoers_files"`
	UseTimestamp      bool     `json:"use_timestamp"`
	TimestampTimeout  int      `json:"timestamp_timeout_minutes"`
	RequireTTY        bool     `json:"require_tty"`
	Issues            []string `json:"issues"`
}

SudoConfig represents sudo configuration

type SudoLogAnalysis

type SudoLogAnalysis struct {
	LogAvailable       bool           `json:"log_available"`
	AnalyzedLines      int            `json:"analyzed_lines"`
	TimeRange          string         `json:"time_range"`
	SudoCommands       int            `json:"sudo_commands_executed"`
	SudoUsers          map[string]int `json:"sudo_users"`
	FailedSudoAttempts int            `json:"failed_sudo_attempts"`
	RootSessions       int            `json:"root_sessions"`
	SuspiciousCommands []SudoCommand  `json:"suspicious_commands,omitempty"`
}

SudoLogAnalysis represents sudo usage analysis

type SysctlCheck

type SysctlCheck struct {
	Parameter        string `json:"parameter"`
	CurrentValue     string `json:"current_value"`
	RecommendedValue string `json:"recommended_value"`
	Compliant        bool   `json:"compliant"`
	Severity         string `json:"severity"` // CRITICAL, HIGH, MEDIUM, LOW
	Description      string `json:"description"`
}

SysctlCheck represents a sysctl parameter check

type SystemIssue

type SystemIssue struct {
	Severity       string `json:"severity"` // CRITICAL, HIGH, MEDIUM, LOW, INFO
	Issue          string `json:"issue"`
	Recommendation string `json:"recommendation"`
}

SystemIssue represents a system security issue

type SystemLogAnalysis

type SystemLogAnalysis struct {
	LogAvailable    bool `json:"log_available"`
	Errors          int  `json:"errors"`
	Warnings        int  `json:"warnings"`
	CriticalEvents  int  `json:"critical_events"`
	ServiceFailures int  `json:"service_failures"`
}

SystemLogAnalysis represents general system log analysis

type SystemSecurityStatus

type SystemSecurityStatus struct {
	LastUpdate         time.Time     `json:"last_update,omitempty"`
	DaysSinceUpdate    int           `json:"days_since_update"`
	UpdatesAvailable   int           `json:"updates_available"`
	SecurityUpdates    int           `json:"security_updates"`
	KernelVersion      string        `json:"kernel_version"`
	OSVersion          string        `json:"os_version"`
	AutoUpdatesEnabled bool          `json:"auto_updates_enabled"`
	RebootRequired     bool          `json:"reboot_required"`
	Issues             []SystemIssue `json:"issues"`
	RiskLevel          string        `json:"risk_level"` // LOW, MEDIUM, HIGH, CRITICAL
}

SystemSecurityStatus represents the overall system security status

func AnalyzeSystemSecurity

func AnalyzeSystemSecurity() *SystemSecurityStatus

AnalyzeSystemSecurity checks system update status and security posture

func (*SystemSecurityStatus) GetSystemSecurityScore

func (s *SystemSecurityStatus) GetSystemSecurityScore() int

GetSystemSecurityScore calculates a 0-100 security score

type TripwireInfo

type TripwireInfo struct {
	Installed bool   `json:"installed"`
	Version   string `json:"version,omitempty"`
	Status    string `json:"status"`
}

TripwireInfo represents Tripwire status

type UserAccount

type UserAccount struct {
	Username        string `json:"username"`
	UID             int    `json:"uid"`
	GID             int    `json:"gid"`
	Home            string `json:"home"`
	Shell           string `json:"shell"`
	EmptyPassword   bool   `json:"empty_password"`
	Locked          bool   `json:"locked"`
	PasswordExpired bool   `json:"password_expired"`
	InSudoGroup     bool   `json:"in_sudo_group"`
	LastLogin       string `json:"last_login,omitempty"`
	RiskLevel       string `json:"risk_level"` // OK, LOW, MEDIUM, HIGH, CRITICAL
}

UserAccount represents a system user account

type UserHardeningStatus

type UserHardeningStatus struct {
	SudoConfig     SudoConfig          `json:"sudo_config"`
	UserAccounts   []UserAccount       `json:"user_accounts"`
	PasswordPolicy PasswordPolicy      `json:"password_policy"`
	LoginConfig    LoginConfig         `json:"login_config"`
	Issues         []UserSecurityIssue `json:"issues"`
	RiskLevel      string              `json:"risk_level"`     // LOW, MEDIUM, HIGH, CRITICAL
	SecurityScore  int                 `json:"security_score"` // 0-100
}

UserHardeningStatus represents user and sudo security configuration

func AnalyzeUserSecurity

func AnalyzeUserSecurity() *UserHardeningStatus

AnalyzeUserSecurity performs comprehensive user and sudo security checks

type UserSecurityIssue

type UserSecurityIssue struct {
	Severity       string `json:"severity"` // CRITICAL, HIGH, MEDIUM, LOW
	Issue          string `json:"issue"`
	Recommendation string `json:"recommendation"`
}

UserSecurityIssue represents a user/sudo security concern

Jump to

Keyboard shortcuts

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