Esempio n. 1
0
        public void Initialize([NotNull] IThreatModel model)
        {
            var entitiesPropertySchemaManager = new EntitiesPropertySchemaManager(model);

            entitiesPropertySchemaManager.GetSchema();

            var dataFlowsPropertySchemaManager = new DataFlowsPropertySchemaManager(model);

            dataFlowsPropertySchemaManager.GetSchema();

            var threatsPropertySchemaManager = new ThreatsPropertySchemaManager(model);

            threatsPropertySchemaManager.GetSchema();
        }
Esempio n. 2
0
        private int ImportDataFlows([NotNull] ThreatModel source, [NotNull] IThreatModel target)
        {
            int result = 0;

            var flows = source.Flows;

            if (flows?.Any() ?? false)
            {
                var entitiesSchemaManager  = new EntitiesPropertySchemaManager(target);
                var dataFlowsSchemaManager = new DataFlowsPropertySchemaManager(target);
                var schema = dataFlowsSchemaManager.GetSchema();

                foreach (var flow in flows)
                {
                    var sourceEntity = GetEntity(flow.SourceGuid.ToString(), target, entitiesSchemaManager);
                    var targetEntity = GetEntity(flow.TargetGuid.ToString(), target, entitiesSchemaManager);
                    if (sourceEntity != null && targetEntity != null)
                    {
                        var dataFlow = target.AddDataFlow(flow.Name, sourceEntity.Id, targetEntity.Id);
                        if (dataFlow != null)
                        {
                            dataFlowsSchemaManager.SetMsTmtDataFlowId(dataFlow, flow.FlowId.ToString());

                            var properties = flow.Properties?.ToArray();
                            AddProperties(schema, dataFlow, properties);
                        }

                        IDiagram diagram = target.Diagrams?.FirstOrDefault(x =>
                                                                           string.CompareOrdinal(x.Name, flow.PageName) == 0);
                        diagram?.AddLink(dataFlow);
                        result++;
                    }
                }
            }

            return(result);
        }