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

            var model = mitigation.Model;

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

                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 Weakness", $"Are you sure you want to replace the existing rule for '{mitigation.Mitigation.Name}' with the one assigned to Weakness '{parent.Name}'?",
                                    true, RequestOptions.YesNo);
                    }
                    else
                    {
                        ShowMessage?.Invoke("Nothing to do, because the Auto Gen Rules are equivalent.");
                    }
                }
            }

            return(result);
        }
Example #2
0
 public static SelectionRule GetRule([NotNull] IWeaknessMitigation weaknessMitigation)
 {
     return(weaknessMitigation.GetRule(weaknessMitigation.Model));
 }