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

feat: handle improper type validation sync vulnerability #2937

Merged
merged 6 commits into from
Jan 3, 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
10 changes: 5 additions & 5 deletions src/controllers/bulkUpload.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* eslint-disable global-require, import/no-dynamic-require, @typescript-eslint/no-unused-vars */
import { client as errNotificationClient } from '../util/errorNotifier';
import logger from '../logger';
import { CatchErr } from '../util/types';
import { CatchErr, ContextBodySimple } from '../util/types';
// TODO: To be refactored and redisgned

const getDestFileUploadHandler = (version, dest) =>
Expand Down Expand Up @@ -45,7 +45,7 @@
return {};
};

const { destType } = ctx.request.body;
const { destType }: ContextBodySimple = ctx.request.body;

Check warning on line 48 in src/controllers/bulkUpload.ts

View check run for this annotation

Codecov / codecov/patch

src/controllers/bulkUpload.ts#L48

Added line #L48 was not covered by tests
const destFileUploadHandler = getDestFileUploadHandler('v0', destType.toLowerCase());

if (!destFileUploadHandler || !destFileUploadHandler.processFileData) {
Expand Down Expand Up @@ -82,7 +82,7 @@
JSON.stringify(ctx.request.body),
);

const { destType } = ctx.request.body;
const { destType }: ContextBodySimple = ctx.request.body;

Check warning on line 85 in src/controllers/bulkUpload.ts

View check run for this annotation

Codecov / codecov/patch

src/controllers/bulkUpload.ts#L85

Added line #L85 was not covered by tests
const destFileUploadHandler = getPollStatusHandler('v0', destType.toLowerCase());
let response;
if (!destFileUploadHandler || !destFileUploadHandler.processPolling) {
Expand Down Expand Up @@ -117,7 +117,7 @@
JSON.stringify(ctx.request.body),
);

const { destType } = ctx.request.body;
const { destType }: ContextBodySimple = ctx.request.body;

Check warning on line 120 in src/controllers/bulkUpload.ts

View check run for this annotation

Codecov / codecov/patch

src/controllers/bulkUpload.ts#L120

Added line #L120 was not covered by tests
const destFileUploadHandler = getJobStatusHandler('v0', destType.toLowerCase());

if (!destFileUploadHandler || !destFileUploadHandler.processJobStatus) {
Expand Down Expand Up @@ -153,7 +153,7 @@
JSON.stringify(ctx.request.body),
);

const { destType } = ctx.request.body;
const { destType }: ContextBodySimple = ctx.request.body;

Check warning on line 156 in src/controllers/bulkUpload.ts

View check run for this annotation

Codecov / codecov/patch

src/controllers/bulkUpload.ts#L156

Added line #L156 was not covered by tests
const destFileUploadHandler = getJobStatusHandler('v0', destType.toLowerCase());

if (!destFileUploadHandler || !destFileUploadHandler.processJobStatus) {
Expand Down
3 changes: 3 additions & 0 deletions src/util/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ export type FixMe = any;

export type CatchErr = any;

export type ContextBodySimple = {
destType: string;
};
export interface Config {
cdkEnabled?: boolean;
cdkV2Enabled?: boolean;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -190,9 +190,11 @@ const ProxyRequest = async (request) => {
const addPayload = body.JSON.addConversionPayload;
// Mapping Conversion Action
const conversionId = await getConversionActionId(headers, params);
addPayload.operations.forEach((operation) => {
set(operation, 'create.transaction_attribute.conversion_action', conversionId);
});
if (Array.isArray(addPayload.operations)) {
addPayload.operations.forEach((operation) => {
set(operation, 'create.transaction_attribute.conversion_action', conversionId);
});
}
await addConversionToJob(endpoint, headers, firstResponse, addPayload);
const thirdResponse = await runTheJob(
endpoint,
Expand Down
Loading