Skip to content

Commit

Permalink
Add rsc question and resource tables and indexes; add rsc user type; …
Browse files Browse the repository at this point in the history
…alpahbetized table names.
  • Loading branch information
Matthew-Grayson committed Mar 21, 2024
1 parent 8fe2660 commit b3d4aff
Show file tree
Hide file tree
Showing 5 changed files with 84 additions and 43 deletions.
40 changes: 22 additions & 18 deletions backend/src/models/connection.ts
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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',
Expand Down
22 changes: 12 additions & 10 deletions backend/src/models/index.ts
Original file line number Diff line number Diff line change
@@ -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';
20 changes: 20 additions & 0 deletions backend/src/models/rsc_question.ts
Original file line number Diff line number Diff line change
@@ -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[];
}
26 changes: 26 additions & 0 deletions backend/src/models/rsc_resource.ts
Original file line number Diff line number Diff line change
@@ -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;
}
19 changes: 4 additions & 15 deletions backend/src/models/user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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<Organization>;
}

0 comments on commit b3d4aff

Please sign in to comment.