public bool Execute(IThreatTypeMitigation mitigation)
        {
            var result = false;

            var model = mitigation.Model;

            if (model != null)
            {
                var rule   = mitigation.GetRule(model);
                var parent = mitigation.ThreatType;

                if (parent != null)
                {
                    var parentRule = parent.GetRule(model);

                    if (string.CompareOrdinal(rule?.ToString(), parentRule?.ToString()) != 0)
                    {
                        Ask?.Invoke(this, new Context()
                        {
                            Container = mitigation, Rule = parentRule
                        },
                                    "Inherit Auto Gen Rule from Threat Type", $"Are you sure you want to replace the existing rule for '{mitigation.Mitigation.Name}' with the one assigned to Threat Type '{parent.Name}'?",
                                    true, RequestOptions.YesNo);
                    }
                    else
                    {
                        ShowMessage?.Invoke("Nothing to do, because the Auto Gen Rules are equivalent.");
                    }
                    result = true;
                }
            }

            return(result);
        }
예제 #2
0
 public static MitigationSelectionRule GetRule([NotNull] IThreatTypeMitigation threatTypeMitigation)
 {
     return(threatTypeMitigation.GetRule(threatTypeMitigation.Model) as MitigationSelectionRule);
 }