nextcloud / cms_pico

🗃 Integrate Pico CMS and let your users manage their own websites
https://apps.nextcloud.com/apps/cms_pico
GNU Affero General Public License v3.0
134 stars 41 forks source link

Missing signature causing issue in NC 25 #234

Closed atkulp closed 1 year ago

atkulp commented 1 year ago

I saw a few issues relating to compatibility issues between cms_pico and NC 25. I'm not sure if any of it has been resolved, but the error that I see is that every hit returns a 500 and the nextcloud.log file shows "No such file or directory" when trying to verify /var/www/html/custom_apps/cms_pico/appinfo/signature.json. Is this expected at this stage?

PhrozenByte commented 1 year ago

Can't reproduce this. Did you somehow (don't know whether this is even possible) force enabled code signing? If yes, disable it. We've never shipped a signature.json and AFAIK code signing still is optional in Nextcloud. In fact, right now we can't even enable code signing, because we'd require a way to whitelist our appdata_public folder, something that AFAIK isn't possible with Nextcloud right now.

atkulp commented 1 year ago

Maybe the signature error is a red herring. Here's what it actually shows:

{
    "reqId": "joLiwU33P0kwJbdvCcMo",
    "level": 3,
    "time": "2023-01-08T04:52:35+00:00",
    "remoteAddr": "",
    "user": "--",
    "app": "PHP",
    "method": "",
    "url": "--",
    "message": "file_get_contents(/var/www/html/custom_apps/cms_pico/appinfo/signature.json): Failed to open stream: No such file or directory at /var/www/html/lib/private/IntegrityCheck/Helpers/FileAccessHelper.php#44",
    "userAgent": "--",
    "version": "25.0.2.3",
    "exception": {
        "Exception": "Error",
        "Message": "file_get_contents(/var/www/html/custom_apps/cms_pico/appinfo/signature.json): Failed to open stream: No such file or directory at /var/www/html/lib/private/IntegrityCheck/Helpers/FileAccessHelper.php#44",
        "Code": 0,
        "Trace": [
            {
                "function": "onError",
                "class": "OC\\Log\\ErrorHandler",
                "type": "::",
                "args": [
                    2,
                    "file_get_contents(/var/www/html/custom_apps/cms_pico/appinfo/signature.json): Failed to open stream: No such file or directory",
                    "/var/www/html/lib/private/IntegrityCheck/Helpers/FileAccessHelper.php",
                    44
                ]
            },
            {
                "file": "/var/www/html/lib/private/IntegrityCheck/Helpers/FileAccessHelper.php",
                "line": 44,
                "function": "file_get_contents",
                "args": [
                    "/var/www/html/custom_apps/cms_pico/appinfo/signature.json"
                ]
            },
            {
                "file": "/var/www/html/lib/private/IntegrityCheck/Checker.php",
                "line": 330,
                "function": "file_get_contents",
                "class": "OC\\IntegrityCheck\\Helpers\\FileAccessHelper",
                "type": "->",
                "args": [
                    "/var/www/html/custom_apps/cms_pico/appinfo/signature.json"
                ]
            },
            {
                "file": "/var/www/html/lib/private/IntegrityCheck/Checker.php",
                "line": 521,
                "function": "verify",
                "class": "OC\\IntegrityCheck\\Checker",
                "type": "->",
                "args": [
                    "/var/www/html/custom_apps/cms_pico/appinfo/signature.json",
                    "/var/www/html/custom_apps/cms_pico",
                    "cms_pico",
                    true
                ]
            },
            {
                "file": "/var/www/html/core/Command/Integrity/CheckApp.php",
                "line": 68,
                "function": "verifyAppSignature",
                "class": "OC\\IntegrityCheck\\Checker",
                "type": "->",
                "args": [
                    "cms_pico",
                    "/var/www/html/custom_apps/cms_pico",
                    true
                ]
            },
            {
                "file": "/var/www/html/3rdparty/symfony/console/Command/Command.php",
                "line": 255,
                "function": "execute",
                "class": "OC\\Core\\Command\\Integrity\\CheckApp",
                "type": "->",
                "args": [
                    {
                        "__class__": "Symfony\\Component\\Console\\Input\\ArgvInput"
                    },
                    {
                        "__class__": "Symfony\\Component\\Console\\Output\\ConsoleOutput"
                    }
                ]
            },
            {
                "file": "/var/www/html/core/Command/Base.php",
                "line": 177,
                "function": "run",
                "class": "Symfony\\Component\\Console\\Command\\Command",
                "type": "->",
                "args": [
                    {
                        "__class__": "Symfony\\Component\\Console\\Input\\ArgvInput"
                    },
                    {
                        "__class__": "Symfony\\Component\\Console\\Output\\ConsoleOutput"
                    }
                ]
            },
            {
                "file": "/var/www/html/3rdparty/symfony/console/Application.php",
                "line": 1009,
                "function": "run",
                "class": "OC\\Core\\Command\\Base",
                "type": "->",
                "args": [
                    {
                        "__class__": "Symfony\\Component\\Console\\Input\\ArgvInput"
                    },
                    {
                        "__class__": "Symfony\\Component\\Console\\Output\\ConsoleOutput"
                    }
                ]
            },
            {
                "file": "/var/www/html/3rdparty/symfony/console/Application.php",
                "line": 273,
                "function": "doRunCommand",
                "class": "Symfony\\Component\\Console\\Application",
                "type": "->",
                "args": [
                    {
                        "__class__": "OC\\Core\\Command\\Integrity\\CheckApp"
                    },
                    {
                        "__class__": "Symfony\\Component\\Console\\Input\\ArgvInput"
                    },
                    {
                        "__class__": "Symfony\\Component\\Console\\Output\\ConsoleOutput"
                    }
                ]
            },
            {
                "file": "/var/www/html/3rdparty/symfony/console/Application.php",
                "line": 149,
                "function": "doRun",
                "class": "Symfony\\Component\\Console\\Application",
                "type": "->",
                "args": [
                    {
                        "__class__": "Symfony\\Component\\Console\\Input\\ArgvInput"
                    },
                    {
                        "__class__": "Symfony\\Component\\Console\\Output\\ConsoleOutput"
                    }
                ]
            },
            {
                "file": "/var/www/html/lib/private/Console/Application.php",
                "line": 213,
                "function": "run",
                "class": "Symfony\\Component\\Console\\Application",
                "type": "->",
                "args": [
                    {
                        "__class__": "Symfony\\Component\\Console\\Input\\ArgvInput"
                    },
                    {
                        "__class__": "Symfony\\Component\\Console\\Output\\ConsoleOutput"
                    }
                ]
            },
            {
                "file": "/var/www/html/console.php",
                "line": 100,
                "function": "run",
                "class": "OC\\Console\\Application",
                "type": "->",
                "args": []
            },
            {
                "file": "/var/www/html/occ",
                "line": 11,
                "args": [
                    "/var/www/html/console.php"
                ],
                "function": "require_once"
            }
        ],
        "File": "/var/www/html/lib/private/Log/ErrorHandler.php",
        "Line": 92,
        "CustomMessage": "--"
    }
}

I'm also seeing some memory allocation errors which could be the real culprit. No matter how high I put the memory limit for PHP, it always runs out of memory in the ExceptionHandler.

NOTICE: PHP message: PHP Fatal error:  Allowed memory size of 2147483648 bytes exhausted (tried to allocate 20480 bytes) in /var/www/htm   │
│   l/lib/private/Log/ExceptionSerializer.php on line 220  

I keep raising the limit, and it's always just a little bit more. It only triggers when I hit my cms_pico blog instance though. Just in case the issue was with my markdown, I even created a new default template site, but that gives the same result.

atkulp commented 1 year ago

Oof. I did the bad hack and changed PHP_MEMORY_LIMIT to -1 to see what happened. It consumed over 20GB of ram before bringing down the server. This doesn't happen until I hit a blog page. What else can I look at?

image
PhrozenByte commented 1 year ago

The memory limit issue is caused by a known bug in Nextcloud. It only appears if a exception is logged though (the issue is caused by a bug in Nextcloud's exception serializer), i.e. the request failed anyway. See https://github.com/nextcloud/server/issues/23429 (and multiple linked issues there). You don't need to raise the memory limit.

According to the stack trace you're trying to run the code check manually. As said, cms_pico doesn't support code signing due to Nextclouds limitations. occ should probably rather show a proper error message instead of just throwing an exception; you might want to report this bug in nextcloud/server.

atkulp commented 1 year ago

Good to know about the memory issue. As for the code check, I can trigger it with the code integrity commands, but what I'm seeing is when I try to go to the https://host.com/apps/cms_pico/pico/site link.

I just added the config setting 'integrity.check.disabled' => true and it allowed it to proceed. Now I'm getting errors relating to the PicoImageProcessor plugin. Since I don't think has anything to do with you, we can close this now I think.

github-actions[bot] commented 1 year ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed in two days if no further activity occurs. Thank you for your contributions! :+1: