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

Remove ReadySetCyber (RSC) from TypeScript Backend. #723

Merged
merged 2 commits into from
Nov 18, 2024
Merged
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
11 changes: 2 additions & 9 deletions backend/src/api/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ import * as savedSearches from './saved-searches';
import rateLimit from 'express-rate-limit';
import { createProxyMiddleware } from 'http-proxy-middleware';
import { Organization, User, UserType, connectToDatabase } from '../models';
import * as assessments from './assessments';
import * as jwt from 'jsonwebtoken';
import { Request, Response, NextFunction } from 'express';
import fetch from 'node-fetch';
Expand Down Expand Up @@ -96,8 +95,7 @@ app.use(
cors({
origin: [
'http://localhost',
/^https:\/\/(.*\.)?crossfeed\.cyber\.dhs\.gov$/,
/^https:\/\/(.*\.)?readysetcyber\.cyber\.dhs\.gov$/
/^https:\/\/(.*\.)?crossfeed\.cyber\.dhs\.gov$/
],
methods: 'GET,POST,PUT,DELETE,OPTIONS'
})
Expand All @@ -113,7 +111,7 @@ app.use(
'https://cognito-idp.us-east-1.amazonaws.com',
'https://api.staging-cd.crossfeed.cyber.dhs.gov'
],
frameSrc: ["'self'", 'https://www.dhs.gov/ntas/'],
frameSrc: ["'self'"],
imgSrc: [
"'self'",
'data:',
Expand Down Expand Up @@ -309,7 +307,6 @@ app.get('/', handlerToExpress(healthcheck));
app.post('/auth/login', handlerToExpress(auth.login));
app.post('/auth/callback', handlerToExpress(auth.callback));
app.post('/users/register', handlerToExpress(users.register));
app.post('/readysetcyber/register', handlerToExpress(users.RSCRegister));

app.get('/notifications', handlerToExpress(notifications.list));
app.get(
Expand Down Expand Up @@ -798,10 +795,6 @@ authenticatedRoute.put(
'/notifications/:notificationId',
handlerToExpress(notifications.update)
);
//Authenticated ReadySetCyber Routes
authenticatedRoute.get('/assessments', handlerToExpress(assessments.list));

authenticatedRoute.get('/assessments/:id', handlerToExpress(assessments.get));

//************* */
// V2 Routes //
Expand Down
118 changes: 0 additions & 118 deletions backend/src/api/assessments.ts

This file was deleted.

7 changes: 0 additions & 7 deletions backend/src/api/scans.ts
Original file line number Diff line number Diff line change
Expand Up @@ -174,13 +174,6 @@ export const SCAN_SCHEMA: ScanSchema = {
description:
'Creates domains from root domains by doing a single DNS lookup for each root domain.'
},
rscSync: {
type: 'fargate',
isPassive: true,
global: true,
description:
'Retrieves and saves assessments from ReadySetCyber mission instance.'
},
savedSearch: {
type: 'fargate',
isPassive: true,
Expand Down
76 changes: 0 additions & 76 deletions backend/src/api/users.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ import {
isGlobalWriteAdmin,
matchesUserRegion
} from './auth';
import { fetchAssessmentsByUser } from '../tasks/rscSync';

class UserSearch {
@IsInt()
Expand Down Expand Up @@ -270,30 +269,6 @@ If you encounter any difficulties, please feel free to reply to this email (or s
);
};

const sendRSCInviteEmail = async (email: string) => {
const staging = process.env.NODE_ENV !== 'production';

await sendEmail(
email,
'ReadySetCyber Dashboard Invitation',
`Hi there,

You've been invited to join ReadySetCyber Dashboard. To accept the invitation and start using your Dashboard, sign on at ${process.env.FRONTEND_DOMAIN}/readysetcyber/create-account.

CyHy Dashboard access instructions:

1. Visit ${process.env.FRONTEND_DOMAIN}/readysetcyber/create-account.
2. Select "Create Account."
3. Enter your email address and a new password for CyHy Dashboard.
4. A confirmation code will be sent to your email. Enter this code when you receive it.
5. You will be prompted to enable MFA. Scan the QR code with an authenticator app on your phone, such as Microsoft Authenticator. Enter the MFA code you see after scanning.
6. After configuring your account, you will be redirected to CyHy Dashboard.

For more information on using CyHy Dashboard, view the CyHy Dashboard user guide at https://docs.crossfeed.cyber.dhs.gov/user-guide/quickstart/.

If you encounter any difficulties, please feel free to reply to this email (or send an email to ${process.env.CROSSFEED_SUPPORT_EMAIL_REPLYTO}).`
);
};
/**
* @swagger
*
Expand Down Expand Up @@ -945,54 +920,3 @@ export const updateV2 = wrapHandler(async (event) => {
}
return NotFound;
});

/**
* @swagger
*
* /readysetcyber/register:
* post:
* description: New ReadySetCyber user registration.
* tags:
* - RSCUsers
*/
export const RSCRegister = wrapHandler(async (event) => {
const body = await validateBody(NewUser, event.body);
const newRSCUser = {
firstName: body.firstName,
lastName: body.lastName,
email: body.email.toLowerCase(),
userType: UserType.READY_SET_CYBER
};

await connectToDatabase();

// Check if user already exists
let user = await User.findOne({
email: newRSCUser.email
});
if (user) {
console.log('User already exists.');
return {
statusCode: 422,
body: 'User email already exists. Registration failed.'
};
// Create if user does not exist
} else {
user = User.create(newRSCUser);
await User.save(user);
// Fetch RSC assessments for user
await fetchAssessmentsByUser(user.email);
// Send email notification
if (process.env.IS_LOCAL!) {
console.log('Cannot send invite email while running on local.');
} else {
await sendRSCInviteEmail(user.email);
}
}

const savedUser = await User.findOne(user.id);
return {
statusCode: 200,
body: JSON.stringify(savedUser)
};
});
34 changes: 0 additions & 34 deletions backend/src/models/assessment.ts

This file was deleted.

26 changes: 0 additions & 26 deletions backend/src/models/category.ts

This file was deleted.

10 changes: 0 additions & 10 deletions backend/src/models/connection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,11 @@ import {
// Models for the Crossfeed database
ApiKey,
Notification,
Assessment,
Category,
Cpe,
Cve,
Domain,
Organization,
OrganizationTag,
Question,
Resource,
Response,
Role,
SavedSearch,
Scan,
Expand Down Expand Up @@ -176,16 +171,11 @@ const connectDb = async (logging?: boolean) => {
database: process.env.DB_NAME,
entities: [
ApiKey,
Assessment,
Category,
Cpe,
Cve,
Domain,
Organization,
OrganizationTag,
Question,
Resource,
Response,
Role,
SavedSearch,
OrganizationTag,
Expand Down
5 changes: 0 additions & 5 deletions backend/src/models/index.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,11 @@
export * from './api-key';
export * from './assessment';
export * from './category';
export * from './connection';
export * from './cpe';
export * from './cve';
export * from './domain';
export * from './organization';
export * from './organization-tag';
export * from './notification';
export * from './question';
export * from './resource';
export * from './response';
export * from './role';
export * from './saved-search';
export * from './scan';
Expand Down
Loading
Loading