Download tasks/18c6c60bb5a392b3/levels/level3/patch.diff from FuCY/php: direct link, hf CLI and curl.
- Browser
- Download file 4.22 kB
-
https://huggingface.co/datasets/FuCY/php/resolve/main/tasks/18c6c60bb5a392b3/levels/level3/patch.diff
- Command line
-
hf download hf://datasets/FuCY/php/tasks/18c6c60bb5a392b3/levels/level3/patch.diff
-
curl -L -o patch.diff https://huggingface.co/datasets/FuCY/php/resolve/main/tasks/18c6c60bb5a392b3/levels/level3/patch.diff
4.22 kB
| diff --git a/app/bundles/AssetBundle/Form/Type/AssetType.php b/app/bundles/AssetBundle/Form/Type/AssetType.php | |
| index 995aff06e46..f285498e17b 100644 | |
| --- a/app/bundles/AssetBundle/Form/Type/AssetType.php | |
| +++ b/app/bundles/AssetBundle/Form/Type/AssetType.php | |
| use Symfony\Component\OptionsResolver\OptionsResolver; | |
| use Symfony\Component\Translation\TranslatorInterface; | |
| use Symfony\Component\Validator\Constraints\NotBlank; | |
| +use Symfony\Component\Validator\Constraints\Url; | |
| class AssetType extends AbstractType | |
| { | |
| public function buildForm(FormBuilderInterface $builder, array $options) | |
| 'remotePath', | |
| TextType::class, | |
| [ | |
| - 'label' => 'mautic.asset.asset.form.remotePath', | |
| - 'label_attr' => ['class' => 'control-label'], | |
| - 'attr' => ['class' => 'form-control'], | |
| - 'required' => false, | |
| + 'label' => 'mautic.asset.asset.form.remotePath', | |
| + 'label_attr' => ['class' => 'control-label'], | |
| + 'attr' => ['class' => 'form-control'], | |
| + 'required' => false, | |
| + 'constraints' => [ | |
| + new Url( | |
| + [ | |
| + 'message' => 'mautic.asset.validation.error.url', | |
| + ] | |
| + ), | |
| + ], | |
| ] | |
| ); | |
| diff --git a/app/bundles/AssetBundle/Tests/Controller/Api/AssetApiControllerFunctionalTest.php b/app/bundles/AssetBundle/Tests/Controller/Api/AssetApiControllerFunctionalTest.php | |
| index 411ae853f28..10f6f78a140 100644 | |
| --- a/app/bundles/AssetBundle/Tests/Controller/Api/AssetApiControllerFunctionalTest.php | |
| +++ b/app/bundles/AssetBundle/Tests/Controller/Api/AssetApiControllerFunctionalTest.php | |
| public function testCreateNewRemoteAsset() | |
| $this->assertNotNull($response['asset']['size']); | |
| } | |
| + public function testCreateNewRemoteAssetWithVulnerableFile(): void | |
| + { | |
| + $payload = [ | |
| + 'file' => 'file:///etc/passwd', | |
| + 'storageLocation' => 'remote', | |
| + 'title' => 'title', | |
| + ]; | |
| + $this->client->request('POST', 'api/assets/new', $payload); | |
| + $clientResponse = $this->client->getResponse(); | |
| + $this->assertSame(400, $clientResponse->getStatusCode(), $clientResponse->getContent()); | |
| + $this->assertEquals('{"errors":[{"code":400,"message":"remotePath: The remote should be a valid URL.","details":{"remotePath":["The remote should be a valid URL."]}}]}', $clientResponse->getContent()); | |
| + } | |
| + | |
| public function testCreateNewLocalAsset() | |
| { | |
| $assetsPath = $this->client->getKernel()->getContainer()->getParameter('mautic.upload_dir'); | |
| diff --git a/app/bundles/AssetBundle/Translations/en_US/validators.ini b/app/bundles/AssetBundle/Translations/en_US/validators.ini | |
| index d9532dbcf1b..a9c593adbb3 100644 | |
| --- a/app/bundles/AssetBundle/Translations/en_US/validators.ini | |
| +++ b/app/bundles/AssetBundle/Translations/en_US/validators.ini | |
| mautic.asset.asset.error.missing.title="Assset Title is required." | |
| mautic.asset.asset.error.missing.remote.path="A remote URL must be specified when remote storage is selected." | |
| mautic.asset.asset.error.file.size="Upload failed as the file is %fileSize% MB which exceeds the maximum allowed file size of %maxSize% MB. This setting can be changed in the Configuration." | |
| mautic.asset.asset.error.file.extension="Upload failed as the file extension, %fileExtension%, is not in the list of allowed extensions (%extensions%). This setting can be changed in the Configuration." | |
| -mautic.asset.asset.error.file.extension.js="Upload failed as the file extension is not in the list of allowed extensions (%extensions%). This setting can be changed in the Configuration." | |
| \ No newline at end of file | |
| +mautic.asset.asset.error.file.extension.js="Upload failed as the file extension is not in the list of allowed extensions (%extensions%). This setting can be changed in the Configuration." | |
| +mautic.asset.validation.error.url="The remote should be a valid URL." | |
| \ No newline at end of file | |