Ejemplo n.º 1
0
        public void Initialize([NotNull] IWeakness weakness)
        {
            _weakness = weakness;
            _model    = weakness.Model;
            _standardMitigationsContainer.Visible = false;
            InitializeGrid(false);
            InitializeItem(weakness);

            var existingMitigations = weakness.Mitigations?.ToArray();
            var mitigations         = _model?.Mitigations?.OrderBy(x => x.Name);

            if (mitigations != null)
            {
                var defaultStrength = _model.GetStrength((int)DefaultStrength.Average);

                foreach (var mitigation in mitigations)
                {
                    var existingMitigation = existingMitigations?.FirstOrDefault(x => x.MitigationId == mitigation.Id);
                    var row = new GridRow(mitigation.Name,
                                          mitigation.ControlType.GetEnumLabel(),
                                          existingMitigation?.Strength ?? defaultStrength);
                    row.Tag     = mitigation;
                    row.Checked = existingMitigation != null;
                    _grid.PrimaryGrid.Rows.Add(row);
                }
            }
        }
Ejemplo n.º 2
0
        public void Initialize([NotNull] IThreatEvent threatEvent)
        {
            _threatEvent = threatEvent;
            _model       = threatEvent.Model;
            _standardMitigationsContainer.Visible = true;
            InitializeGrid(true);
            InitializeItem(threatEvent);

            var existingMitigations = threatEvent.Mitigations?.ToArray();
            var mitigations         = _model?.Mitigations?.OrderBy(x => x.Name);

            if (mitigations != null)
            {
                var defaultStrength = _model.GetStrength((int)DefaultStrength.Average);

                foreach (var mitigation in mitigations)
                {
                    var existingMitigation = existingMitigations?.FirstOrDefault(x => x.MitigationId == mitigation.Id);
                    var row = new GridRow(mitigation.Name,
                                          mitigation.ControlType.GetEnumLabel(),
                                          existingMitigation?.Strength ?? defaultStrength,
                                          existingMitigation?.Status ?? MitigationStatus.Undefined);
                    row.Tag     = mitigation;
                    row.Checked = existingMitigation != null;
                    _grid.PrimaryGrid.Rows.Add(row);
                }
            }
        }
Ejemplo n.º 3
0
        private int GetFreeIdUp(int id)
        {
            int result = id;

            if (_threatModel.GetStrength(id) != null)
            {
                if (id == (int)DefaultStrength.Maximum)
                {
                    result = -1;
                }
                else
                {
                    result = GetFreeIdUp(id + 1);
                }
            }

            return(result);
        }