// RecalculateDocument rebuilds the policy document based on the actions
// this initial implementation is naive and doesn't deduplicate or aggregate policies.
RecalculateDocument rebuilds the policy document based on the actions
this initial implementation is naive and doesn't deduplicate or aggregate policies.
// RecalculateDocument rebuilds the policy document based on the actions // this initial implementation is naive and doesn ' t deduplicate or aggregate policies .
func (p *Policy) RecalculateDocument(actions []AWSAction) {
	statements := []AWSIAMStatement{}
	for _, alert := range actions {
		if alert.Enabled && len(alert.Recommendations) > 0 {
			advisory := alert.GetSelectedAdvisory()
			for _, description := range advisory.Details().Description {
				policy, ok := description.Policy.(AWSIAMPolicy)
				if ok {
					statements = append(statements, policy.Statement...)
				}
			}
		}
	}
	p.LastUpdated = time.Now()
	p.EventCount = len(actions)
	p.Document.Statement = statements
}
func ( p * Policy ) RecalculateDocument ( actions [ ] AWSAction ) { statements := [ ] AWSIAMStatement { } for _ , alert := range actions { if alert . Enabled && len ( alert . Recommendations ) > 0 { advisory := alert . GetSelectedAdvisory ( ) for _ , description := range advisory . Details ( ) . Description { policy , ok := description . Policy . ( AWSIAMPolicy ) if ok { statements = append ( statements , policy . Statement ... ) } } } } p . LastUpdated = time . Now ( ) p . EventCount = len ( actions ) p . Document . Statement = statements }
RecalculateDocument rebuilds the policy document based on the actions
this initial implementation is naive and doesn't deduplicate or aggregate policies.
RecalculateDocument rebuilds the policy document based on the actions this initial implementation is naive and doesn ' t deduplicate or aggregate policies .
// TODO: this should be redesigned to avoid casting from the interface.