Skip to content

Commit

Permalink
Merge pull request #359 from center-for-threat-informed-defense/280-a…
Browse files Browse the repository at this point in the history
…dd-documentdb-interoperability

280 add documentdb interoperability
  • Loading branch information
seansica authored Jan 13, 2025
2 parents 1ddb53a + 7a98c93 commit 7ee03dd
Show file tree
Hide file tree
Showing 42 changed files with 4,200 additions and 3,907 deletions.
273 changes: 0 additions & 273 deletions .eslintrc.yml

This file was deleted.

3 changes: 0 additions & 3 deletions app/lib/database-configuration.js
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,6 @@ async function checkForInvalidEnterpriseCollectionId() {
if (attackObject.stix.type === 'x-mitre-collection') {
if (invalidIds.includes(attackObject.stix.id)) {
attackObject.stix.id = validId;
// eslint-disable-next-line no-await-in-loop
await attackObject.save();
collectionUpdates += 1;
}
Expand All @@ -160,7 +159,6 @@ async function checkForInvalidEnterpriseCollectionId() {
}
}
if (attackObjectUpdated) {
// eslint-disable-next-line no-await-in-loop
await attackObject.save();
objectUpdates += 1;
}
Expand Down Expand Up @@ -190,7 +188,6 @@ async function checkForInvalidEnterpriseCollectionId() {
}

if (collectionIndexUpdated) {
// eslint-disable-next-line no-await-in-loop
await collectionIndex.save();
collectionIndexUpdates += 1;
}
Expand Down
3 changes: 3 additions & 0 deletions app/lib/database-connection.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ exports.initializeConnection = async function (options) {

const mongoose = require('mongoose');

// Set `strictQuery` to `true` to omit unknown fields in queries.
mongoose.set('strictQuery', true);

// Configure mongoose to use ES6 promises
mongoose.Promise = global.Promise;

Expand Down
4 changes: 3 additions & 1 deletion app/lib/database-in-memory.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ exports.initializeConnection = async function () {

const uri = mongod.getUri();

// Set `strictQuery` to `true` to omit unknown fields in queries.
mongoose.set('strictQuery', true);

// Configure mongoose to use ES6 promises
mongoose.Promise = global.Promise;

Expand Down Expand Up @@ -39,7 +42,6 @@ exports.clearDatabase = async function () {

for (const key in collections) {
const collection = collections[key];
// eslint-disable-next-line no-await-in-loop
await collection.deleteMany();
}
};
Expand Down
4 changes: 3 additions & 1 deletion app/lib/regex.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
'use strict';

const logger = require('../lib/logger');

exports.sanitizeRegex = function (expression) {
// Compile the expression. If it's valid, return the expression. Otherwise, return an empty string.
try {
// Escapes all regex characters so they are treated like literal characters rather than special regex characters
// eslint-disable-next-line no-useless-escape
expression = expression.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
// eslint-disable-next-line no-new
new RegExp(expression);
return expression;
} catch (err) {
logger.warn(err);
return '';
}
};
4 changes: 2 additions & 2 deletions app/repository/_abstract.repository.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,8 @@ class AbstractRepository {
* @param {*} modified The modification date for the document.
* @returns {Object} The removed document.
*/
async findOneAndRemove(stixId, modified) {
throw new NotImplementedError(this.constructor.name, 'findOneAndRemove');
async findOneAndDelete(stixId, modified) {
throw new NotImplementedError(this.constructor.name, 'findOneAndDelete');
}

/**
Expand Down
Loading

0 comments on commit 7ee03dd

Please sign in to comment.