diff --git a/src/db/create-db.ts b/src/db/create-db.ts index 3586dc0f..77a26440 100644 --- a/src/db/create-db.ts +++ b/src/db/create-db.ts @@ -55,6 +55,8 @@ async function class_query(db: OrientDB.ODatabase, options: IOrientJSONClassOpti if (idx > -1) { alias = name; const replaced = name.replace(/-/g, ''); + console.log('found aliases: ', replaced); + name = replaced; } try { @@ -70,14 +72,19 @@ async function class_query(db: OrientDB.ODatabase, options: IOrientJSONClassOpti const query = `ALTER CLASS ${name} SHORTNAME ${alias}`; await db.exec(query); } + console.log('done with creating superclasses'); return cls; } async function create_classes(db: OrientDB.ODatabase) { + for (const cls of schema.classes) { const c = await class_query(db, cls); await create_properties(c, cls.properties); } + + console.log('done creating db'); + //TODO give user some indication db is being created } async function create_properties(cls: OrientDB.Class, props: OrientDB.PropertyCreateConfig[]): Promise { diff --git a/src/db/schema.ts b/src/db/schema.ts index 4eb9135b..719bb357 100644 --- a/src/db/schema.ts +++ b/src/db/schema.ts @@ -147,7 +147,7 @@ export const schema: ISchemaFile = { }, { name: "artifact", - superClasses: ["cyber-observable-core"], + superClasses: ["cyberobservablecore"], properties: [ { name: "mime_type", type: "String", collate: "default" }, { name: "payload_bin", type: "Binary", collate: "default" }, @@ -175,7 +175,6 @@ export const schema: ISchemaFile = { name: "attack-pattern", superClasses: ["core"], properties: [ - { name: "external_references", type: "EmbeddedList", collate: "default" }, { name: "name", type: "String", mandatory: true, notNull: true, collate: "default" }, { name: "description", type: "String", collate: "default" }, { name: "aliases", type: "EmbeddedList", collate: "default" }, @@ -190,7 +189,7 @@ export const schema: ISchemaFile = { }, { name: "autonomous-system", - superClasses: ["cyber-observable-core"], + superClasses: ["cyberobservablecore"], properties: [ { name: "number", type: "Integer", mandatory: true, notNull: true, collate: "default"}, { name: "name", type: "String", collate: "default" }, @@ -272,7 +271,7 @@ export const schema: ISchemaFile = { }, { name: "directory", - superClasses: ["cyber-observable-core"], + superClasses: ["cyberobservablecore"], properties: [ { name: "path", type: "String", mandatory: true, notNull: true, collate: "default" }, { name: "path_enc", type: "String", collate: "default" }, @@ -284,7 +283,7 @@ export const schema: ISchemaFile = { }, { name: "domain-name", - superClasses: ["cyber-observable-core"], + superClasses: ["cyberobservablecore"], properties: [ { name: "value", type: "String", mandatory: true, notNull: true, collate: "default" }, { name: "resolves_to_refs", type: "EmbeddedList", collate: "default" }, @@ -310,7 +309,7 @@ export const schema: ISchemaFile = { }, { name: "email-addr", - superClasses: ["cyber-observable-core"], + superClasses: ["cyberobservablecore"], properties: [ { name: "value", type: "String", mandatory: true, notNull: true, collate: "default" }, { name: "display_name", type: "String", collate: "default" }, @@ -319,7 +318,7 @@ export const schema: ISchemaFile = { }, { name: "email-message", - superClasses: ["cyber-observable-core"], + superClasses: ["cyberobservablecore"], properties: [ { name: "is_multipart", type: "Boolean", mandatory: true, notNull:true , collate: "default" }, { name: "date", type: "DateTime", collate: "default" }, @@ -352,7 +351,7 @@ export const schema: ISchemaFile = { }, { name: "file", - superClasses: ["cyber-observable-core"], + superClasses: ["cyberobservablecore"], properties: [ { name: "hashes", type: "EmbeddedMap", collate: "default" }, { name: "size", type: "Integer", collate: "default" }, @@ -465,7 +464,7 @@ export const schema: ISchemaFile = { }, { name: "ipv4-addr", - superClasses: ["cyber-observable-core"], + superClasses: ["cyberobservablecore"], properties: [ { name: "value", type: "String", mandatory: true, notNull: true, collate: "default" }, { name: "resolves_to_refs", type: "EmbeddedList", collate: "default" }, @@ -474,7 +473,7 @@ export const schema: ISchemaFile = { }, { name: "ipv6-addr", - superClasses: ["cyber-observable-core"], + superClasses: ["cyberobservablecore"], properties: [ { name: "value", type: "String", mandatory: true, notNull: true, collate: "default" }, { name: "resolves_to_refs", type: "EmbeddedList", collate: "default" }, @@ -483,7 +482,7 @@ export const schema: ISchemaFile = { }, { name: "language-content", - superClasses: ["language-meta-core"], + superClasses: ["languagemetacore"], properties: [ { name: "object_ref", type: "String", mandatory: true , notNull: true, collate: "default"}, { name: "object_modified", type: "DateTime", collate: "default"}, @@ -509,7 +508,7 @@ export const schema: ISchemaFile = { }, { name: "mac-addr", - superClasses: ["cyber-observable-core"], + superClasses: ["cyberobservablecore"], properties: [ { name: "value", type: "String", mandatory: true, notNull: true, collate: "default" } ], @@ -558,7 +557,7 @@ export const schema: ISchemaFile = { }, { name: "marking-definition", - superClasses: ["marking-meta-core"], + superClasses: ["markingmetacore"], properties: [ { name: "name", type: "String", collate: "default" }, { name: "definition_type", type: "String", mandatory: true, notNull: true , collate: "default" }, @@ -573,14 +572,14 @@ export const schema: ISchemaFile = { }, { name: "mutex", - superClasses: ["cyber-observable-core"], + superClasses: ["cyberobservablecore"], properties: [ { name: "name", type: "String", mandatory: true, notNull: true, collate: "default" } ], }, { name: "network-traffic", - superClasses: ["cyber-observable-core"], + superClasses: ["cyberobservablecore"], properties: [ { name: "start", type: "DateTime", collate: "default" }, { name: "end", type: "DateTime", collate: "default" }, @@ -645,7 +644,7 @@ export const schema: ISchemaFile = { }, { name: "process", - superClasses: ["cyber-observable-core"], + superClasses: ["cyberobservablecore"], properties: [ { name: "is_hidden", type: "Boolean", collate: "default" }, { name: "pid", type: "Integer", collate: "default" }, @@ -680,7 +679,7 @@ export const schema: ISchemaFile = { }, { name: "software", - superClasses: ["cyber-observable-core"], + superClasses: ["cyberobservablecore"], properties: [ { name: "name", type: "String", mandatory: true, notNull: true, collate: "default"}, { name: "cpe", type: "String", collate: "default" }, @@ -734,14 +733,14 @@ export const schema: ISchemaFile = { }, { name: "url", - superClasses: ["cyber-observable-core"], + superClasses: ["cyberobservablecore"], properties: [ { name: "value", type: "String", mandatory: true, notNull: true, collate: "default" } ], }, { name: "user-account", - superClasses: ["cyber-observable-core"], + superClasses: ["cyberobservablecore"], properties: [ { name: "user_id", type: "String", collate: "default" }, { name: "credential", type: "String", collate: "default" }, @@ -775,14 +774,13 @@ export const schema: ISchemaFile = { name: "vulnerability", superClasses: ["core"], properties: [ - { name: "external_references", type: "EmbeddedList", collate: "default" }, { name: "name", type: "String", mandatory: true, notNull: true, collate: "default" }, { name: "description", type: "String", collate: "default" }, ], }, { name: "windows-registry-key", - superClasses: ["cyber-observable-core"], + superClasses: ["cyberobservablecore"], properties: [ { name: "key", type: "String", collate: "default" }, { name: "values", type: "EmbeddedList", collate: "default" }, @@ -793,7 +791,7 @@ export const schema: ISchemaFile = { }, { name: "x509-certificate", - superClasses: ["cyber-observable-core"], + superClasses: ["cyberobservablecore"], properties: [ { name: "is_self_signed", type: "Boolean", collate: "default" }, { name: "hashes", type: "EmbeddedMap", collate: "default" }, diff --git a/src/graph/graphFunctions.ts b/src/graph/graphFunctions.ts index 90f57ff5..84367016 100644 --- a/src/graph/graphFunctions.ts +++ b/src/graph/graphFunctions.ts @@ -139,7 +139,7 @@ export class GraphUtils { } /** - * pkg should be a JSON object complying to the Stix2.0 bundle schema + * pkg should be a JSON object complying to the Stix2.1 bundle schema * * @param {BundleType} pkg * @returns {Promise} @@ -160,7 +160,7 @@ export class GraphUtils { try { // Add relationships to graph for (const r of relationships) { - // console.log(`adding relationship ${r.id}`); + console.log(`adding relationship ${r.id}`); let to_node = this.cy.getElementById(r.target_ref); let from_node = this.cy.getElementById(r.source_ref); if (from_node.length === 0) { diff --git a/src/stix/stixnode.ts b/src/stix/stixnode.ts index 33c4d5d0..e5d9572c 100644 --- a/src/stix/stixnode.ts +++ b/src/stix/stixnode.ts @@ -12,7 +12,7 @@ export let node_img: { [index: string]: string } = {}; export interface StixNodeData extends cytoscape.NodeDataDefinition { name?: string; // the_data.name, id: Identifier; // the_data.id, - label?: string; // the_data.name, + label?: string; // the_data.label, type: StixType; // the_type, level?: 1; // version: the_data.version, @@ -46,9 +46,9 @@ export class StixNode implements IStixNode { * Represents a stix node in the graph. One of these is attached to each node on the canvas. * The actual data is stored here for easy access. stixNode.raw_data should hold the actual * stix JSON - * @param {StixNodeData} the_data - * @param {StixType} the_type - * @param {DataSourceType} d_source + * @param {StixNodeData} the_data Object Thrown to Cytoscape Node + * @param {StixType} the_type - Object From Database + * @param {DataSourceType} d_source - Whether we are drag and drop or queried from DB. */ constructor(the_data: StixNodeData, the_type: StixType, d_source: DataSourceType) { @@ -64,7 +64,12 @@ export class StixNode implements IStixNode { data_source: d_source, }; if (the_type !== 'marking-definition') { - this.data.name = the_data.name; + if(the_data.name == undefined){ + console.log('the data does not have a name: ', the_data) + this.data.name = the_data.type; + }else{ + this.data.name = the_data.name; + } this.data.modified = the_data.modified; } diff --git a/src/ui/database-config-widget.ts b/src/ui/database-config-widget.ts index 16980b9d..420c69d9 100644 --- a/src/ui/database-config-widget.ts +++ b/src/ui/database-config-widget.ts @@ -115,6 +115,7 @@ class DatabaseConfigDialog { this.useConfig = $( "#db-config-list input:checked" ).val() as string; this._storage.current = this.useConfig; ipcRenderer.send('useDatabase', this._storage.get(this.useConfig)); + //add progress bar here tied to this._anchor.dialog("close"); }