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

fix: check if output parameter is located inside root #896

Merged
merged 2 commits into from
Nov 18, 2024
Merged
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: 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
Loading