From b3d4aff67a90a3eb80d207109688a888eda0f63a Mon Sep 17 00:00:00 2001 From: "Grayson, Matthew" Date: Thu, 21 Mar 2024 16:02:06 -0500 Subject: [PATCH] Add rsc question and resource tables and indexes; add rsc user type; alpahbetized table names. --- backend/src/models/connection.ts | 40 ++++++++++++++++-------------- backend/src/models/index.ts | 22 ++++++++-------- backend/src/models/rsc_question.ts | 20 +++++++++++++++ backend/src/models/rsc_resource.ts | 26 +++++++++++++++++++ backend/src/models/user.ts | 19 +++----------- 5 files changed, 84 insertions(+), 43 deletions(-) create mode 100644 backend/src/models/rsc_question.ts create mode 100644 backend/src/models/rsc_resource.ts diff --git a/backend/src/models/connection.ts b/backend/src/models/connection.ts index ec8c8cd3..bfb83abf 100644 --- a/backend/src/models/connection.ts +++ b/backend/src/models/connection.ts @@ -1,19 +1,21 @@ import { createConnection, Connection } from 'typeorm'; import { + ApiKey, + Cpe, + Cve, Domain, - Service, - Vulnerability, - Scan, Organization, - User, + OrganizationTag, Role, - ScanTask, - Webpage, - ApiKey, + RscQuestion, + RscResource, SavedSearch, - OrganizationTag, - Cpe, - Cve + Scan, + ScanTask, + Service, + User, + Vulnerability, + Webpage } from '.'; let connection: Connection | null = null; @@ -27,20 +29,22 @@ const connectDb = async (logging?: boolean) => { password: process.env.DB_PASSWORD, database: process.env.DB_NAME, entities: [ + ApiKey, Cpe, Cve, Domain, - Service, - Vulnerability, - Scan, Organization, - User, + OrganizationTag, Role, - ScanTask, - Webpage, - ApiKey, + RscQuestion, + RscResource, SavedSearch, - OrganizationTag + Scan, + ScanTask, + Service, + User, + Vulnerability, + Webpage ], synchronize: false, name: 'default', diff --git a/backend/src/models/index.ts b/backend/src/models/index.ts index 310cfb76..9615cbad 100644 --- a/backend/src/models/index.ts +++ b/backend/src/models/index.ts @@ -1,15 +1,17 @@ -export * from './domain'; -export * from './cve'; -export * from './cpe'; -export * from './service'; +export * from './api-key'; export * from './connection'; -export * from './vulnerability'; -export * from './scan'; +export * from './cpe'; +export * from './cve'; +export * from './domain'; export * from './organization'; -export * from './user'; +export * from './organization-tag'; export * from './role'; +export * from './rsc_question'; +export * from './rsc_resource'; +export * from './saved-search'; +export * from './scan'; export * from './scan-task'; +export * from './service'; +export * from './user'; +export * from './vulnerability'; export * from './webpage'; -export * from './api-key'; -export * from './saved-search'; -export * from './organization-tag'; diff --git a/backend/src/models/rsc_question.ts b/backend/src/models/rsc_question.ts new file mode 100644 index 00000000..b8488ff9 --- /dev/null +++ b/backend/src/models/rsc_question.ts @@ -0,0 +1,20 @@ +import { + BaseEntity, + Column, + Entity, + OneToMany, + PrimaryGeneratedColumn +} from 'typeorm'; +import { RscResource } from './rsc_resource'; + +@Entity() +export class RscQuestion extends BaseEntity { + @PrimaryGeneratedColumn('uuid') + id: string; + + @Column() + name: string; + + @OneToMany(() => RscResource, (resource) => resource.question) + resources: RscResource[]; +} diff --git a/backend/src/models/rsc_resource.ts b/backend/src/models/rsc_resource.ts new file mode 100644 index 00000000..cfd330f1 --- /dev/null +++ b/backend/src/models/rsc_resource.ts @@ -0,0 +1,26 @@ +import { + BaseEntity, + Column, + Entity, + ManyToOne, + PrimaryGeneratedColumn +} from 'typeorm'; +import { RscQuestion } from './rsc_question'; + +@Entity() +export class RscResource extends BaseEntity { + @PrimaryGeneratedColumn('uuid') + id: string; + + @Column() + title: string; + + @Column() + text: string; + + @Column() + url: string; + + @ManyToOne(() => RscQuestion, (question) => question.resources) + question: RscQuestion; +} diff --git a/backend/src/models/user.ts b/backend/src/models/user.ts index 8a9cdc5f..1aa72b5e 100644 --- a/backend/src/models/user.ts +++ b/backend/src/models/user.ts @@ -10,14 +10,15 @@ import { PrimaryGeneratedColumn, BeforeUpdate } from 'typeorm'; -import { Organization, Role } from './'; +import { Role } from './'; import { ApiKey } from './api-key'; export enum UserType { - STANDARD = 'standard', GLOBAL_VIEW = 'globalView', GLOBAL_ADMIN = 'globalAdmin', - REGIONAL_ADMIN = 'regionalAdmin' + REGIONAL_ADMIN = 'regionalAdmin', + READY_SET_CYBER = 'readySetCyber', + STANDARD = 'standard' } @Entity() export class User extends BaseEntity { @@ -115,16 +116,4 @@ export class User extends BaseEntity { nullable: true }) state: string; - - // @Column({ - // nullable: true, - // default: 0 - // }) - // numberOfOrganizations: number; - - // @Column({ - // nullable: true, - // default: [] - // }) - // organizationIds: Array; }