From 041eca9b27778ae639e8b11825991f07b3ff4bc4 Mon Sep 17 00:00:00 2001 From: Seungmin Kim <8457324+ehfd@users.noreply.github.com> Date: Sun, 1 Dec 2024 22:43:08 +0900 Subject: [PATCH 1/6] fix(occ): Fix `occ integrity:check-app` and Admin panel "rescan" deliver inconsistent results Signed-off-by: Seungmin Kim <8457324+ehfd@users.noreply.github.com> --- core/Command/Integrity/CheckApp.php | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/core/Command/Integrity/CheckApp.php b/core/Command/Integrity/CheckApp.php index d24b80a4764e6..ce658ec16dabb 100644 --- a/core/Command/Integrity/CheckApp.php +++ b/core/Command/Integrity/CheckApp.php @@ -9,6 +9,8 @@ use OC\Core\Command\Base; use OC\IntegrityCheck\Checker; +use OC\IntegrityCheck\Helpers\AppLocator; +use OC\IntegrityCheck\Helpers\FileAccessHelper; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputOption; @@ -22,6 +24,8 @@ class CheckApp extends Base { public function __construct( private Checker $checker, + private AppLocator $appLocator, + private FileAccessHelper $fileAccessHelper, ) { parent::__construct(); } @@ -43,14 +47,19 @@ protected function configure() { */ protected function execute(InputInterface $input, OutputInterface $output): int { $appid = $input->getArgument('appid'); - $path = (string)$input->getOption('path'); - $result = $this->checker->verifyAppSignature($appid, $path, true); - $this->writeArrayInOutputFormat($input, $output, $result); - if (count($result) > 0) { - $output->writeln('' . count($result) . ' errors found', OutputInterface::VERBOSITY_VERBOSE); - return 1; + $path = (string)$input->getOption('path') ?? $this->appLocator->getAppPath($appid); + if ($this->fileAccessHelper->file_exists($path . '/appinfo/signature.json')) { + // Only verify if the application explicitly ships a signature.json file + $result = $this->checker->verifyAppSignature($appid, $path, true); + $this->writeArrayInOutputFormat($input, $output, $result); + if (count($result) > 0) { + $output->writeln('' . count($result) . ' errors found', OutputInterface::VERBOSITY_VERBOSE); + return 1; + } + $output->writeln('No errors found', OutputInterface::VERBOSITY_VERBOSE); + } else { + $output->writeln('App signature not found, skipping app integrity check', OutputInterface::VERBOSITY_VERBOSE); } - $output->writeln('No errors found', OutputInterface::VERBOSITY_VERBOSE); return 0; } } From 5a457b8da5f2c8687b1a97a5f88769c666cd05e6 Mon Sep 17 00:00:00 2001 From: Seungmin Kim <8457324+ehfd@users.noreply.github.com> Date: Mon, 2 Dec 2024 03:12:13 +0900 Subject: [PATCH 2/6] fix(occ): Fix linting issues Signed-off-by: Seungmin Kim <8457324+ehfd@users.noreply.github.com> --- core/Command/Integrity/CheckApp.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/core/Command/Integrity/CheckApp.php b/core/Command/Integrity/CheckApp.php index ce658ec16dabb..b5706b2b24ef5 100644 --- a/core/Command/Integrity/CheckApp.php +++ b/core/Command/Integrity/CheckApp.php @@ -47,7 +47,10 @@ protected function configure() { */ protected function execute(InputInterface $input, OutputInterface $output): int { $appid = $input->getArgument('appid'); - $path = (string)$input->getOption('path') ?? $this->appLocator->getAppPath($appid); + $path = (string)$input->getOption('path'); + if ($path === '') { + $path = $this->appLocator->getAppPath($appid); + } if ($this->fileAccessHelper->file_exists($path . '/appinfo/signature.json')) { // Only verify if the application explicitly ships a signature.json file $result = $this->checker->verifyAppSignature($appid, $path, true); From ab9ac5046bfdad5220361936af0bc6c10fc1ef17 Mon Sep 17 00:00:00 2001 From: Seungmin Kim <8457324+ehfd@users.noreply.github.com> Date: Sat, 14 Dec 2024 19:02:50 +0900 Subject: [PATCH 3/6] fix(occ): Add condition for isShipped Signed-off-by: Seungmin Kim <8457324+ehfd@users.noreply.github.com> --- core/Command/Integrity/CheckApp.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/core/Command/Integrity/CheckApp.php b/core/Command/Integrity/CheckApp.php index b5706b2b24ef5..403d36b6c8791 100644 --- a/core/Command/Integrity/CheckApp.php +++ b/core/Command/Integrity/CheckApp.php @@ -11,6 +11,7 @@ use OC\IntegrityCheck\Checker; use OC\IntegrityCheck\Helpers\AppLocator; use OC\IntegrityCheck\Helpers\FileAccessHelper; +use OCP\App\IAppManager; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputOption; @@ -24,6 +25,7 @@ class CheckApp extends Base { public function __construct( private Checker $checker, + private ?IAppManager $appManager, private AppLocator $appLocator, private FileAccessHelper $fileAccessHelper, ) { @@ -51,7 +53,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int if ($path === '') { $path = $this->appLocator->getAppPath($appid); } - if ($this->fileAccessHelper->file_exists($path . '/appinfo/signature.json')) { + if ($this->appManager->isShipped($appid) || $this->fileAccessHelper->file_exists($path . '/appinfo/signature.json')) { // Only verify if the application explicitly ships a signature.json file $result = $this->checker->verifyAppSignature($appid, $path, true); $this->writeArrayInOutputFormat($input, $output, $result); From 09154c334c3d14e5fcdba109202af0fc4a746a39 Mon Sep 17 00:00:00 2001 From: Seungmin Kim <8457324+ehfd@users.noreply.github.com> Date: Sun, 15 Dec 2024 01:14:56 +0900 Subject: [PATCH 4/6] fix(occ): Modify IAppManager Co-authored-by: Joas Schilling <213943+nickvergessen@users.noreply.github.com> Signed-off-by: Seungmin Kim <8457324+ehfd@users.noreply.github.com> --- core/Command/Integrity/CheckApp.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/Command/Integrity/CheckApp.php b/core/Command/Integrity/CheckApp.php index 403d36b6c8791..c48e699b7a4fe 100644 --- a/core/Command/Integrity/CheckApp.php +++ b/core/Command/Integrity/CheckApp.php @@ -25,7 +25,7 @@ class CheckApp extends Base { public function __construct( private Checker $checker, - private ?IAppManager $appManager, + private IAppManager $appManager, private AppLocator $appLocator, private FileAccessHelper $fileAccessHelper, ) { From a5c25635b3d51ac18554f8e0031f0c2eeba59bfc Mon Sep 17 00:00:00 2001 From: Seungmin Kim <8457324+ehfd@users.noreply.github.com> Date: Sun, 15 Dec 2024 01:25:44 +0900 Subject: [PATCH 5/6] fix(occ): Cosmetic edits Signed-off-by: Seungmin Kim <8457324+ehfd@users.noreply.github.com> --- core/Command/Integrity/CheckApp.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/Command/Integrity/CheckApp.php b/core/Command/Integrity/CheckApp.php index c48e699b7a4fe..fff5752a7b7b3 100644 --- a/core/Command/Integrity/CheckApp.php +++ b/core/Command/Integrity/CheckApp.php @@ -25,9 +25,9 @@ class CheckApp extends Base { public function __construct( private Checker $checker, - private IAppManager $appManager, private AppLocator $appLocator, private FileAccessHelper $fileAccessHelper, + private IAppManager $appManager, ) { parent::__construct(); } From eb77c633ab516912799da823484d8406ee2154d5 Mon Sep 17 00:00:00 2001 From: Seungmin Kim <8457324+ehfd@users.noreply.github.com> Date: Tue, 17 Dec 2024 04:40:44 +0900 Subject: [PATCH 6/6] fix(occ): Revise output condition Co-authored-by: Joas Schilling <213943+nickvergessen@users.noreply.github.com> Signed-off-by: Seungmin Kim <8457324+ehfd@users.noreply.github.com> --- core/Command/Integrity/CheckApp.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/Command/Integrity/CheckApp.php b/core/Command/Integrity/CheckApp.php index fff5752a7b7b3..e1889a35cfe6f 100644 --- a/core/Command/Integrity/CheckApp.php +++ b/core/Command/Integrity/CheckApp.php @@ -63,7 +63,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int } $output->writeln('No errors found', OutputInterface::VERBOSITY_VERBOSE); } else { - $output->writeln('App signature not found, skipping app integrity check', OutputInterface::VERBOSITY_VERBOSE); + $output->writeln('App signature not found, skipping app integrity check'); } return 0; }