From 4232fe528f7170db3fc76fa0ab20a411f419151d Mon Sep 17 00:00:00 2001 From: robertSt7 <104770750+robertSt7@users.noreply.github.com> Date: Fri, 5 Apr 2024 10:11:49 +0200 Subject: [PATCH 1/7] Update cla.yml (#69) --- .github/workflows/cla.yml | 36 ++++++++---------------------------- 1 file changed, 8 insertions(+), 28 deletions(-) diff --git a/.github/workflows/cla.yml b/.github/workflows/cla.yml index 5d17fe6..2c7cc9d 100644 --- a/.github/workflows/cla.yml +++ b/.github/workflows/cla.yml @@ -1,34 +1,14 @@ -name: "CLA Assistant" +name: CLA check + on: issue_comment: types: [created] pull_request_target: - types: [opened,closed,synchronize] + types: [opened, closed, synchronize] jobs: - CLAssistant: - runs-on: ubuntu-latest - steps: - - name: "CLA Assistant" - if: (github.event.comment.body == 'recheck' || github.event.comment.body == 'I have read the CLA Document and I hereby sign the CLA') || github.event_name == 'pull_request_target' - # Beta Release - uses: cla-assistant/github-action@v2.1.1-beta - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - # the below token should have repo scope and must be manually added by you in the repository's secret - PERSONAL_ACCESS_TOKEN : ${{ secrets.PERSONAL_ACCESS_TOKEN }} - with: - path-to-signatures: 'signatures/version1/cla.json' - path-to-document: 'https://github.com/pimcore/pimcore/blob/master/CLA.md' # e.g. a CLA or a DCO document - # branch should not be protected - branch: 'main' - allowlist: user1,bot* - - #below are the optional inputs - If the optional inputs are not given, then default values will be taken - remote-organization-name: 'pimcore' #enter the remote organization name where the signatures should be stored (Default is storing the signatures in the same repository) - remote-repository-name: 'cla' - #create-file-commit-message: 'For example: Creating file for storing CLA Signatures' - #signed-commit-message: 'For example: $contributorName has signed the CLA in #$pullRequestNo' - #custom-notsigned-prcomment: 'pull request comment with Introductory message to ask new contributors to sign' - #custom-pr-sign-comment: 'The signature to be committed in order to sign the CLA' - #custom-allsigned-prcomment: 'pull request comment when all contributors has signed, defaults to **CLA Assistant Lite bot** All Contributors have signed the CLA.' + cla-workflow: + uses: pimcore/workflows-collection-public/.github/workflows/reusable-cla-check.yaml@v1.3.0 + if: (github.event.comment.body == 'recheck' || github.event.comment.body == 'I have read the CLA Document and I hereby sign the CLA') || github.event_name == 'pull_request_target' + secrets: + CLA_ACTION_ACCESS_TOKEN: ${{ secrets.CLA_ACTION_ACCESS_TOKEN }} From 816a831ff1eb7a5419c32edbdcc75f234863b3ce Mon Sep 17 00:00:00 2001 From: Alex Zamponi <562324+alexz707@users.noreply.github.com> Date: Fri, 26 Apr 2024 15:53:28 +0200 Subject: [PATCH 2/7] First test to fix pimcore/web-to-print-bundle#73 --- src/Controller/Document/PrintpageControllerBase.php | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/Controller/Document/PrintpageControllerBase.php b/src/Controller/Document/PrintpageControllerBase.php index 0a17761..f76cdc3 100644 --- a/src/Controller/Document/PrintpageControllerBase.php +++ b/src/Controller/Document/PrintpageControllerBase.php @@ -272,6 +272,18 @@ public function activeGenerateProcessAction(Request $request): JsonResponse $statusUpdate = Processor::getInstance()->getStatusUpdate($document->getId()); } + + // Workaround for a bug which happens when the local filesystem is using a NFS with cache. + // This invalidates the cache and the file_exists() function returns the correct value. + // TODO: check if there are any side effects + try { + if ($dh = opendir(dirname($document->getPdfFileName()))) { + closedir($dh); + } + } catch (\Exception) { + } + + return $this->adminJson([ 'activeGenerateProcess' => !empty($inProgress), 'date' => $date, From e95efc4a1b8487d4fb2727db109b4272fc73095c Mon Sep 17 00:00:00 2001 From: JiaJia Ji Date: Mon, 29 Apr 2024 13:16:24 +0200 Subject: [PATCH 3/7] Update SECURITY.md (#71) --- SECURITY.md | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/SECURITY.md b/SECURITY.md index 53173b7..15268a0 100644 --- a/SECURITY.md +++ b/SECURITY.md @@ -2,19 +2,21 @@ ## Reporting a Vulnerability -If you think that you have found a security issue, -don’t use the bug tracker and don’t publish it publicly. -Instead, all security issues must be reported via 📫 to [security-issue@pimcore.com](mailto:security-issue@pimcore.com). +If you think that you have found a security issue, +don’t use the bug tracker and don’t publish it publicly. +Instead, all security issues must be reported via a private vulnerability report. + +Please follow the [instructions](https://docs.github.com/en/code-security/security-advisories/guidance-on-reporting-and-writing-information-about-vulnerabilities/privately-reporting-a-security-vulnerability#privately-reporting-a-security-vulnerability) to submit a private report. ## Resolving Process -Every submitted security issue is handled with top priority by following these steps: +Every submitted security issue is handled with top priority by following these steps: 1. Confirm the vulnerability 2. Determine the severity 3. Contact reporter 4. Work on a patch 5. Get a CVE identification number (may be done by the reporter or a security service provider) -6. Patch reviewing +6. Patch reviewing 7. Tagging a new release for supported versions -8. Publish security announcement \ No newline at end of file +8. Publish security announcement From 436ab61e8d19b24cb2b9528458dd70569e14060b Mon Sep 17 00:00:00 2001 From: Alex Zamponi <562324+alexz707@users.noreply.github.com> Date: Tue, 30 Apr 2024 10:53:53 +0200 Subject: [PATCH 4/7] Fix for pimcore/web-to-print-bundle#73 --- .../Document/PrintpageControllerBase.php | 55 ++++++++++++------- 1 file changed, 35 insertions(+), 20 deletions(-) diff --git a/src/Controller/Document/PrintpageControllerBase.php b/src/Controller/Document/PrintpageControllerBase.php index f76cdc3..d20a796 100644 --- a/src/Controller/Document/PrintpageControllerBase.php +++ b/src/Controller/Document/PrintpageControllerBase.php @@ -42,7 +42,7 @@ abstract class PrintpageControllerBase extends DocumentControllerBase * * @return JsonResponse * - * @throws \Exception + * @throws Exception */ public function getDataByIdAction(Request $request): JsonResponse { @@ -250,7 +250,7 @@ protected function setValuesToDocument(Request $request, Document $document): vo * * @return JsonResponse * - * @throws \Exception + * @throws Exception */ public function activeGenerateProcessAction(Request $request): JsonResponse { @@ -272,23 +272,11 @@ public function activeGenerateProcessAction(Request $request): JsonResponse $statusUpdate = Processor::getInstance()->getStatusUpdate($document->getId()); } - - // Workaround for a bug which happens when the local filesystem is using a NFS with cache. - // This invalidates the cache and the file_exists() function returns the correct value. - // TODO: check if there are any side effects - try { - if ($dh = opendir(dirname($document->getPdfFileName()))) { - closedir($dh); - } - } catch (\Exception) { - } - - return $this->adminJson([ 'activeGenerateProcess' => !empty($inProgress), 'date' => $date, 'message' => $document->getLastGenerateMessage(), - 'downloadAvailable' => file_exists($document->getPdfFileName()), + 'downloadAvailable' => $this->checkFileExists($document->getPdfFileName()), 'statusUpdate' => $statusUpdate, ]); } @@ -300,7 +288,7 @@ public function activeGenerateProcessAction(Request $request): JsonResponse * * @return BinaryFileResponse * - * @throws \Exception + * @throws Exception */ public function pdfDownloadAction(Request $request): BinaryFileResponse { @@ -310,7 +298,7 @@ public function pdfDownloadAction(Request $request): BinaryFileResponse throw $this->createNotFoundException('Document with id ' . $request->get('id') . ' not found.'); } - if (file_exists($document->getPdfFileName())) { + if ($this->checkFileExists($document->getPdfFileName())) { $response = new BinaryFileResponse($document->getPdfFileName()); $response->headers->set('Content-Type', 'application/pdf'); if ($request->get('download')) { @@ -331,7 +319,7 @@ public function pdfDownloadAction(Request $request): BinaryFileResponse * * @return JsonResponse * - * @throws \Exception + * @throws Exception */ public function startPdfGenerationAction(Request $request, \Pimcore\Config $config): JsonResponse { @@ -416,7 +404,7 @@ public function getProcessingOptionsAction(Request $request): JsonResponse private function getStoredProcessingOptions(int $documentId): array { $filename = PIMCORE_SYSTEM_TEMP_DIRECTORY . DIRECTORY_SEPARATOR . 'web2print-processingoptions-' . $documentId . '_' . $this->getAdminUser()->getId() . '.psf'; - if (file_exists($filename)) { + if ($this->checkFileExists($filename)) { $options = \Pimcore\Tool\Serialize::unserialize(file_get_contents($filename)); if (is_array($options)) { return $options; @@ -438,7 +426,7 @@ private function saveProcessingOptions(int $documentId, array $options): void * * @return JsonResponse * - * @throws \Exception + * @throws Exception */ public function cancelGenerationAction(Request $request): JsonResponse { @@ -446,4 +434,31 @@ public function cancelGenerationAction(Request $request): JsonResponse return $this->adminJson(['success' => true]); } + + /** + * Checks if a file exists on the filesystem. + * @param string $filePath + * @return bool + */ + private function checkFileExists(string $filePath): bool + { + $this->invalidateFsCacheFor($filePath); + return file_exists($filePath); + } + + /** + * Invalidates the FS cache for a given file path by opening and closing the directory. + * This is a workaround for a bug which happens when the local filesystem is using a NFS with cache. + * @param string $filePath + * @return void + */ + private function invalidateFsCacheFor(string $filePath): void + { + try { + if ($dh = opendir(dirname($filePath))) { + closedir($dh); + } + } catch (Exception) { + } + } } From 1c27202421fea9929a939c5af94b0cfe6ab70f52 Mon Sep 17 00:00:00 2001 From: alexz707 Date: Tue, 30 Apr 2024 11:56:34 +0000 Subject: [PATCH 5/7] Apply php-cs-fixer changes --- src/Controller/Document/PrintpageControllerBase.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/Controller/Document/PrintpageControllerBase.php b/src/Controller/Document/PrintpageControllerBase.php index d20a796..a047f7e 100644 --- a/src/Controller/Document/PrintpageControllerBase.php +++ b/src/Controller/Document/PrintpageControllerBase.php @@ -437,19 +437,24 @@ public function cancelGenerationAction(Request $request): JsonResponse /** * Checks if a file exists on the filesystem. + * * @param string $filePath + * * @return bool */ private function checkFileExists(string $filePath): bool { $this->invalidateFsCacheFor($filePath); + return file_exists($filePath); } /** * Invalidates the FS cache for a given file path by opening and closing the directory. * This is a workaround for a bug which happens when the local filesystem is using a NFS with cache. + * * @param string $filePath + * * @return void */ private function invalidateFsCacheFor(string $filePath): void From 107b6758ab6aaaec7717e3222e4a7950f56f5589 Mon Sep 17 00:00:00 2001 From: Bernhard Rusch Date: Fri, 17 May 2024 14:19:52 +0200 Subject: [PATCH 6/7] Include image in test PDF generation (#68) * Include image in test PDF generation * fixed undefined array index * Update src/Processor/Gotenberg.php Co-authored-by: Sebastian Blank --------- Co-authored-by: Sebastian Blank --- public/img/logo.png | Bin 0 -> 8044 bytes src/Processor/Gotenberg.php | 49 +++++++++++--------- templates/settings/test_web2print.html.twig | 5 ++ 3 files changed, 33 insertions(+), 21 deletions(-) create mode 100644 public/img/logo.png diff --git a/public/img/logo.png b/public/img/logo.png new file mode 100644 index 0000000000000000000000000000000000000000..1ce55ce95a94b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QB)PGSHlouF4B~Pnz^YSRzBfVdM>v3~=XqWwfE9+%4~7YY;I3AXI-AUdd*YB*Dvc zO}Kc{Bhl6l>xEYQKmB|nUqk6~NuQ80-usLA@PTXud_&}DfA~(?vnt9{-wNcHFdFm< zow18P`-dYsAeW~v6U!y3{s(VnlKBEzV-z)OabL&#qnDO=ZR xKQX}3T+t=@9iab90_<;k>|eZDbj%f#4PL{Jm_?<4&-69_t);H3R;FST_FuDw8z=w( literal 0 HcmV?d00001 diff --git a/src/Processor/Gotenberg.php b/src/Processor/Gotenberg.php index 87941cc..cfc3a2c 100644 --- a/src/Processor/Gotenberg.php +++ b/src/Processor/Gotenberg.php @@ -24,6 +24,10 @@ use Pimcore\Bundle\WebToPrintBundle\Model\Document\PrintAbstract; use Pimcore\Bundle\WebToPrintBundle\Processor; use Pimcore\Logger; +use function array_merge; +use function file_exists; +use function json_decode; +use function key_exists; class Gotenberg extends Processor { @@ -32,35 +36,15 @@ class Gotenberg extends Processor */ protected function buildPdf(PrintAbstract $document, object $config): string { - $web2printConfig = Config::getWeb2PrintConfig(); - $gotenbergSettings = $web2printConfig['gotenbergSettings']; - $gotenbergSettings = json_decode($gotenbergSettings, true); - $params = ['document' => $document]; $this->updateStatus($document->getId(), 10, 'start_html_rendering'); $html = $document->renderDocument($params); - $params['hostUrl'] = 'http://nginx:80'; - if (!empty($web2printConfig['gotenbergHostUrl'])) { - $params['hostUrl'] = $web2printConfig['gotenbergHostUrl']; - } - - $html = $this->processHtml($html, $params); $this->updateStatus($document->getId(), 40, 'finished_html_rendering'); - if ($gotenbergSettings) { - foreach (['header', 'footer'] as $item) { - if (key_exists($item, $gotenbergSettings) && $gotenbergSettings[$item] && - file_exists($gotenbergSettings[$item])) { - $gotenbergSettings[$item . 'Template'] = $gotenbergSettings[$item]; - } - unset($gotenbergSettings[$item]); - } - } - try { $this->updateStatus($document->getId(), 50, 'pdf_conversion'); - $pdf = $this->getPdfFromString($html, $gotenbergSettings ?? []); + $pdf = $this->getPdfFromString($html); $this->updateStatus($document->getId(), 100, 'saving_pdf_document'); } catch (\Exception $e) { Logger::error((string) $e); @@ -92,6 +76,29 @@ public function getProcessingOptions(): array */ public function getPdfFromString(string $html, array $params = [], bool $returnFilePath = false): string { + $web2printConfig = Config::getWeb2PrintConfig(); + + $processParams = [ + 'hostUrl' => $web2printConfig['gotenbergHostUrl'] ?? 'http://nginx:80', + ]; + + $html = $this->processHtml($html, $processParams); + + $gotenbergSettings = $web2printConfig['gotenbergSettings'] ?? ''; + $gotenbergSettings = json_decode($gotenbergSettings, true); + + if ($gotenbergSettings) { + foreach (['header', 'footer'] as $item) { + if (key_exists($item, $gotenbergSettings) && $gotenbergSettings[$item] && + file_exists($gotenbergSettings[$item])) { + $gotenbergSettings[$item . 'Template'] = $gotenbergSettings[$item]; + } + unset($gotenbergSettings[$item]); + } + + $params = array_merge($params, $gotenbergSettings); + } + $params = $params ?: $this->getDefaultOptions(); $event = new PrintConfigEvent($this, [ diff --git a/templates/settings/test_web2print.html.twig b/templates/settings/test_web2print.html.twig index 5ec22f0..356106c 100644 --- a/templates/settings/test_web2print.html.twig +++ b/templates/settings/test_web2print.html.twig @@ -76,5 +76,10 @@

Background Test

This text could have a background color depending on configured settings.

+ +

Image Test

+ + + From 0af211b8c6755cd2d0a19475397aa5704061e794 Mon Sep 17 00:00:00 2001 From: robertSt7 Date: Fri, 17 May 2024 12:20:08 +0000 Subject: [PATCH 7/7] Apply php-cs-fixer changes --- src/Processor/Gotenberg.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Processor/Gotenberg.php b/src/Processor/Gotenberg.php index cfc3a2c..61c121a 100644 --- a/src/Processor/Gotenberg.php +++ b/src/Processor/Gotenberg.php @@ -16,18 +16,18 @@ namespace Pimcore\Bundle\WebToPrintBundle\Processor; +use function array_merge; +use function file_exists; use Gotenberg\Gotenberg as GotenbergAPI; use Gotenberg\Stream; +use function json_decode; +use function key_exists; use Pimcore\Bundle\WebToPrintBundle\Config; use Pimcore\Bundle\WebToPrintBundle\Event\DocumentEvents; use Pimcore\Bundle\WebToPrintBundle\Event\Model\PrintConfigEvent; use Pimcore\Bundle\WebToPrintBundle\Model\Document\PrintAbstract; use Pimcore\Bundle\WebToPrintBundle\Processor; use Pimcore\Logger; -use function array_merge; -use function file_exists; -use function json_decode; -use function key_exists; class Gotenberg extends Processor {