Skip to content

Commit

Permalink
update property assignement for path traversal
Browse files Browse the repository at this point in the history
  • Loading branch information
OmarFourati committed Jan 9, 2024
1 parent 02f8242 commit 6904ec0
Showing 1 changed file with 9 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -263,19 +263,15 @@ function checkLocalFileExtractorProperty(
property: PropertyAssignment,
validationContext: ValidationContext,
) {
if (propName === 'filePath') {
const validPathRegex = /^(?!.*\.\.\/).*$/;
const isValidPath = validPathRegex.test(propValue.toString());
if (isValidPath === false) {
validationContext.accept(
'error',
'File path cannot start with "../". Path traversal is restricted.',
{
node: property,
property: 'value',
},
);
}
if (propName === 'filePath' && propValue.toString().includes('../')) {
validationContext.accept(
'error',
'File path cannot include "../". Path traversal is restricted.',
{
node: property,
property: 'value',
},
);
}
}

Expand Down

0 comments on commit 6904ec0

Please sign in to comment.