Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

280 add documentdb interoperability #359

Open
wants to merge 13 commits into
base: project-orion
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@
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 @@
}
}
if (attackObjectUpdated) {
// eslint-disable-next-line no-await-in-loop
await attackObject.save();
objectUpdates += 1;
}
Expand Down Expand Up @@ -190,7 +188,6 @@
}

if (collectionIndexUpdated) {
// eslint-disable-next-line no-await-in-loop
await collectionIndex.save();
collectionIndexUpdates += 1;
}
Expand Down Expand Up @@ -247,7 +244,7 @@
const newMarkingDefinition = new MarkingDefinition(newMarkingDefinitionData);
await newMarkingDefinition.save();
logger.info(`Created static marking definition ${newMarkingDefinition.stix.name}`);
} catch (err) {

Check failure on line 247 in app/lib/database-configuration.js

View workflow job for this annotation

GitHub Actions / static-checks

'err' is defined but never used
logger.error(
`Unable to create static marking definition ${staticMarkingDefinition.name}`,
);
Expand All @@ -255,7 +252,7 @@
}
}
}
} catch (err) {

Check failure on line 255 in app/lib/database-configuration.js

View workflow job for this annotation

GitHub Actions / static-checks

'err' is defined but never used
logger.error('Unable to parse static marking definitions');
}
}
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
Loading