207 lines
2.4 KiB
JavaScript
207 lines
2.4 KiB
JavaScript
const config = require('../../config');
|
|
const providers = config.providers;
|
|
const crypto = require('crypto');
|
|
const bcrypt = require('bcrypt');
|
|
const moment = require('moment');
|
|
|
|
module.exports = function(sequelize, DataTypes) {
|
|
const threat_actors = sequelize.define(
|
|
'threat_actors',
|
|
{
|
|
id: {
|
|
type: DataTypes.UUID,
|
|
defaultValue: DataTypes.UUIDV4,
|
|
primaryKey: true,
|
|
},
|
|
|
|
name: {
|
|
type: DataTypes.TEXT,
|
|
|
|
|
|
|
|
},
|
|
|
|
actor_type: {
|
|
type: DataTypes.ENUM,
|
|
|
|
|
|
|
|
values: [
|
|
|
|
"apt",
|
|
|
|
|
|
"cybercrime_group",
|
|
|
|
|
|
"insider",
|
|
|
|
|
|
"hacktivist",
|
|
|
|
|
|
"unknown"
|
|
|
|
],
|
|
|
|
},
|
|
|
|
motivation: {
|
|
type: DataTypes.ENUM,
|
|
|
|
|
|
|
|
values: [
|
|
|
|
"financial",
|
|
|
|
|
|
"espionage",
|
|
|
|
|
|
"disruption",
|
|
|
|
|
|
"ideology",
|
|
|
|
|
|
"unknown"
|
|
|
|
],
|
|
|
|
},
|
|
|
|
origin_country: {
|
|
type: DataTypes.TEXT,
|
|
|
|
|
|
|
|
},
|
|
|
|
aliases: {
|
|
type: DataTypes.TEXT,
|
|
|
|
|
|
|
|
},
|
|
|
|
profile: {
|
|
type: DataTypes.TEXT,
|
|
|
|
|
|
|
|
},
|
|
|
|
threat_level: {
|
|
type: DataTypes.DECIMAL,
|
|
|
|
|
|
|
|
},
|
|
|
|
first_seen_at: {
|
|
type: DataTypes.DATE,
|
|
|
|
|
|
|
|
},
|
|
|
|
last_seen_at: {
|
|
type: DataTypes.DATE,
|
|
|
|
|
|
|
|
},
|
|
|
|
importHash: {
|
|
type: DataTypes.STRING(255),
|
|
allowNull: true,
|
|
unique: true,
|
|
},
|
|
},
|
|
{
|
|
timestamps: true,
|
|
paranoid: true,
|
|
freezeTableName: true,
|
|
},
|
|
);
|
|
|
|
threat_actors.associate = (db) => {
|
|
|
|
|
|
/// loop through entities and it's fields, and if ref === current e[name] and create relation has many on parent entity
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
db.threat_actors.hasMany(db.threat_indicators, {
|
|
as: 'threat_indicators_threat_actor',
|
|
foreignKey: {
|
|
name: 'threat_actorId',
|
|
},
|
|
constraints: false,
|
|
});
|
|
|
|
|
|
db.threat_actors.hasMany(db.threat_campaigns, {
|
|
as: 'threat_campaigns_threat_actor',
|
|
foreignKey: {
|
|
name: 'threat_actorId',
|
|
},
|
|
constraints: false,
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//end loop
|
|
|
|
|
|
|
|
db.threat_actors.belongsTo(db.organizations, {
|
|
as: 'organizations',
|
|
foreignKey: {
|
|
name: 'organizationsId',
|
|
},
|
|
constraints: false,
|
|
});
|
|
|
|
|
|
|
|
|
|
db.threat_actors.belongsTo(db.users, {
|
|
as: 'createdBy',
|
|
});
|
|
|
|
db.threat_actors.belongsTo(db.users, {
|
|
as: 'updatedBy',
|
|
});
|
|
};
|
|
|
|
|
|
|
|
return threat_actors;
|
|
};
|
|
|
|
|