Documentation
¶
Index ¶
- Constants
- func GetAccountSummaryContext(summary *AccountSummary) string
- func GetFinalResponsePrompt(question, iamData, conversationContext string) string
- func GetFixPlanPrompt(finding SecurityFinding, currentPolicy string) string
- func GetLLMAnalysisPrompt(question string, iamContext string) string
- func GetPermissionAnalysisPrompt(question string, permissions []string, context string) string
- func GetSecurityAnalysisPrompt(resourceType, resourceName, policyDocument string) string
- func GetTrustPolicyAnalysisPrompt(roleName, trustPolicy string) string
- type AccessKeyInfo
- type AccountSummary
- type Agent
- func (a *Agent) ApplyFixPlan(ctx context.Context, plan *FixPlan, confirm bool) error
- func (a *Agent) ClearConversation()
- func (a *Agent) GetAccountID() string
- func (a *Agent) GetAnalyzer() *analyzer.SubAgent
- func (a *Agent) GetClient() *Client
- func (a *Agent) GetFixer() *fixer.SubAgent
- func (a *Agent) HandleQuery(ctx context.Context, query string, opts QueryOptions) (*Response, error)
- type AgentOptions
- type Client
- func (c *Client) AttachRolePolicy(ctx context.Context, roleName, policyARN string) error
- func (c *Client) CreatePolicyVersion(ctx context.Context, policyARN, document string, setAsDefault bool) error
- func (c *Client) DeletePolicyVersion(ctx context.Context, policyARN, versionID string) error
- func (c *Client) DetachRolePolicy(ctx context.Context, roleName, policyARN string) error
- func (c *Client) ExecuteOperations(ctx context.Context, operations []IAMOperation) (string, error)
- func (c *Client) GetAccountID() string
- func (c *Client) GetAccountSummary(ctx context.Context) (*AccountSummary, error)
- func (c *Client) GetCredentialReport(ctx context.Context) (*CredentialReport, error)
- func (c *Client) GetPolicyDocument(ctx context.Context, policyARN string) (*PolicyDetail, error)
- func (c *Client) GetRoleDetails(ctx context.Context, roleName string) (*RoleDetail, error)
- func (c *Client) GetRolePolicyDocument(ctx context.Context, roleName, policyName string) (string, error)
- func (c *Client) ListAccessKeys(ctx context.Context, userName string) ([]AccessKeyInfo, error)
- func (c *Client) ListGroups(ctx context.Context) ([]GroupInfo, error)
- func (c *Client) ListPolicies(ctx context.Context) ([]PolicyInfo, error)
- func (c *Client) ListRoles(ctx context.Context) ([]RoleInfo, error)
- func (c *Client) ListUsers(ctx context.Context) ([]UserInfo, error)
- func (c *Client) UpdateAccessKey(ctx context.Context, userName, accessKeyID, status string) error
- func (c *Client) UpdateAssumeRolePolicy(ctx context.Context, roleName, document string) error
- type ConversationEntry
- type ConversationHistory
- func (h *ConversationHistory) AddEntry(question, answer, accountID string)
- func (h *ConversationHistory) Clear()
- func (h *ConversationHistory) GetAccountSummary() *AccountSummary
- func (h *ConversationHistory) GetAccountSummaryContext() string
- func (h *ConversationHistory) GetRecentContext(maxEntries int) string
- func (h *ConversationHistory) Load() error
- func (h *ConversationHistory) Save() error
- func (h *ConversationHistory) UpdateAccountSummary(summary *AccountSummary)
- type CredentialReport
- type CredentialReportEntry
- type FixCommand
- type FixPlan
- type GroupInfo
- type IAMAnalysis
- type IAMOperation
- type IAMOperationResult
- type InlinePolicy
- type PolicyDetail
- type PolicyDocument
- type PolicyInfo
- type PolicyVersion
- type QueryOptions
- type Response
- type RoleDetail
- type RoleInfo
- type SecurityFinding
- type Statement
- type TrustPolicy
- type TrustStatement
- type UserInfo
Constants ¶
const ( SeverityCritical = "critical" SeverityHigh = "high" SeverityMedium = "medium" SeverityLow = "low" SeverityInfo = "info" )
Severity levels for findings
const ( FindingOverpermissivePolicy = "overpermissive_policy" FindingAdminAccess = "admin_access" FindingWildcardResource = "wildcard_resource" FindingUnusedRole = "unused_role" FindingCrossAccountTrust = "cross_account_trust" FindingMissingMFA = "missing_mfa" FindingOldAccessKeys = "old_access_keys" FindingInactiveKeys = "inactive_keys" FindingRootAccountUsage = "root_account_usage" FindingPublicS3Access = "public_s3_access" FindingExcessivePermissions = "excessive_permissions" FindingMissingResourceScoping = "missing_resource_scoping" )
Finding types
const ( ActionUpdatePolicy = "update_policy" ActionCreatePolicyVersion = "create_policy_version" ActionAttachPolicy = "attach_policy" ActionDetachPolicy = "detach_policy" ActionDeletePolicyVersion = "delete_policy_version" ActionDeactivateAccessKey = "deactivate_access_key" ActionDeleteAccessKey = "delete_access_key" ActionRotateAccessKey = "rotate_access_key" ActionUpdateTrustPolicy = "update_trust_policy" )
Action types for fix commands
const ( ResponseTypeResult = "result" ResponseTypePlan = "plan" ResponseTypeFindings = "findings" ResponseTypeError = "error" )
Response types
const MaxAnswerLengthInContext = 500
MaxAnswerLengthInContext limits how much of previous answers to include in context
const MaxHistoryEntries = 20
MaxHistoryEntries limits the conversation history size
Variables ¶
This section is empty.
Functions ¶
func GetAccountSummaryContext ¶
func GetAccountSummaryContext(summary *AccountSummary) string
GetAccountSummaryContext returns a formatted string of IAM account summary
func GetFinalResponsePrompt ¶
GetFinalResponsePrompt returns the prompt for generating the final user-facing response
func GetFixPlanPrompt ¶
func GetFixPlanPrompt(finding SecurityFinding, currentPolicy string) string
GetFixPlanPrompt returns the prompt for generating a fix plan for a security finding
func GetLLMAnalysisPrompt ¶
GetLLMAnalysisPrompt returns the prompt for LLM to analyze what IAM operations are needed
func GetPermissionAnalysisPrompt ¶
GetPermissionAnalysisPrompt returns the prompt for analyzing specific permissions
func GetSecurityAnalysisPrompt ¶
GetSecurityAnalysisPrompt returns the prompt for analyzing a policy document for security issues
func GetTrustPolicyAnalysisPrompt ¶
GetTrustPolicyAnalysisPrompt returns the prompt for analyzing a trust policy
Types ¶
type AccessKeyInfo ¶
type AccessKeyInfo struct {
UserName string `json:"user_name"`
AccessKeyId string `json:"access_key_id"`
Status string `json:"status"`
CreateDate time.Time `json:"create_date"`
LastUsedDate *time.Time `json:"last_used_date,omitempty"`
LastUsedService string `json:"last_used_service,omitempty"`
LastUsedRegion string `json:"last_used_region,omitempty"`
}
AccessKeyInfo contains access key metadata
type AccountSummary ¶
type AccountSummary struct {
RoleCount int `json:"role_count"`
PolicyCount int `json:"policy_count"`
UserCount int `json:"user_count"`
GroupCount int `json:"group_count"`
InstanceProfiles int `json:"instance_profiles"`
MFADevices int `json:"mfa_devices"`
AccessKeys int `json:"access_keys"`
}
AccountSummary represents a summary of IAM resources in an account
type Agent ¶
type Agent struct {
// contains filtered or unexported fields
}
Agent orchestrates IAM operations
func NewAgentWithOptions ¶
func NewAgentWithOptions(opts AgentOptions) (*Agent, error)
NewAgentWithOptions creates a new IAM agent with the specified options
func (*Agent) ApplyFixPlan ¶
ApplyFixPlan applies a fix plan
func (*Agent) ClearConversation ¶
func (a *Agent) ClearConversation()
ClearConversation clears the conversation history
func (*Agent) GetAccountID ¶
GetAccountID returns the AWS account ID
func (*Agent) GetAnalyzer ¶
GetAnalyzer returns the analyzer subagent
func (*Agent) HandleQuery ¶
func (a *Agent) HandleQuery(ctx context.Context, query string, opts QueryOptions) (*Response, error)
HandleQuery handles an IAM query and returns a response
type AgentOptions ¶
AgentOptions configures the IAM agent
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client wraps the AWS IAM SDK client
func (*Client) AttachRolePolicy ¶
AttachRolePolicy attaches a managed policy to a role
func (*Client) CreatePolicyVersion ¶
func (c *Client) CreatePolicyVersion(ctx context.Context, policyARN, document string, setAsDefault bool) error
CreatePolicyVersion creates a new version of an IAM policy
func (*Client) DeletePolicyVersion ¶
DeletePolicyVersion deletes a specific version of an IAM policy
func (*Client) DetachRolePolicy ¶
DetachRolePolicy detaches a managed policy from a role
func (*Client) ExecuteOperations ¶
ExecuteOperations executes IAM operations in parallel and returns combined results
func (*Client) GetAccountID ¶
GetAccountID returns the AWS account ID
func (*Client) GetAccountSummary ¶
func (c *Client) GetAccountSummary(ctx context.Context) (*AccountSummary, error)
GetAccountSummary returns IAM account summary statistics
func (*Client) GetCredentialReport ¶
func (c *Client) GetCredentialReport(ctx context.Context) (*CredentialReport, error)
GetCredentialReport generates and returns the credential report
func (*Client) GetPolicyDocument ¶
GetPolicyDocument returns the policy document for a managed policy
func (*Client) GetRoleDetails ¶
GetRoleDetails returns detailed information about a specific role
func (*Client) GetRolePolicyDocument ¶
func (c *Client) GetRolePolicyDocument(ctx context.Context, roleName, policyName string) (string, error)
GetRolePolicyDocument returns the policy document for an inline policy
func (*Client) ListAccessKeys ¶
ListAccessKeys returns access keys for a user
func (*Client) ListGroups ¶
ListGroups returns all IAM groups
func (*Client) ListPolicies ¶
func (c *Client) ListPolicies(ctx context.Context) ([]PolicyInfo, error)
ListPolicies returns all customer-managed IAM policies
func (*Client) UpdateAccessKey ¶
UpdateAccessKey updates the status of an access key
type ConversationEntry ¶
type ConversationEntry struct {
Timestamp time.Time `json:"timestamp"`
Question string `json:"question"`
Answer string `json:"answer"`
AccountID string `json:"account_id"`
}
ConversationEntry represents a single Q&A exchange
type ConversationHistory ¶
type ConversationHistory struct {
Entries []ConversationEntry `json:"entries"`
AccountID string `json:"account_id"`
LastSummary *AccountSummary `json:"last_summary,omitempty"`
// contains filtered or unexported fields
}
ConversationHistory maintains conversation state for IAM ask mode
func NewConversationHistory ¶
func NewConversationHistory(accountID string) *ConversationHistory
NewConversationHistory creates a new conversation history for an account
func (*ConversationHistory) AddEntry ¶
func (h *ConversationHistory) AddEntry(question, answer, accountID string)
AddEntry adds a new conversation entry
func (*ConversationHistory) Clear ¶
func (h *ConversationHistory) Clear()
Clear clears all conversation history
func (*ConversationHistory) GetAccountSummary ¶
func (h *ConversationHistory) GetAccountSummary() *AccountSummary
GetAccountSummary returns the cached account summary
func (*ConversationHistory) GetAccountSummaryContext ¶
func (h *ConversationHistory) GetAccountSummaryContext() string
GetAccountSummaryContext returns a string representation of account summary suitable for inclusion in LLM prompts
func (*ConversationHistory) GetRecentContext ¶
func (h *ConversationHistory) GetRecentContext(maxEntries int) string
GetRecentContext returns recent conversation context as a formatted string for inclusion in LLM prompts
func (*ConversationHistory) Load ¶
func (h *ConversationHistory) Load() error
Load loads conversation history from disk
func (*ConversationHistory) Save ¶
func (h *ConversationHistory) Save() error
Save persists the conversation history to disk
func (*ConversationHistory) UpdateAccountSummary ¶
func (h *ConversationHistory) UpdateAccountSummary(summary *AccountSummary)
UpdateAccountSummary updates the cached account summary
type CredentialReport ¶
type CredentialReport struct {
GeneratedTime time.Time `json:"generated_time"`
Users []CredentialReportEntry `json:"users"`
}
CredentialReport represents an IAM credential report
type CredentialReportEntry ¶
type CredentialReportEntry struct {
User string `json:"user"`
ARN string `json:"arn"`
UserCreationTime time.Time `json:"user_creation_time"`
PasswordEnabled bool `json:"password_enabled"`
PasswordLastUsed *time.Time `json:"password_last_used,omitempty"`
PasswordLastChanged *time.Time `json:"password_last_changed,omitempty"`
PasswordNextRotation *time.Time `json:"password_next_rotation,omitempty"`
MFAActive bool `json:"mfa_active"`
AccessKey1Active bool `json:"access_key_1_active"`
AccessKey1LastRotated *time.Time `json:"access_key_1_last_rotated,omitempty"`
AccessKey1LastUsedDate *time.Time `json:"access_key_1_last_used_date,omitempty"`
AccessKey1LastUsedRegion string `json:"access_key_1_last_used_region,omitempty"`
AccessKey1LastUsedService string `json:"access_key_1_last_used_service,omitempty"`
AccessKey2Active bool `json:"access_key_2_active"`
AccessKey2LastRotated *time.Time `json:"access_key_2_last_rotated,omitempty"`
AccessKey2LastUsedDate *time.Time `json:"access_key_2_last_used_date,omitempty"`
AccessKey2LastUsedRegion string `json:"access_key_2_last_used_region,omitempty"`
AccessKey2LastUsedService string `json:"access_key_2_last_used_service,omitempty"`
}
CredentialReportEntry represents a single user entry in the credential report
type FixCommand ¶
type FixCommand struct {
ID string `json:"id"`
Action string `json:"action"`
ResourceARN string `json:"resource_arn"`
Parameters map[string]interface{} `json:"parameters"`
Reason string `json:"reason"`
Rollback *FixCommand `json:"rollback,omitempty"`
}
FixCommand represents a single remediation command
type FixPlan ¶
type FixPlan struct {
ID string `json:"id"`
Summary string `json:"summary"`
Finding SecurityFinding `json:"finding"`
Commands []FixCommand `json:"commands"`
Notes []string `json:"notes,omitempty"`
Warnings []string `json:"warnings,omitempty"`
CreatedAt time.Time `json:"created_at"`
}
FixPlan represents a plan to remediate a security finding
type GroupInfo ¶
type GroupInfo struct {
GroupName string `json:"group_name"`
GroupARN string `json:"group_arn"`
Path string `json:"path"`
CreateDate time.Time `json:"create_date"`
}
GroupInfo contains basic group information
type IAMAnalysis ¶
type IAMAnalysis struct {
Operations []IAMOperation `json:"operations"`
Analysis string `json:"analysis"`
}
IAMAnalysis represents the LLM's analysis of what IAM operations are needed
type IAMOperation ¶
type IAMOperation struct {
Operation string `json:"operation"`
Reason string `json:"reason"`
Parameters map[string]interface{} `json:"parameters"`
}
IAMOperation represents an IAM operation requested by the LLM
type IAMOperationResult ¶
IAMOperationResult represents the result of an IAM operation
type InlinePolicy ¶
type InlinePolicy struct {
PolicyName string `json:"policy_name"`
PolicyDocument string `json:"policy_document"`
}
InlinePolicy represents an inline policy attached to a role
type PolicyDetail ¶
type PolicyDetail struct {
PolicyInfo
PolicyDocument string `json:"policy_document"`
Versions []PolicyVersion `json:"versions,omitempty"`
Tags map[string]string `json:"tags,omitempty"`
}
PolicyDetail contains detailed policy information including document
type PolicyDocument ¶
type PolicyDocument struct {
Version string `json:"Version"`
Statement []Statement `json:"Statement"`
}
PolicyDocument represents a parsed IAM policy document
func ParsePolicyDocument ¶
func ParsePolicyDocument(document string) (*PolicyDocument, error)
ParsePolicyDocument parses a JSON policy document string
type PolicyInfo ¶
type PolicyInfo struct {
PolicyName string `json:"policy_name"`
PolicyARN string `json:"policy_arn"`
Path string `json:"path"`
CreateDate time.Time `json:"create_date"`
UpdateDate time.Time `json:"update_date"`
AttachmentCount int32 `json:"attachment_count"`
IsAttachable bool `json:"is_attachable"`
DefaultVersionId string `json:"default_version_id"`
Description string `json:"description,omitempty"`
}
PolicyInfo contains basic policy information
type PolicyVersion ¶
type PolicyVersion struct {
VersionId string `json:"version_id"`
IsDefaultVersion bool `json:"is_default_version"`
CreateDate time.Time `json:"create_date"`
Document string `json:"document,omitempty"`
}
PolicyVersion represents a specific version of an IAM policy
type QueryOptions ¶
type QueryOptions struct {
AccountWide bool `json:"account_wide"`
RoleARN string `json:"role_arn,omitempty"`
PolicyARN string `json:"policy_arn,omitempty"`
UserName string `json:"user_name,omitempty"`
GroupName string `json:"group_name,omitempty"`
}
QueryOptions configures how IAM queries are executed
type Response ¶
type Response struct {
Type string `json:"type"`
Content string `json:"content,omitempty"`
Plan *FixPlan `json:"plan,omitempty"`
Findings []SecurityFinding `json:"findings,omitempty"`
Error error `json:"error,omitempty"`
}
Response represents the IAM agent response
type RoleDetail ¶
type RoleDetail struct {
RoleInfo
AttachedPolicies []PolicyInfo `json:"attached_policies"`
InlinePolicies []InlinePolicy `json:"inline_policies"`
InstanceProfiles []string `json:"instance_profiles,omitempty"`
LastUsed *time.Time `json:"last_used,omitempty"`
}
RoleDetail contains detailed role information including policies
type RoleInfo ¶
type RoleInfo struct {
RoleName string `json:"role_name"`
RoleARN string `json:"role_arn"`
Path string `json:"path"`
CreateDate time.Time `json:"create_date"`
Description string `json:"description,omitempty"`
MaxSessionDuration int32 `json:"max_session_duration"`
AssumeRolePolicyDocument string `json:"assume_role_policy_document"`
Tags map[string]string `json:"tags,omitempty"`
}
RoleInfo contains basic role information
type SecurityFinding ¶
type SecurityFinding struct {
ID string `json:"id"`
Severity string `json:"severity"`
Type string `json:"type"`
ResourceARN string `json:"resource_arn"`
Description string `json:"description"`
Remediation string `json:"remediation"`
Actions []string `json:"actions,omitempty"`
Resources []string `json:"resources,omitempty"`
}
SecurityFinding represents a security issue found during IAM analysis
type Statement ¶
type Statement struct {
Sid string `json:"Sid,omitempty"`
Effect string `json:"Effect"`
Principal interface{} `json:"Principal,omitempty"`
Action interface{} `json:"Action"`
Resource interface{} `json:"Resource"`
Condition interface{} `json:"Condition,omitempty"`
}
Statement represents a single statement in an IAM policy
type TrustPolicy ¶
type TrustPolicy struct {
Version string `json:"Version"`
Statement []TrustStatement `json:"Statement"`
}
TrustPolicy represents a parsed trust policy
type TrustStatement ¶
type TrustStatement struct {
Effect string `json:"Effect"`
Principal interface{} `json:"Principal"`
Action interface{} `json:"Action"`
Condition interface{} `json:"Condition,omitempty"`
}
TrustStatement represents a statement in a trust policy
type UserInfo ¶
type UserInfo struct {
UserName string `json:"user_name"`
UserARN string `json:"user_arn"`
Path string `json:"path"`
CreateDate time.Time `json:"create_date"`
PasswordLastUsed *time.Time `json:"password_last_used,omitempty"`
Tags map[string]string `json:"tags,omitempty"`
}
UserInfo contains basic user information