Skip to content

Commit

Permalink
fix: check if output parameter is located inside root (#896)
Browse files Browse the repository at this point in the history
  • Loading branch information
martyanovandrey authored Nov 18, 2024
1 parent d91a614 commit 69296e7
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/services/includers/batteries/unarchive.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import {Headers, extract} from 'tar-stream';

import type {PassThrough} from 'stream';

import {getRealPath} from '@diplodoc/transform/lib/utilsFS';

import {IncluderFunctionParams} from '../../../models';

const name = 'unarchive';
Expand Down Expand Up @@ -87,7 +89,14 @@ async function includerFunction(params: IncluderFunctionParams<Params>) {

const contentPath = index === 0 ? join(writeBasePath, input) : join(readBasePath, input);

const writePath = join(writeBasePath, output);
const writePath = getRealPath(join(writeBasePath, output));

if (!writePath.startsWith(writeBasePath)) {
throw new UnarchiveIncluderError(
`Expected the output parameter to be located inside project root, got: ${output}`,
output,
);
}

try {
await pipeline(contentPath, writePath);
Expand Down

0 comments on commit 69296e7

Please sign in to comment.