Skip to content

Commit

Permalink
Revert logging
Browse files Browse the repository at this point in the history
  • Loading branch information
aloftus23 committed Oct 2, 2024
1 parent 63ecd92 commit 1a175b6
Show file tree
Hide file tree
Showing 9 changed files with 9 additions and 621 deletions.
99 changes: 6 additions & 93 deletions backend/src/api/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import * as search from './search';
import * as vulnerabilities from './vulnerabilities';
import * as organizations from './organizations';
import * as scans from './scans';
import * as logs from './logs';
import * as users from './users';
import * as scanTasks from './scan-tasks';
import * as stats from './stats';
Expand All @@ -23,13 +22,14 @@ import * as reports from './reports';
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 { 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';
import logger from '../tools/lambda-logger';
import { HttpsProxyAgent } from 'https-proxy-agent';
import * as searchOrganizations from './organizationSearch';

const sanitizer = require('sanitizer');

Expand Down Expand Up @@ -598,7 +598,6 @@ authenticatedRoute.delete(
handlerToExpress(savedSearches.del)
);
authenticatedRoute.get('/scans', handlerToExpress(scans.list));
authenticatedRoute.post('/logs/search', handlerToExpress(logs.list));
authenticatedRoute.get('/granularScans', handlerToExpress(scans.listGranular));
authenticatedRoute.post('/scans', handlerToExpress(scans.create));
authenticatedRoute.get('/scans/:scanId', handlerToExpress(scans.get));
Expand Down Expand Up @@ -656,39 +655,12 @@ authenticatedRoute.delete(
);
authenticatedRoute.post(
'/v2/organizations/:organizationId/users',
handlerToExpress(
organizations.addUserV2,
async (req, user) => {
const orgId = req?.params?.organizationId;
const userId = req?.body?.userId;
const role = req?.body?.role;
if (orgId && userId) {
const orgRecord = await Organization.findOne({ where: { id: orgId } });
const userRecord = await User.findOne({ where: { id: userId } });
return {
timestamp: new Date(),
userPerformedAssignment: user?.data?.id,
organization: orgRecord,
role: role,
user: userRecord
};
}
return {
timestamp: new Date(),
userId: user?.data?.id,
updatePayload: req.body
};
},
'USER ASSIGNED'
)
handlerToExpress(organizations.addUserV2)
);

authenticatedRoute.post(
'/organizations/:organizationId/roles/:roleId/approve',
handlerToExpress(organizations.approveRole)
);

// TO-DO Add logging => /users => user has an org and you change them to a new organization
authenticatedRoute.post(
'/organizations/:organizationId/roles/:roleId/remove',
handlerToExpress(organizations.removeRole)
Expand All @@ -706,58 +678,9 @@ authenticatedRoute.post(
handlerToExpress(organizations.checkDomainVerification)
);
authenticatedRoute.post('/stats', handlerToExpress(stats.get));
authenticatedRoute.post(
'/users',
handlerToExpress(
users.invite,
async (req, user, responseBody) => {
const userId = user?.data?.id;
if (userId) {
const userRecord = await User.findOne({ where: { id: userId } });
return {
timestamp: new Date(),
userPerformedInvite: userRecord,
invitePayload: req.body,
createdUserRecord: responseBody
};
}
return {
timestamp: new Date(),
userId: user.data?.id,
invitePayload: req.body,
createdUserRecord: responseBody
};
},
'USER INVITE'
)
);
authenticatedRoute.post('/users', handlerToExpress(users.invite));
authenticatedRoute.get('/users', handlerToExpress(users.list));
authenticatedRoute.delete(
'/users/:userId',
handlerToExpress(
users.del,
async (req, user, res) => {
const userId = req?.params?.userId;
const userPerformedRemovalId = user?.data?.id;
if (userId && userPerformedRemovalId) {
const userPerformdRemovalRecord = await User.findOne({
where: { id: userPerformedRemovalId }
});
return {
timestamp: new Date(),
userPerformedRemoval: userPerformdRemovalRecord,
userRemoved: userId
};
}
return {
timestamp: new Date(),
userPerformedRemoval: user.data?.id,
userRemoved: req.params.userId
};
},
'USER DENY/REMOVE'
)
);
authenticatedRoute.delete('/users/:userId', handlerToExpress(users.del));
authenticatedRoute.get(
'/users/state/:state',
handlerToExpress(users.getByState)
Expand All @@ -782,17 +705,7 @@ authenticatedRoute.post(
authenticatedRoute.put(
'/users/:userId/register/approve',
checkGlobalAdminOrRegionAdmin,
handlerToExpress(
users.registrationApproval,
async (req, user) => {
return {
timestamp: new Date(),
userId: user?.data?.id,
userToApprove: req.params.userId
};
},
'USER APPROVE'
)
handlerToExpress(users.registrationApproval)
);

authenticatedRoute.put(
Expand Down
175 changes: 0 additions & 175 deletions backend/src/api/logs.ts

This file was deleted.

3 changes: 2 additions & 1 deletion backend/src/models/connection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,8 @@ const connectDb = async (logging?: boolean) => {
VwMostCommonVulns,
VwSeverityStats,
VwDomainStats,
VwOrgStats
VwOrgStats,
Webpage
],
synchronize: false,
name: 'default',
Expand Down
1 change: 0 additions & 1 deletion backend/src/models/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ export * from './service';
export * from './user';
export * from './vulnerability';
export * from './webpage';
export * from './log';
// Mini data lake models
export * from './mini_data_lake/cert_scans';
export * from './mini_data_lake/cidrs';
Expand Down
19 changes: 0 additions & 19 deletions backend/src/models/log.ts

This file was deleted.

Loading

0 comments on commit 1a175b6

Please sign in to comment.