public void Apply() { if (_dirty) { _model.SetExtensionConfiguration(_extensionId, _configuration); } var schemaManager = new EffortPropertySchemaManager(_model); if (EnableEffort) { schemaManager.AddSupport(); } else { schemaManager.RemoveSupport(); } }
private Effort CalculateMaxEffort([NotNull] EffortPropertySchemaManager schemaManager) { Effort result = Effort.Undefined; var model = _mitigation.Model; var propertyType = schemaManager.GetPropertyType(); if (model != null && propertyType != null) { CalculateMaxEffort(model, propertyType); var entities = model.Entities?.ToArray(); if (entities?.Any() ?? false) { foreach (var entity in entities) { var effort = CalculateMaxEffort(entity, propertyType); if (effort > result) { result = effort; } } } var flows = model.DataFlows?.ToArray(); if (flows?.Any() ?? false) { foreach (var flow in flows) { var effort = CalculateMaxEffort(flow, propertyType); if (effort > result) { result = effort; } } } } return(result); }
public void Refresh() { if (_mitigation != null) { var schemaManager = new EffortPropertySchemaManager(_mitigation.Model); if (schemaManager.IsEffortSupported) { SetInfo("Estimated Effort", CalculateMaxEffort(schemaManager).ToString()); } var properties = ExtensionUtils.GetExtensions <IRoadmapPropertyProvider>()?.ToArray(); if (properties?.Any() ?? false) { foreach (var property in properties) { var propertyValue = property.GetValue(_mitigation); if (propertyValue != null) { SetInfo(property.Name, propertyValue); } } } } }
public RoadmapItem([NotNull] IMitigation mitigation, Effectiveness effectiveness) { _mitigation = mitigation; PortBorderMargin = SizeF.Empty; Label.Text = mitigation.Name; ToolTipText = mitigation.Name; switch (effectiveness) { case Effectiveness.Unknown: Label.TextColor = Color.White; Header.BrushColor = ThreatModelManager.StandardColor; break; case Effectiveness.Minor: Label.TextColor = Color.Black; Header.BrushColor = Color.White; Header.BorderPenColor = Color.DarkGreen; break; case Effectiveness.Average: Label.TextColor = Color.Black; Header.BrushColor = Color.LimeGreen; Header.BorderPenColor = Color.LimeGreen; break; case Effectiveness.Major: Label.TextColor = Color.White; Header.BrushColor = Color.DarkGreen; Header.BorderPenColor = Color.DarkGreen; break; default: throw new ArgumentOutOfRangeException(nameof(effectiveness), effectiveness, null); } if (effectiveness != Effectiveness.Unknown) { AddItem("Effectiveness", effectiveness.ToString()); } var schemaManager = new EffortPropertySchemaManager(mitigation.Model); if (schemaManager.IsEffortSupported) { AddItem("Estimated Effort", CalculateMaxEffort(schemaManager).ToString()); } var properties = ExtensionUtils.GetExtensions <IRoadmapPropertyProvider>()?.ToArray(); if (properties?.Any() ?? false) { foreach (var property in properties) { var propertyValue = property?.GetValue(mitigation); if (propertyValue != null) { AddItem(property.Name, propertyValue); } } } }