Exemplo n.º 1
0
 private void ModelChildCreated([NotNull] IStrength strength)
 {
     if (strength.Visible)
     {
         AddGridRow(strength, _grid.PrimaryGrid);
     }
 }
Exemplo n.º 2
0
        private void Assign([NotNull] IMitigation mitigation, [NotNull] IStrength strength, MitigationStatus status = MitigationStatus.Undefined)
        {
            if (_threatType != null)
            {
                _threatType.AddMitigation(mitigation, strength);
            }
            else if (_threatEvent != null)
            {
                if (_standardMitigationsContainer.Visible && _standardMitigations.Checked &&
                    !(_threatEvent.ThreatType?.Mitigations?.Any(x => x.MitigationId == mitigation.Id) ?? false))
                {
                    _threatEvent.ThreatType?.AddMitigation(mitigation, strength);
                }

                _threatEvent.AddMitigation(mitigation, strength, status);
            }
            else if (_weakness != null)
            {
                _weakness.AddMitigation(mitigation, strength);
            }
            else if (_vulnerability != null)
            {
                if (_standardMitigationsContainer.Visible && _standardMitigations.Checked &&
                    !(_vulnerability.Weakness?.Mitigations?.Any(x => x.MitigationId == mitigation.Id) ?? false))
                {
                    _vulnerability.Weakness?.AddMitigation(mitigation, strength);
                }

                _vulnerability.AddMitigation(mitigation, strength, status);
            }
        }
 public ProcedureController(ICountry serv, IProductName prodName, IProductCode prodCode, IMarketingAuthorizNumber marketingAuthorizNumber, IPackSize packSize,
                            IApprDocsType apprDocsType, IStrength strength, IManufacturer manufacturer, IArtwork artwork, IMarketingAuthorizHolder marketingAuthorizHolder,
                            IPharmaceuticalForm pharmaceuticalForm, IProductService product, IProcedure procedure, IBaseEmailService emailService, IArchProccessor archProccessor)
 {
     _countryService                 = serv;
     _productNameService             = prodName;
     _productCodeService             = prodCode;
     _packSizeService                = packSize;
     _marketingAuthorizNumberService = marketingAuthorizNumber;
     _apprDocsTypeService            = apprDocsType;
     _strengthService                = strength;
     _manufacturerService            = manufacturer;
     _artworkService                 = artwork;
     _marketingAuthorizHolderService = marketingAuthorizHolder;
     _pharmaceuticalFormService      = pharmaceuticalForm;
     _productService                 = product;
     _emailService     = emailService;
     _procedureService = procedure;
     _archProccessor   = archProccessor;
     emailer           = new Emailer()
     {
         Login         = WebConfigurationManager.AppSettings["login"],
         Pass          = WebConfigurationManager.AppSettings["password"],
         From          = WebConfigurationManager.AppSettings["from"],
         Port          = int.Parse(WebConfigurationManager.AppSettings["smtpPort"]),
         SmtpServer    = WebConfigurationManager.AppSettings["smtpSrv"],
         DirectorMail  = WebConfigurationManager.AppSettings["directorMail"],
         DeveloperMail = WebConfigurationManager.AppSettings["developerMail"],
     };
     _currentUser = GetCurrentUser();
 }
Exemplo n.º 4
0
        public IThreatEventMitigation AddMitigation(IMitigation mitigation, IStrength strength,
                                                    MitigationStatus status = MitigationStatus.Proposed, string directives = null)
        {
            if (!(IsInitialized?.Get() ?? false))
            {
                return(null);
            }
            if (mitigation == null)
            {
                throw new ArgumentNullException(nameof(mitigation));
            }

            IThreatEventMitigation result = null;

            if (GetMitigation(mitigation.Id) == null)
            {
                result            = new ThreatEventMitigation(MySelf?.Get(), mitigation, strength);
                result.Status     = status;
                result.Directives = directives;
                if (_mitigations == null)
                {
                    _mitigations = new List <IThreatEventMitigation>();
                }
                _mitigations.Add(result);
                Dirty.IsDirty = true;
                _threatEventMitigationAdded?.Invoke(MitigationsContainer?.Get(), result);
            }

            return(result);
        }
        public IVulnerabilityMitigation AddMitigation(IMitigation mitigation, IStrength strength,
                                                      MitigationStatus status = MitigationStatus.Proposed, string directives = null)
        {
            if (mitigation == null)
            {
                throw new ArgumentNullException(nameof(mitigation));
            }

            IVulnerabilityMitigation result = null;

            if (GetMitigation(mitigation.Id) == null && Instance is IVulnerability vulnerability)
            {
                result = new VulnerabilityMitigation(vulnerability, mitigation, strength)
                {
                    Status = status, Directives = directives
                };
                if (_mitigations == null)
                {
                    _mitigations = new List <IVulnerabilityMitigation>();
                }
                _mitigations.Add(result);
                if (Instance is IDirty dirtyObject)
                {
                    dirtyObject.SetDirty();
                }
                _vulnerabilityMitigationAdded?.Invoke(vulnerability, result);
            }

            return(result);
        }
Exemplo n.º 6
0
        private void ModelChildRemoved([NotNull] IStrength strength)
        {
            var row = GetRow(strength);

            if (row != null)
            {
                RemoveEventSubscriptions(row);
                _grid.PrimaryGrid.Rows.Remove(row);
            }
        }
 public WeaknessMitigation([NotNull] IThreatModel model, [NotNull] IWeakness weakness,
                           [NotNull] IMitigation mitigation, IStrength strength) : this()
 {
     _model        = model;
     _modelId      = model.Id;
     _weaknessId   = weakness.Id;
     _weakness     = weakness;
     _mitigationId = mitigation.Id;
     _mitigation   = mitigation;
     Strength      = strength;
 }
Exemplo n.º 8
0
 public ThreatTypeMitigation([NotNull] IThreatModel model, [NotNull] IThreatType threatType,
                             [NotNull] IMitigation mitigation, IStrength strength) : this()
 {
     _model        = model;
     _modelId      = model.Id;
     _threatTypeId = threatType.Id;
     _threatType   = threatType;
     _mitigationId = mitigation.Id;
     _mitigation   = mitigation;
     Strength      = strength;
 }
        public void Add([NotNull] IStrength strength)
        {
            if (_strengths == null)
            {
                _strengths = new List <IStrength>();
            }

            _strengths.Add(strength);

            SetDirty();
            _strengthCreated?.Invoke(strength);
        }
        public IStrength AddStrength([Range(0, 100)] int id, [Required] string name)
        {
            IStrength result = null;

            if (!(_strengths?.Any(x => x.Id == id) ?? false))
            {
                result = new StrengthDefinition(this, id, name);
                Add(result);
            }

            return(result);
        }
Exemplo n.º 11
0
        public VulnerabilityMitigation([NotNull] IVulnerability vulnerability, [NotNull] IMitigation mitigation, IStrength strength) : this()
        {
            _model           = vulnerability.Model;
            _modelId         = vulnerability.Model.Id;
            _vulnerabilityId = vulnerability.Id;
            _vulnerability   = vulnerability;
            _mitigationId    = mitigation.Id;
            _mitigation      = mitigation;
            Strength         = strength;

            _model.AutoApplySchemas(this);
        }
Exemplo n.º 12
0
 private void _strengths_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (_strengths.SelectedItem is IStrength strength)
     {
         _strength   = strength;
         _ok.Enabled = true;
     }
     else
     {
         _ok.Enabled = false;
     }
 }
Exemplo n.º 13
0
 static public Abilities GetAbilities(IStrength strength, IDexterity dexterity, IConstitution constitution, IIntelligence intelligence, IWisdom wisdom, ICharisma charisma)
 {
     return(new Abilities()
     {
         Strength = strength,
         Dexterity = dexterity,
         Constitution = constitution,
         Intelligence = intelligence,
         Wisdom = wisdom,
         Charisma = charisma
     });
 }
Exemplo n.º 14
0
        public ThreatEventMitigation([NotNull] IThreatEvent threatEvent, [NotNull] IMitigation mitigation, IStrength strength) : this()
        {
            _model         = threatEvent.Model;
            _modelId       = threatEvent.Model.Id;
            _threatEventId = threatEvent.Id;
            _threatEvent   = threatEvent;
            _mitigationId  = mitigation.Id;
            _mitigation    = mitigation;
            Strength       = strength;

            _model.AutoApplySchemas(this);
        }
        private void _useExisting_CheckedChanged(object sender, EventArgs e)
        {
            _ok.Enabled = CalculateOkEnabled();

            _threatTypes.Enabled = true;
            _existingThreatTypeStrength.Enabled = true;
            _strength                      = _existingThreatTypeStrength.SelectedItem as IStrength;
            _name.Enabled                  = false;
            _description.Enabled           = false;
            _severity.Enabled              = false;
            _newThreatTypeStrength.Enabled = false;
        }
Exemplo n.º 16
0
        private void _ok_Click(object sender, EventArgs e)
        {
            int id = GetFreeIdUp(_id.Value);

            if (id == -1)
            {
                id = GetFreeIdDown(_id.Value);
            }
            if (id > 0)
            {
                _strength             = _threatModel.AddStrength(id, _name.Text);
                _strength.Description = _description.Text;
            }
        }
Exemplo n.º 17
0
 public Abilities(
     IStrength strength,
     IDexterity dexterity,
     IConstitution constitution,
     IIntelligence intelligence,
     IWisdom wisdom,
     ICharisma charisma)
 {
     Strength     = strength ?? throw new ArgumentNullException(nameof(strength));
     Dexterity    = dexterity ?? throw new ArgumentNullException(nameof(dexterity));
     Constitution = constitution ?? throw new ArgumentNullException(nameof(constitution));
     Intelligence = intelligence ?? throw new ArgumentNullException(nameof(intelligence));
     Wisdom       = wisdom ?? throw new ArgumentNullException(nameof(wisdom));
     Charisma     = charisma ?? throw new ArgumentNullException(nameof(charisma));
 }
Exemplo n.º 18
0
        private void AddGridRow([NotNull] IStrength strength, [NotNull] GridPanel panel)
        {
            var row = new GridRow(
                strength.Id,
                strength.Name,
                strength.Description);

            ((INotifyPropertyChanged)strength).PropertyChanged += OnStrengthPropertyChanged;
            row.Tag = strength;
            for (int i = 0; i < row.Cells.Count; i++)
            {
                row.Cells[i].PropertyChanged += OnPropertyChanged;
            }
            panel.Rows.Add(row);
        }
Exemplo n.º 19
0
        public void Add([NotNull] IStrength strength)
        {
            if (_strengths == null)
            {
                _strengths = new List <IStrength>();
            }

            _strengths.Add(strength);

            if (this == ThreatModelManager.Model)
            {
                Dirty.IsDirty = true;
                _strengthCreated?.Invoke(strength);
            }
        }
Exemplo n.º 20
0
 // GET: Settings
 public SettingsController(ICountry serv, IProductName prodName, IProductCode prodCode, IMarketingAuthorizNumber marketingAuthorizNumber, IPackSize packSize,
                           IApprDocsType apprDocsType, IStrength strength, IManufacturer manufacturer, IArtwork artwork, IMarketingAuthorizHolder marketingAuthorizHolder,
                           IPharmaceuticalForm pharmaceuticalForm, IBase <CountrySettingDTO> countrySettingsService)
 {
     _countryService                 = serv;
     _productNameService             = prodName;
     _productCodeService             = prodCode;
     _packSizeService                = packSize;
     _marketingAuthorizNumberService = marketingAuthorizNumber;
     _apprDocsTypeService            = apprDocsType;
     _strengthService                = strength;
     _manufacturerService            = manufacturer;
     _artworkService                 = artwork;
     _marketingAuthorizHolderService = marketingAuthorizHolder;
     _pharmaceuticalFormService      = pharmaceuticalForm;
     _countrySettingsService         = countrySettingsService;
 }
Exemplo n.º 21
0
        private GridRow GetRow([NotNull] IStrength strength)
        {
            GridRow result = null;

            var rows = _grid.PrimaryGrid.Rows.OfType <GridRow>().ToArray();

            foreach (var row in rows)
            {
                if (row.Tag == strength)
                {
                    result = row;
                    break;
                }
            }

            return(result);
        }
        public IThreatTypeMitigation AddMitigation([NotNull] IMitigation mitigation, IStrength strength)
        {
            IThreatTypeMitigation result = null;

            if (GetMitigation(mitigation.Id) == null)
            {
                result = new ThreatTypeMitigation(Model, this, mitigation, strength);
                if (_mitigations == null)
                {
                    _mitigations = new List <IThreatTypeMitigation>();
                }
                _mitigations.Add(result);
                SetDirty();
                _threatTypeMitigationAdded?.Invoke(this, result);
            }

            return(result);
        }
        public IStrength GetMappedStrength(int id)
        {
            IStrength result = null;

            if (_strengths?.Any() ?? false)
            {
                var strengths = _strengths?.OrderBy(x => x.Id).ToArray();
                foreach (var strength in strengths)
                {
                    if (strength.Id >= id)
                    {
                        result = strength;
                        break;
                    }
                }

                if (result == null)
                {
                    result = strengths.LastOrDefault();
                }
            }

            return(result);
        }
Exemplo n.º 24
0
        private bool IsSelected([NotNull] IStrength item, [Required] string filter)
        {
            var result = (!string.IsNullOrWhiteSpace(item.Name) &&
                          item.Name.IndexOf(filter, StringComparison.OrdinalIgnoreCase) >= 0) ||
                         (!string.IsNullOrWhiteSpace(item.Description) &&
                          item.Description.IndexOf(filter, StringComparison.OrdinalIgnoreCase) >= 0);

            if (!result && (item.Properties?.Any() ?? false))
            {
                var properties = item.Properties.ToArray();
                foreach (var property in properties)
                {
                    var stringValue = property.StringValue;
                    if ((!string.IsNullOrWhiteSpace(stringValue) &&
                         stringValue.IndexOf(filter, StringComparison.OrdinalIgnoreCase) >= 0))
                    {
                        result = true;
                        break;
                    }
                }
            }

            return(result);
        }
Exemplo n.º 25
0
        public int CompareTo(IStrength other)
        {
            var comparer = new StrengthComparer();

            return(comparer.Compare(this, other));
        }
 private bool IsUsed([NotNull] IStrength strength)
 {
     return((_entities?.Any(x => x.ThreatEvents?.Any(y => y.Mitigations?.Any(z => z.StrengthId == strength.Id) ?? false) ?? false) ?? false) ||
            (_dataFlows?.Any(x => x.ThreatEvents?.Any(y => y.Mitigations?.Any(z => z.StrengthId == strength.Id) ?? false) ?? false) ?? false) ||
            (_threatTypes?.Any(x => x.Mitigations?.Any(y => y.StrengthId == strength.Id) ?? false) ?? false));
 }
 private void _existingThreatTypeStrength_SelectedIndexChanged(object sender, EventArgs e)
 {
     _strength   = _existingThreatTypeStrength.SelectedItem as IStrength;
     _ok.Enabled = CalculateOkEnabled();
 }