Пример #1
0
        public IEnumerable <KeyValuePair <string, IPropertyType> > GetProperties([NotNull] IThreatModel model)
        {
            IEnumerable <KeyValuePair <string, IPropertyType> > result = null;

            var threatTypes = model.ThreatTypes?
                              .OrderByDescending(x => x.Severity, new SeverityComparer())
                              .ToArray();

            if (threatTypes?.Any() ?? false)
            {
                var dict = new Dictionary <string, IPropertyType>();

                foreach (var threatType in threatTypes)
                {
                    var properties = threatType.Properties?
                                     .Where(x => !(x.PropertyType?.DoNotPrint ?? true))
                                     .Select(x => x.PropertyType)
                                     .ToArray();

                    if (properties?.Any() ?? false)
                    {
                        foreach (var property in properties)
                        {
                            if (!dict.ContainsKey(property.Name))
                            {
                                dict.Add(property.Name, property);
                            }
                        }
                    }

                    var eventProperties = new ListThreatEventsPlaceholder().GetProperties(model)?.ToArray();
                    if (eventProperties?.Any() ?? false)
                    {
                        foreach (var ep in eventProperties)
                        {
                            var text = $"[From Events] {ep.Key}";
                            if (!dict.ContainsKey(text))
                            {
                                dict.Add(text, ep.Value);
                            }
                        }
                    }
                }

                result = dict.Where(x => !x.Key.StartsWith("[From Events] "))
                         .OrderBy(x => model.GetSchema(x.Value.SchemaId).Priority)
                         .ThenBy(x => model.GetSchema(x.Value.SchemaId).Namespace)
                         .ThenBy(x => model.GetSchema(x.Value.SchemaId).Name)
                         .ThenBy(x => x.Value.Priority)
                         .Union(dict.Where(x => x.Key.StartsWith("[From Events] "))
                                .OrderBy(x => model.GetSchema(x.Value.SchemaId).Priority)
                                .ThenBy(x => x.Value.Priority))
                         .ToArray();
            }

            return(result);
        }
Пример #2
0
        public IPropertySchema GetSchema()
        {
            var result = _model.GetSchema(_schemaName, Resources.DefaultNamespace) ?? _model.AddSchema(_schemaName, Resources.DefaultNamespace);

            result.AppliesTo   = _scope;
            result.Priority    = 100;
            result.Visible     = true;
            result.System      = false;
            result.AutoApply   = false;
            result.Description = Resources.TmtPropertySchemaDescription;

            return(result);
        }
Пример #3
0
        public IPropertySchema GetSchema()
        {
            var result = _model.GetSchema(SchemaName, Resources.DefaultNamespace);

            if (result == null)
            {
                result             = _model.AddSchema(SchemaName, Resources.DefaultNamespace);
                result.AppliesTo   = Scope.Entity;
                result.Priority    = 30;
                result.Visible     = true;
                result.System      = true;
                result.AutoApply   = false;
                result.Description = Resources.EntitiesPropertySchemaDescription;
            }

            var id = result.GetPropertyType(ThreatModelEntityId);

            if (id == null)
            {
                id             = result.AddPropertyType(ThreatModelEntityId, PropertyValueType.String);
                id.Visible     = false;
                id.Description = Resources.ThreatModelEntityIdDescription;
            }

            return(result);
        }
        public IPropertySchema GetSchema()
        {
            var result = _model.GetSchema(SchemaName, Properties.Resources.DefaultNamespace) ?? _model.AddSchema(SchemaName, Properties.Resources.DefaultNamespace);

            result.AppliesTo     = Scope.Mitigation | Scope.ThreatEventMitigation;
            result.AutoApply     = true;
            result.Priority      = 50;
            result.Visible       = true;
            result.System        = true;
            result.NotExportable = true;
            result.Description   = Properties.Resources.EffortPropertySchemaDescription;

            var effort = result.GetPropertyType("Effort");

            if (effort == null)
            {
                effort = result.AddPropertyType("Effort", PropertyValueType.List);
                if (effort is IListPropertyType listPropertyType)
                {
                    listPropertyType.SetListProvider(new ListProvider());
                    listPropertyType.Context = EnumExtensions.GetEnumLabels <Effort>().TagConcat();
                }
            }
            effort.Visible     = true;
            effort.Description = Resources.PropertyEffort;

            return(result);
        }
Пример #5
0
        public IPropertySchema GetSchema()
        {
            var result = _model.GetSchema(SchemaName, Properties.Resources.DefaultNamespace);

            if (result == null)
            {
                result             = _model.AddSchema(SchemaName, Properties.Resources.DefaultNamespace);
                result.AppliesTo   = Scope.ThreatModel;
                result.AutoApply   = true;
                result.Priority    = 10;
                result.Visible     = false;
                result.System      = true;
                result.Description = Properties.Resources.WordPropertySchemaDescription;
            }

            var ignoredListFields = result.GetPropertyType("IgnoredListFields");

            if (ignoredListFields == null)
            {
                ignoredListFields             = result.AddPropertyType("IgnoredListFields", PropertyValueType.Array);
                ignoredListFields.Visible     = false;
                ignoredListFields.Description = Resources.PropertyIgnoredListFields;
            }

            var columnWidth = result.GetPropertyType("ColumnWidth");

            if (columnWidth == null)
            {
                columnWidth             = result.AddPropertyType("ColumnWidth", PropertyValueType.Array);
                columnWidth.Visible     = false;
                columnWidth.Description = Resources.PropertyColumnWidths;
            }

            return(result);
        }
        public IPropertySchema GetSchema()
        {
            var result = _model.GetSchema(SchemaName, Properties.Resources.DefaultNamespace);

            if (result == null)
            {
                result                       = _model.AddSchema(SchemaName, Properties.Resources.DefaultNamespace);
                result.AppliesTo             = Scope.ThreatType | Scope.ThreatEvent;
                result.AutoApply             = true;
                result.Priority              = 10;
                result.Visible               = true;
                result.System                = true;
                result.RequiredExecutionMode = ExecutionMode.Expert;
                result.Description           = Properties.Resources.ThreatsPropertySchemaDescription;
            }

            var keywords = result.GetPropertyType("Keywords");

            if (keywords == null)
            {
                keywords             = result.AddPropertyType("Keywords", PropertyValueType.Tokens);
                keywords.Visible     = true;
                keywords.Description = Resources.PropertyKeywords;
            }

            return(result);
        }
        public IPropertySchema GetSchema()
        {
            var result = _model.GetSchema(Resources.TmtObjectPropertySchema, Resources.DefaultNamespace);

            if (result == null)
            {
                result             = _model.AddSchema(Resources.TmtObjectPropertySchema, Resources.DefaultNamespace);
                result.AppliesTo   = Scope.Entity | Scope.DataFlow | Scope.TrustBoundary;
                result.Priority    = 30;
                result.Visible     = false;
                result.System      = true;
                result.AutoApply   = false;
                result.Description = Resources.TmtObjectPropertySchemaDescription;
            }

            var id = result.GetPropertyType(ThreatModelObjectId);

            if (id == null)
            {
                id             = result.AddPropertyType(ThreatModelObjectId, PropertyValueType.String);
                id.Visible     = false;
                id.Description = Resources.ThreatModelObjectIdDescription;
            }

            var instanceId = result.GetPropertyType(ThreatModelInstanceId);

            if (instanceId == null)
            {
                instanceId             = result.AddPropertyType(ThreatModelInstanceId, PropertyValueType.String);
                instanceId.Visible     = false;
                instanceId.Description = Resources.ThreatModelInstanceIdDescription;
            }

            return(result);
        }
Пример #8
0
        private static IEnumerable <IPropertySchema> GetSchemas([NotNull] IThreatModel model, IEnumerable <IProperty> properties)
        {
            IEnumerable <IPropertySchema> result = null;

            if (properties?.Any() ?? false)
            {
                List <IPropertySchema> list = new List <IPropertySchema>();
                foreach (var property in properties)
                {
                    var propertyType = model.GetPropertyType(property.PropertyTypeId);
                    if (propertyType != null)
                    {
                        var schema = model.GetSchema(propertyType.SchemaId);
                        if (schema != null && !list.Contains(schema))
                        {
                            list.Add(schema);
                        }
                    }
                }

                if (list.Count > 0)
                {
                    result = list.Where(x => x.Visible)
                             .OrderByDescending(x => x.Priority)
                             .ThenByDescending(x => x.Name);
                }
            }

            return(result);
        }
Пример #9
0
        public IPropertySchema GetSchema()
        {
            var result = _model.GetSchema(SchemaName, Resources.DefaultNamespace) ?? _model.AddSchema(SchemaName, Resources.DefaultNamespace);

            result.AppliesTo     = Scope.ThreatModel;
            result.AutoApply     = true;
            result.Priority      = 10;
            result.Visible       = false;
            result.System        = true;
            result.NotExportable = true;
            result.Description   = Resources.ReportingConfigPropertySchemaDescription;

            var excelSelectedFields = result.GetPropertyType("ExcelSelectedFields") ?? result.AddPropertyType("ExcelSelectedFields", PropertyValueType.Array);

            excelSelectedFields.Visible     = false;
            excelSelectedFields.DoNotPrint  = true;
            excelSelectedFields.Description = Resources.PropertyExcelSelectedFields;

            var wordDocumentPath = result.GetPropertyType("WordDocumentPath") ?? result.AddPropertyType("WordDocumentPath", PropertyValueType.SingleLineString);

            wordDocumentPath.Visible     = false;
            wordDocumentPath.DoNotPrint  = true;
            wordDocumentPath.Description = Resources.PropertyWordDocumentPath;

            var wordSections = result.GetPropertyType("WordSections") ?? result.AddPropertyType("WordSections", PropertyValueType.JsonSerializableObject);

            wordSections.Visible     = false;
            wordSections.DoNotPrint  = true;
            wordSections.Description = Resources.PropertyWordSections;

            return(result);
        }
Пример #10
0
        public IPropertySchema GetSchema()
        {
            var result = _model.GetSchema(SchemaName, Resources.DefaultNamespace) ?? _model.AddSchema(SchemaName, Resources.DefaultNamespace);

            result.AppliesTo     = Scope.ThreatModel;
            result.AutoApply     = true;
            result.Priority      = 10;
            result.Visible       = false;
            result.System        = true;
            result.NotExportable = true;
            result.Description   = Resources.ThreatModelConfigPropertySchemaDescription;

            var horizontalSpacing = result.GetPropertyType("Diagram Layout Horizontal Spacing") ?? result.AddPropertyType("Diagram Layout Horizontal Spacing", PropertyValueType.Integer);

            horizontalSpacing.Visible     = false;
            horizontalSpacing.DoNotPrint  = true;
            horizontalSpacing.Description = Resources.PropertyHorizontalSpacing;

            var verticalSpacing = result.GetPropertyType("Diagram Layout Vertical Spacing") ?? result.AddPropertyType("Diagram Layout Vertical Spacing", PropertyValueType.Integer);

            verticalSpacing.Visible     = false;
            verticalSpacing.DoNotPrint  = true;
            verticalSpacing.Description = Resources.PropertyVerticalSpacing;

            return(result);
        }
        private IEnumerable <ListItem> GetListItems([NotNull] IThreatModel model, IEnumerable <IMitigation> mitigations)
        {
            IEnumerable <ListItem> result = null;

            if (mitigations?.Any() ?? false)
            {
                var list = new List <ListItem>();

                var propertyType = model.GetSchema(SchemaName, SchemaNamespace)?.GetPropertyType(PropertyName);

                foreach (var mitigation in mitigations)
                {
                    var items = new List <ItemRow>();

                    items.Add(new TextRow("Control Type", mitigation.ControlType.GetEnumLabel()));
                    items.Add(new TextRow("Description", mitigation.Description));

                    var itemRows = mitigation.GetItemRows(propertyType)?
                                   .ToArray();
                    if (itemRows?.Any() ?? false)
                    {
                        items.AddRange(itemRows);
                    }

                    list.Add(new ListItem(mitigation.Name, mitigation.Id, items));
                }

                result = list;
            }

            return(result);
        }
        public IEnumerable <KeyValuePair <string, IEnumerable <ListItem> > > GetList(IThreatModel model)
        {
            IEnumerable <KeyValuePair <string, IEnumerable <ListItem> > > result = null;

            var mitigations = model.Mitigations?
                              .OrderBy(x => x.Name)
                              .ToArray();

            if ((mitigations?.Any() ?? false) && !string.IsNullOrWhiteSpace(SchemaNamespace) &&
                !string.IsNullOrWhiteSpace(SchemaName) && !string.IsNullOrWhiteSpace(PropertyName))
            {
                var list = new List <KeyValuePair <string, IEnumerable <ListItem> > >();

                var propertyType = model.GetSchema(SchemaName, SchemaNamespace)?.GetPropertyType(PropertyName);
                if (propertyType != null)
                {
                    var possibleValues = mitigations
                                         .Where(x => x.HasProperty(propertyType))
                                         .Select(x => x.GetProperty(propertyType)?.StringValue)
                                         .OrderBy(x => x)
                                         .Distinct()
                                         .ToArray();

                    if (possibleValues.Any())
                    {
                        foreach (var possibleValue in possibleValues)
                        {
                            if (!string.IsNullOrWhiteSpace(possibleValue))
                            {
                                var selectedMitigations = mitigations
                                                          .Where(x => x.HasProperty(propertyType) &&
                                                                 string.CompareOrdinal(x.GetProperty(propertyType).StringValue,
                                                                                       possibleValue) == 0)
                                                          .ToArray();

                                var listItems = GetListItems(model, selectedMitigations)?.ToArray();
                                if (listItems?.Any() ?? false)
                                {
                                    list.Add(new KeyValuePair <string, IEnumerable <ListItem> >(possibleValue, listItems));
                                }
                            }
                        }
                    }

                    var remainingMitigations = mitigations
                                               .Where(x => !x.HasProperty(propertyType) || string.IsNullOrWhiteSpace(x.GetProperty(propertyType)?.StringValue))
                                               .ToArray();
                    var remainingListItems = GetListItems(model, remainingMitigations)?.ToArray();
                    if (remainingListItems?.Any() ?? false)
                    {
                        list.Add(new KeyValuePair <string, IEnumerable <ListItem> >("<undefined>", remainingListItems));
                    }
                }

                result = list;
            }

            return(result);
        }
        public IEnumerable <KeyValuePair <string, IPropertyType> > GetProperties([NotNull] IThreatModel model)
        {
            IEnumerable <KeyValuePair <string, IPropertyType> > result = null;

            var schemaManager = new AutoGenRulesPropertySchemaManager(model);
            var mitigations   = model.Mitigations?
                                .Where(x => model.GetThreatTypeMitigations(x)?.Any(y => y.HasTop(schemaManager)) ?? false)
                                .OrderBy(x => x.Name)
                                .ToArray();

            if (mitigations?.Any() ?? false)
            {
                var dict = new Dictionary <string, IPropertyType>();

                foreach (var mitigation in mitigations)
                {
                    var properties = mitigation.Properties?
                                     .Where(x => !(x.PropertyType?.DoNotPrint ?? true) &&
                                            model.GetSchema(x.PropertyType.SchemaId) is IPropertySchema schema &&
                                            (string.CompareOrdinal(schema.Namespace, SchemaNamespace) != 0 ||
                                             string.CompareOrdinal(schema.Name, SchemaName) != 0 ||
                                             string.CompareOrdinal(x.PropertyType.Name, PropertyName) != 0))
                                     .Select(x => x.PropertyType)
                                     .ToArray();

                    if (properties?.Any() ?? false)
                    {
                        foreach (var property in properties)
                        {
                            if (!dict.ContainsKey(property.Name))
                            {
                                dict.Add(property.Name, property);
                            }
                        }
                    }
                }

                result = dict
                         .OrderBy(x => model.GetSchema(x.Value.SchemaId).Priority)
                         .ThenBy(x => x.Value.Priority)
                         .ToArray();
            }

            return(result);
        }
        public IEnumerable <KeyValuePair <string, IPropertyType> > GetProperties([NotNull] IThreatModel model)
        {
            IEnumerable <KeyValuePair <string, IPropertyType> > result = null;

            var schema      = new RoadmapPropertySchemaManager(model);
            var mitigations = model.GetUniqueMitigations()?
                              .Where(x => schema.GetStatus(x) == RoadmapStatus.LongTerm)
                              .OrderBy(x => x.Name)
                              .ToArray();

            if (mitigations?.Any() ?? false)
            {
                var dict = new Dictionary <string, IPropertyType>();

                foreach (var mitigation in mitigations)
                {
                    var properties = mitigation.Properties?
                                     .Where(x => !(x.PropertyType?.DoNotPrint ?? true))
                                     .Select(x => x.PropertyType)
                                     .ToArray();

                    if (properties?.Any() ?? false)
                    {
                        foreach (var property in properties)
                        {
                            if (!dict.ContainsKey(property.Name))
                            {
                                dict.Add(property.Name, property);
                            }
                        }
                    }
                }

                result = dict
                         .OrderBy(x => model.GetSchema(x.Value.SchemaId).Priority)
                         .ThenBy(x => model.GetSchema(x.Value.SchemaId).Namespace)
                         .ThenBy(x => model.GetSchema(x.Value.SchemaId).Name)
                         .ThenBy(x => x.Value.Priority)
                         .ToArray();
            }

            return(result);
        }
        public IPropertySchema GetLinksSchema()
        {
            var result = _model.GetSchema(LinksSchemaName, Properties.Resources.DefaultNamespace) ?? _model.AddSchema(LinksSchemaName, Properties.Resources.DefaultNamespace);

            result.AppliesTo     = Scope.Link;
            result.Priority      = 15;
            result.Visible       = false;
            result.System        = true;
            result.AutoApply     = false;
            result.NotExportable = true;
            result.Description   = Properties.Resources.LinksPropertySchemaDescription;

            var points = result.GetPropertyType("Points") ?? result.AddPropertyType("Points", PropertyValueType.Array);

            points.Visible     = false;
            points.DoNotPrint  = true;
            points.Description = Resources.PropertyPoints;

            return(result);
        }
        public IEnumerable <KeyValuePair <string, IPropertyType> > GetProperties([NotNull] IThreatModel model)
        {
            IEnumerable <KeyValuePair <string, IPropertyType> > result = null;

            var threatEvents = model.GetThreatEvents()?
                               .OrderByDescending(x => x.Severity, new SeverityComparer())
                               .ToArray();

            if (threatEvents?.Any() ?? false)
            {
                var dict = new Dictionary <string, IPropertyType>();

                foreach (var threatEvent in threatEvents)
                {
                    var properties = threatEvent.Properties?
                                     .Where(x => !(x.PropertyType?.DoNotPrint ?? true))
                                     .Select(x => x.PropertyType)
                                     .ToArray();

                    if (properties?.Any() ?? false)
                    {
                        foreach (var property in properties)
                        {
                            if (!dict.ContainsKey(property.Name))
                            {
                                dict.Add(property.Name, property);
                            }
                        }
                    }
                }

                result = dict
                         .OrderBy(x => model.GetSchema(x.Value.SchemaId).Priority)
                         .ThenBy(x => model.GetSchema(x.Value.SchemaId).Namespace)
                         .ThenBy(x => model.GetSchema(x.Value.SchemaId).Name)
                         .ThenBy(x => x.Value.Priority)
                         .ToArray();
            }

            return(result);
        }
Пример #17
0
        public IPropertySchema GetSchema()
        {
            var schema = _model.GetSchema(Questions, Resources.DefaultNamespace) ?? _model.AddSchema(Questions, Resources.DefaultNamespace);

            schema.Description   = Resources.QuestionsPropertySchemaDescription;
            schema.Visible       = false;
            schema.AppliesTo     = Scope.ThreatModel;
            schema.System        = true;
            schema.AutoApply     = false;
            schema.NotExportable = false;

            return(schema);
        }
        public IPropertySchema GetSchema()
        {
            var result = _model.GetSchema(SchemaName, Resources.DefaultNamespace) ?? _model.AddSchema(SchemaName, Resources.DefaultNamespace);

            result.AppliesTo   = Scope.ThreatType | Scope.ThreatEvent;
            result.Priority    = 30;
            result.Visible     = true;
            result.System      = false;
            result.AutoApply   = false;
            result.Description = Resources.ThreatsPropertySchemaDescription;

            return(result);
        }
Пример #19
0
        public IPropertySchema GetSchema()
        {
            var result = _model.GetSchema(Resources.TmtDataStorePropertySchema, Resources.DefaultNamespace) ?? _model.AddSchema(Resources.TmtDataStorePropertySchema, Resources.DefaultNamespace);

            result.AppliesTo   = Scope.DataStore;
            result.Priority    = 90;
            result.Visible     = true;
            result.System      = false;
            result.AutoApply   = true;
            result.Description = Resources.EntityPropertySchemaDescription;

            return(result);
        }
        public IEnumerable <KeyValuePair <string, IPropertyType> > GetProperties([NotNull] IThreatModel model)
        {
            IEnumerable <KeyValuePair <string, IPropertyType> > result = null;

            var processes = model.Entities?.OfType <IProcess>().OrderBy(x => x.Name).ToArray();

            if (processes?.Any() ?? false)
            {
                var dict = new Dictionary <string, IPropertyType>();

                foreach (var process in processes)
                {
                    var properties = process.Properties?
                                     .Where(x => !(x.PropertyType?.DoNotPrint ?? true))
                                     .Select(x => x.PropertyType)
                                     .ToArray();

                    if (properties?.Any() ?? false)
                    {
                        foreach (var property in properties)
                        {
                            if (!dict.ContainsKey(property.Name))
                            {
                                dict.Add(property.Name, property);
                            }
                        }
                    }
                }

                result = dict
                         .OrderBy(x => model.GetSchema(x.Value.SchemaId).Priority)
                         .ThenBy(x => model.GetSchema(x.Value.SchemaId).Namespace)
                         .ThenBy(x => model.GetSchema(x.Value.SchemaId).Name)
                         .ThenBy(x => x.Value.Priority)
                         .ToArray();
            }

            return(result);
        }
Пример #21
0
        public IPropertySchema GetSchema()
        {
            var result = _model.GetSchema(SchemaName, Resources.DefaultNamespace) ?? _model.AddSchema(SchemaName, Resources.DefaultNamespace);

            result.AppliesTo     = Scope.Entity;
            result.AutoApply     = true;
            result.Priority      = 10;
            result.Visible       = true;
            result.System        = true;
            result.NotExportable = true;
            result.Description   = Resources.AssociatedDiagramPropertySchemaDescription;

            return(result);
        }
Пример #22
0
        public IPropertySchema GetSchema()
        {
            var result = _model.GetSchema(SchemaName, Resources.DefaultNamespace) ?? _model.AddSchema(SchemaName, Resources.DefaultNamespace);

            result.AppliesTo     = Scope.All;
            result.AutoApply     = false;
            result.Priority      = 10;
            result.Visible       = false;
            result.System        = true;
            result.NotExportable = false;
            result.Description   = Resources.AutoGenRulePropertySchemaDescription;

            return(result);
        }
        public IPropertySchema GetSchema()
        {
            var schema = _model.GetSchema(Annotations, Resources.DefaultNamespace) ?? _model.AddSchema(Annotations, Resources.DefaultNamespace);

            schema.Description   = Resources.AnnotationsPropertySchemaDescription;
            schema.Visible       = true;
            schema.AppliesTo     = Scope.All;
            schema.System        = true;
            schema.AutoApply     = false;
            schema.NotExportable = true;
            schema.Priority      = 1000;

            return(schema);
        }
Пример #24
0
        public IPropertySchema GetSchema()
        {
            var result = _model.GetSchema(SchemaName, Resources.DefaultNamespace) ?? _model.AddSchema(SchemaName, Resources.DefaultNamespace);

            result.AppliesTo     = Scope.ThreatModel;
            result.AutoApply     = false;
            result.Priority      = 100;
            result.Visible       = false;
            result.System        = true;
            result.NotExportable = true;
            result.Description   = Resources.ResidualRiskEstimatorConfigurationPropertySchemaDescription;

            return(result);
        }
        public IPropertySchema GetSchema()
        {
            var schema = _model.GetSchema(Properties.Resources.SchemaName, Properties.Resources.DefaultNamespace);

            if (schema == null)
            {
                schema           = _model.AddSchema(Properties.Resources.SchemaName, Properties.Resources.DefaultNamespace);
                schema.Visible   = false;
                schema.AppliesTo = Scope.All;
                schema.System    = true;
                schema.AutoApply = false;
            }

            return(schema);
        }
        public IPropertySchema GetPropertySchema()
        {
            IPropertySchema result = _model.GetSchema(Properties.Resources.DevOpsPropertySchema,
                                                      Properties.Resources.DefaultNamespace) ?? _model.AddSchema(Properties.Resources.DevOpsPropertySchema,
                                                                                                                 Properties.Resources.DefaultNamespace);

            result.Description   = Properties.Resources.DevOpsPropertySchemaDescription;
            result.Visible       = false;
            result.AppliesTo     = Scope.Mitigation;
            result.System        = true;
            result.AutoApply     = false;
            result.NotExportable = true;

            return(result);
        }
Пример #27
0
        public IPropertySchema GetSchema()
        {
            var result = _model.GetSchema(SchemaName, Properties.Resources.DefaultNamespace) ??
                         _model.AddSchema(SchemaName, Properties.Resources.DefaultNamespace);

            result.AppliesTo             = Scope.Process | Scope.DataStore;
            result.AutoApply             = false;
            result.Priority              = 10;
            result.Visible               = true;
            result.System                = true;
            result.NotExportable         = true;
            result.RequiredExecutionMode = ExecutionMode.Pioneer;
            result.Description           = Properties.Resources.AssetSchemaDescription;

            var descriptionPT = result.GetPropertyType("Asset Description") ??
                                result.AddPropertyType("Asset Description", PropertyValueType.String);

            descriptionPT.Visible     = true;
            descriptionPT.Description = "Description of the Asset.";

            var minValuePT = result.GetPropertyType("Min Value") ?? result.AddPropertyType("Min Value", PropertyValueType.Decimal);

            minValuePT.Visible     = true;
            minValuePT.Description =
                "Minimum estimated value of the Asset, expressed in the main currency for the Threat Model.";

            var maxValuePT = result.GetPropertyType("Max Value") ?? result.AddPropertyType("Max Value", PropertyValueType.Decimal);

            maxValuePT.Visible     = true;
            maxValuePT.Description =
                "Maximum estimated value of the Asset, expressed in the main currency for the Threat Model.";

            var effects = result.GetPropertyType("Concerns");

            if (effects == null)
            {
                effects = result.AddPropertyType("Concerns", PropertyValueType.ListMulti);
                if (effects is IListMultiPropertyType listMultiPropertyType)
                {
                    listMultiPropertyType.SetListProvider(new EffectsListProvider());
                }
            }
            effects.Visible     = true;
            effects.Description = "Main concerns for the Asset.";

            return(result);
        }
        private void LoadItems([NotNull] IEnumerable<IExternalInteractor> entities, 
            [NotNull] List<IThreatEvent> threatEvents,
            [NotNull] List<IThreatEventMitigation> mitigations)
        {
            _externalInteractors.PrimaryGrid.Rows.Clear();
            _fieldsExternalInteractors.Items.Clear();

            if (entities.Any())
            {
                var selectedProperties = GetSelectedProperties();

                foreach (var entity in entities)
                {
                    var row = new GridRow(
                        entity.Name,
                        entity.Description,
                        entity.Parent?.Name ?? string.Empty)
                    {
                        Checked = true,
                        Tag = entity
                    };
                    _externalInteractors.PrimaryGrid.Rows.Add(row);

                    var teArray = entity.ThreatEvents?.ToArray();
                    if (teArray?.Any() ?? false)
                    {
                        threatEvents.AddRange(teArray);

                        foreach (var teItem in teArray)
                        {
                            var mArray = teItem.Mitigations?.ToArray();
                            if (mArray?.Any() ?? false)
                            {
                                mitigations.AddRange(mArray);
                            }
                        }
                    }

                    var properties = entity.Properties?
                        .Where(x => x.PropertyType != null && x.PropertyType.Visible && 
                                    (_model.GetSchema(x.PropertyType.SchemaId)?.Visible ?? false)).ToArray();
                    if (properties?.Any() ?? false)
                    {
                        foreach (var property in properties)
                        {
                            var propertyType = property.PropertyType;
                            if (!_fieldsExternalInteractors.Items.Contains(propertyType))
                                _fieldsExternalInteractors.Items.Add(propertyType, 
                                    selectedProperties?.Contains(propertyType.Id.ToString()) ?? false);
                        }
                    }
                }
            }
        }
Пример #29
0
        private void _properties_SelectedIndexChanged(object sender, EventArgs e)
        {
            _ok.Enabled = IsValid();

            string text;

            if (_properties.SelectedItem is IPropertyType propertyType)
            {
                var schema = _model.GetSchema(propertyType.SchemaId);
                text = schema.Name;
            }
            else
            {
                text = null;
            }
            _schema.Text = text;
        }
Пример #30
0
        public IPropertySchema GetSchema()
        {
            var result = _model.GetSchema(SchemaName, Properties.Resources.DefaultNamespace);

            if (result == null)
            {
                result             = _model.AddSchema(SchemaName, Properties.Resources.DefaultNamespace);
                result.AppliesTo   = Scope.ThreatType;
                result.AutoApply   = true;
                result.Priority    = 10;
                result.Visible     = false;
                result.System      = true;
                result.Description = Resources.AutoThreatGenPropertySchemaDescription;
            }

            return(result);
        }