コード例 #1
0
        public void EnrichGraph([NotNull] MitreGraph graph)
        {
            graph.RegisterSource(_name, _version, _catalog.GetLastChangeDateTime());

            var attackPatterns = _catalog.Objects?
                                 .Where(x => !x.Deprecated && !x.Revoked && string.CompareOrdinal(x.Type, "attack-pattern") == 0)
                                 .ToArray();

            if (attackPatterns?.Any() ?? false)
            {
                foreach (var attackPattern in attackPatterns)
                {
                    graph.CreateNode(attackPattern);
                }
            }

            var mitigations = _catalog.Objects?
                              .Where(x => !x.Deprecated && !x.Revoked && string.CompareOrdinal(x.Type, "course-of-action") == 0)
                              .ToArray();

            if (mitigations?.Any() ?? false)
            {
                foreach (var mitigation in mitigations)
                {
                    graph.CreateNode(mitigation);
                }
            }

            var relationships = _catalog.Objects?
                                .Where(x => !x.Deprecated && !x.Revoked && string.CompareOrdinal(x.Type, "relationship") == 0)
                                .ToArray();

            if (relationships?.Any() ?? false)
            {
                foreach (var relationship in relationships)
                {
                    var source = graph.GetNode("ATT&CK", relationship.Source);
                    var target = graph.GetNode("ATT&CK", relationship.Target);
                    if (source != null && target != null)
                    {
                        switch (relationship.Relationship)
                        {
                        case "mitigates":
                            source.AddRelationship(RelationshipType.Mitigates, target);
                            target.AddRelationship(RelationshipType.IsMitigatedBy, source);
                            break;

                        case "subtechnique-of":
                            source.AddRelationship(RelationshipType.ChildOf, target);
                            target.AddRelationship(RelationshipType.ParentOf, source);
                            break;
                        }
                    }
                }
            }
        }
コード例 #2
0
        public void EnrichGraph([NotNull] MitreGraph graph)
        {
            graph.RegisterSource(_catalog.Name, _catalog.Version, _catalog.Date);

            var views = _catalog.Views?
                        .Where(x => x.Type == ViewTypeEnumeration.Graph && x.Status != StatusEnumeration.Deprecated && x.Status != StatusEnumeration.Obsolete)
                        .ToArray();

            if (views?.Any() ?? false)
            {
                foreach (var v in views)
                {
                    graph.CreateNode(v);
                }
            }

            var categories = _catalog.Categories?
                             .Where(x => x.Status != StatusEnumeration.Deprecated && x.Status != StatusEnumeration.Obsolete)
                             .ToArray();

            if (categories?.Any() ?? false)
            {
                foreach (var c in categories)
                {
                    graph.CreateNode(c);
                }
            }

            var weaknesses = _catalog.Weaknesses?
                             .Where(x => x.Status != StatusEnumeration.Deprecated && x.Status != StatusEnumeration.Obsolete)
                             .ToArray();

            if (weaknesses?.Any() ?? false)
            {
                foreach (var w in weaknesses)
                {
                    graph.CreateNode(w);
                }
            }
        }