public bool VerifyOrCreateSchema()
        {
            var opts = new CreateIndexOptions()
            {
                Background = true
            };

            opts.Name = "ProjectName-A+ScanId-A";
            if (!MongoUtil.IndexExists(Collection, opts.Name))
            {
                Collection.Indexes.CreateOne(new CreateIndexModel <BsonDocument>(Builders <BsonDocument> .IndexKeys
                                                                                 .Ascending(new StringFieldDefinition <BsonDocument, String>("ProjectName"))
                                                                                 .Ascending(new StringFieldDefinition <BsonDocument, String>("ScanId"))
                                                                                 , opts));
            }

            opts.Name = "FirstViolationDetectionDate-A";
            if (!MongoUtil.IndexExists(Collection, opts.Name))
            {
                Collection.Indexes.CreateOne(new CreateIndexModel <BsonDocument>(Builders <BsonDocument> .IndexKeys
                                                                                 .Ascending(new StringFieldDefinition <BsonDocument, DateTime>("FirstViolationDetectionDate"))
                                                                                 , opts));
            }

            opts.Name = "ViolationOccurredDate-A";
            if (!MongoUtil.IndexExists(Collection, opts.Name))
            {
                Collection.Indexes.CreateOne(new CreateIndexModel <BsonDocument>(Builders <BsonDocument> .IndexKeys
                                                                                 .Ascending(new StringFieldDefinition <BsonDocument, DateTime>("ViolationOccurredDate"))
                                                                                 , opts));
            }

            return(true);
        }
Ejemplo n.º 2
0
        public override bool VerifyOrCreateSchema()
        {
            var opts = new CreateIndexOptions()
            {
                Background = true
            };

            opts.Name = "ProjectName-A+ScanId-D";
            if (!MongoUtil.IndexExists(Collection, opts.Name))
            {
                Collection.Indexes.CreateOne(new CreateIndexModel <BsonDocument>(Builders <BsonDocument> .IndexKeys
                                                                                 .Ascending(new StringFieldDefinition <BsonDocument, String>("ProjectName"))
                                                                                 .Descending(new StringFieldDefinition <BsonDocument, String>("ScanId"))
                                                                                 , opts));
            }

            opts.Name = "High-A";
            if (!MongoUtil.IndexExists(Collection, opts.Name))
            {
                Collection.Indexes.CreateOne(new CreateIndexModel <BsonDocument>(Builders <BsonDocument> .IndexKeys
                                                                                 .Ascending(new StringFieldDefinition <BsonDocument, Int64>("High"))
                                                                                 , opts));
            }

            opts.Name = "Medium-A";
            if (!MongoUtil.IndexExists(Collection, opts.Name))
            {
                Collection.Indexes.CreateOne(new CreateIndexModel <BsonDocument>(Builders <BsonDocument> .IndexKeys
                                                                                 .Ascending(new StringFieldDefinition <BsonDocument, Int64>("Medium"))
                                                                                 , opts));
            }

            opts.Name = "Low-A";
            if (!MongoUtil.IndexExists(Collection, opts.Name))
            {
                Collection.Indexes.CreateOne(new CreateIndexModel <BsonDocument>(Builders <BsonDocument> .IndexKeys
                                                                                 .Ascending(new StringFieldDefinition <BsonDocument, Int64>("Low"))
                                                                                 , opts));
            }

            opts.Name = "Information-A";
            if (!MongoUtil.IndexExists(Collection, opts.Name))
            {
                Collection.Indexes.CreateOne(new CreateIndexModel <BsonDocument>(Builders <BsonDocument> .IndexKeys
                                                                                 .Ascending(new StringFieldDefinition <BsonDocument, Int64>("Information"))
                                                                                 , opts));
            }

            opts.Name = "ScanFinished-A";
            if (!MongoUtil.IndexExists(Collection, opts.Name))
            {
                Collection.Indexes.CreateOne(new CreateIndexModel <BsonDocument>(Builders <BsonDocument> .IndexKeys
                                                                                 .Ascending(new StringFieldDefinition <BsonDocument, DateTime>("ScanFinished"))
                                                                                 , opts));
            }


            return(true);
        }
Ejemplo n.º 3
0
        public static T CreateInstance <T>(IMongoDatabase db, String collectionName, ShardKeySpec spec) where T : MongoDBOut, new()
        {
            T retVal = new T();

            retVal.DB         = db;
            retVal.Collection = MongoUtil.MakeCollection(db, collectionName);
            retVal.Spec       = spec;

            return(retVal);
        }
Ejemplo n.º 4
0
        public static IMongoCollection <BsonDocument> MakeCollection(IMongoDatabase db, String collectionName)
        {
            if (!MongoUtil.CollectionExists(db, collectionName))
            {
                _log.Info($"Creating collection {collectionName}");

                db.CreateCollection(collectionName);
            }


            return(db.GetCollection <BsonDocument>(collectionName));
        }
Ejemplo n.º 5
0
        public override bool VerifyOrCreateSchema()
        {
            var opts = new CreateIndexOptions()
            {
                Background = true
            };

            opts.Name = "ProjectName-A+ScanId-D";
            if (!MongoUtil.IndexExists(Collection, opts.Name))
            {
                Collection.Indexes.CreateOne(new CreateIndexModel <BsonDocument>(Builders <BsonDocument> .IndexKeys
                                                                                 .Ascending(new StringFieldDefinition <BsonDocument, String>("ProjectName"))
                                                                                 .Descending(new StringFieldDefinition <BsonDocument, String>("ScanId"))
                                                                                 , opts));
            }

            opts.Name = "ScanId-D+PathId-A";
            if (!MongoUtil.IndexExists(Collection, opts.Name))
            {
                Collection.Indexes.CreateOne(new CreateIndexModel <BsonDocument>(Builders <BsonDocument> .IndexKeys
                                                                                 .Descending(new StringFieldDefinition <BsonDocument, String>("ScanId"))
                                                                                 .Ascending(new StringFieldDefinition <BsonDocument, String>("PathId"))
                                                                                 , opts));
            }

            opts.Name = "SimilarityId-D+ProjectName-A";
            if (!MongoUtil.IndexExists(Collection, opts.Name))
            {
                Collection.Indexes.CreateOne(new CreateIndexModel <BsonDocument>(Builders <BsonDocument> .IndexKeys
                                                                                 .Descending(new StringFieldDefinition <BsonDocument, String>("SimilarityId"))
                                                                                 .Ascending(new StringFieldDefinition <BsonDocument, String>("ProjectName"))
                                                                                 , opts));
            }

            opts.Name = "SinkFileName-A";
            if (!MongoUtil.IndexExists(Collection, opts.Name))
            {
                Collection.Indexes.CreateOne(new CreateIndexModel <BsonDocument>(Builders <BsonDocument> .IndexKeys
                                                                                 .Ascending(new StringFieldDefinition <BsonDocument, String>("SinkFileName"))
                                                                                 , opts));
            }

            opts.Name = "QueryName-A";
            if (!MongoUtil.IndexExists(Collection, opts.Name))
            {
                Collection.Indexes.CreateOne(new CreateIndexModel <BsonDocument>(Builders <BsonDocument> .IndexKeys
                                                                                 .Ascending(new StringFieldDefinition <BsonDocument, String>("QueryName"))
                                                                                 , opts));
            }

            opts.Name = "ResultSeverity-A";
            if (!MongoUtil.IndexExists(Collection, opts.Name))
            {
                Collection.Indexes.CreateOne(new CreateIndexModel <BsonDocument>(Builders <BsonDocument> .IndexKeys
                                                                                 .Ascending(new StringFieldDefinition <BsonDocument, String>("ResultSeverity"))
                                                                                 , opts));
            }

            opts.Name = "QueryLanguage-A";
            if (!MongoUtil.IndexExists(Collection, opts.Name))
            {
                Collection.Indexes.CreateOne(new CreateIndexModel <BsonDocument>(Builders <BsonDocument> .IndexKeys
                                                                                 .Ascending(new StringFieldDefinition <BsonDocument, String>("QueryLanguage"))
                                                                                 , opts));
            }

            opts.Name = "ScanFinished-A";
            if (!MongoUtil.IndexExists(Collection, opts.Name))
            {
                Collection.Indexes.CreateOne(new CreateIndexModel <BsonDocument>(Builders <BsonDocument> .IndexKeys
                                                                                 .Ascending(new StringFieldDefinition <BsonDocument, DateTime>("ScanFinished"))
                                                                                 , opts));
            }


            return(true);
        }
Ejemplo n.º 6
0
        public bool VerifyOrCreateSchema()
        {
            var opts = new CreateIndexOptions()
            {
                Background = true
            };

            opts.Name = "ProjectName-A+ScanId-A";
            if (!MongoUtil.IndexExists(Collection, opts.Name))
            {
                Collection.Indexes.CreateOne(new CreateIndexModel <BsonDocument>(Builders <BsonDocument> .IndexKeys
                                                                                 .Ascending(new StringFieldDefinition <BsonDocument, String>("ProjectName"))
                                                                                 .Ascending(new StringFieldDefinition <BsonDocument, String>("ScanId"))
                                                                                 , opts));
            }


            opts.Name = "ScanFinished-A";
            if (!MongoUtil.IndexExists(Collection, opts.Name))
            {
                Collection.Indexes.CreateOne(new CreateIndexModel <BsonDocument>(Builders <BsonDocument> .IndexKeys
                                                                                 .Ascending(new StringFieldDefinition <BsonDocument, DateTime>("ScanFinished"))
                                                                                 , opts));
            }

            opts.Name = "RulesViolated-A";
            if (!MongoUtil.IndexExists(Collection, opts.Name))
            {
                Collection.Indexes.CreateOne(new CreateIndexModel <BsonDocument>(Builders <BsonDocument> .IndexKeys
                                                                                 .Ascending(new StringFieldDefinition <BsonDocument, Int32>("RulesViolated"))
                                                                                 , opts));
            }

            opts.Name = "HighVulnerabilityLibraries-A";
            if (!MongoUtil.IndexExists(Collection, opts.Name))
            {
                Collection.Indexes.CreateOne(new CreateIndexModel <BsonDocument>(Builders <BsonDocument> .IndexKeys
                                                                                 .Ascending(new StringFieldDefinition <BsonDocument, Int32>("HighVulnerabilityLibraries"))
                                                                                 , opts));
            }

            opts.Name = "MediumVulnerabilityLibraries-A";
            if (!MongoUtil.IndexExists(Collection, opts.Name))
            {
                Collection.Indexes.CreateOne(new CreateIndexModel <BsonDocument>(Builders <BsonDocument> .IndexKeys
                                                                                 .Ascending(new StringFieldDefinition <BsonDocument, Int32>("MediumVulnerabilityLibraries"))
                                                                                 , opts));
            }

            opts.Name = "LowVulnerabilityLibraries-A";
            if (!MongoUtil.IndexExists(Collection, opts.Name))
            {
                Collection.Indexes.CreateOne(new CreateIndexModel <BsonDocument>(Builders <BsonDocument> .IndexKeys
                                                                                 .Ascending(new StringFieldDefinition <BsonDocument, Int32>("LowVulnerabilityLibraries"))
                                                                                 , opts));
            }

            opts.Name = "LegalHigh-A";
            if (!MongoUtil.IndexExists(Collection, opts.Name))
            {
                Collection.Indexes.CreateOne(new CreateIndexModel <BsonDocument>(Builders <BsonDocument> .IndexKeys
                                                                                 .Ascending(new StringFieldDefinition <BsonDocument, Int32>("LegalHigh"))
                                                                                 , opts));
            }

            opts.Name = "LegalMedium-A";
            if (!MongoUtil.IndexExists(Collection, opts.Name))
            {
                Collection.Indexes.CreateOne(new CreateIndexModel <BsonDocument>(Builders <BsonDocument> .IndexKeys
                                                                                 .Ascending(new StringFieldDefinition <BsonDocument, Int32>("LegalMedium"))
                                                                                 , opts));
            }

            opts.Name = "LegalLow-A";
            if (!MongoUtil.IndexExists(Collection, opts.Name))
            {
                Collection.Indexes.CreateOne(new CreateIndexModel <BsonDocument>(Builders <BsonDocument> .IndexKeys
                                                                                 .Ascending(new StringFieldDefinition <BsonDocument, Int32>("LegalLow"))
                                                                                 , opts));
            }

            return(true);
        }