owncloud / files_antivirus

:space_invader: virus scanner for ownCloud
GNU Affero General Public License v3.0
48 stars 30 forks source link

PHP Syntax error when upgrading to files_antivirus 1.2.0 on PHP 7.3 #525

Closed gregoryR closed 1 year ago

gregoryR commented 1 year ago

Steps to reproduce

  1. upgrade files_antivirus from 1.1.0 to 1.2.0

Expected behaviour

app files_antivirus upgrades and owncloud is usable

Actual behaviour

app files_antivirus upgrades but owncloud is not usable. I get 500 errors with "Exception":"ParseError"

The new syntax in lib/ScannerFactory.php line 32 seems requiring php 7.4 ? On Debian 10 the standard php version is 7.3

    protected AppConfig $appConfig;
    protected ILogger $logger;
    protected string $scannerClass;
    protected IL10N $l10N;

I deactivate the files_antivirus app in order to access Owncloud again

Server configuration

Operating system:

"server OS": "Linux",
"server OS version": "Linux vextracloud2 4.19.0-22-amd64 #1 SMP Debian 4.19.260-1 (2022-09-29) x86_64",

Web server:

"webserver version": "Apache\/2.4.38 (Debian)",

Database:

Mysql 5

PHP version:

"PHP Version": "7.3.31-1~deb10u1"

ownCloud version: (see ownCloud admin page)

"ownCloud version": "10.11.0.6",
"ownCloud version string": "10.11.0",
"ownCloud edition": "Community",

Updated from an older ownCloud or fresh install:

Regular updates

Where did you install ownCloud from:

https://owncloud.com/download-server/

Signing status (ownCloud 9.0 and above):

No errors have been found.

The content of config/config.php:

    "config": {
        "maintenance": false,
        "instanceid": "oc309f9eec79",
        "passwordsalt": "***REMOVED SENSITIVE VALUE***",
        "overwritehost": "cloud.ifremer.fr",
        "overwriteprotocol": "https",
        "overwritewebroot": "\/",
        "overwrite.cli.url": "https:\/\/cloud.ifremer.fr\/",
        "default_language": "fr",
        "trusted_domains": [
            "cloud.ifremer.fr"
        ],
        "appstoreenabled": true,
        "datadirectory": "\/home\/cloud\/data",
        "dbtype": "mysql",
        "version": "10.11.0.6",
        "dbname": "owncloud",
        "dbhost": "vmysql1.ifremer.fr",
        "dbtableprefix": "oc_",
        "dbuser": "***REMOVED SENSITIVE VALUE***",
        "dbpassword": "***REMOVED SENSITIVE VALUE***",
        "installed": true,
        "proxy": "134.246.142.38:3128",
        "trusted_proxies": [
            "134.246.142.39"
        ],
        "forwarded_for_headers": [
            "HTTP_X_FORWARDED_FOR",
            "HTTP_FORWARDED_FOR"
        ],
        "ldapIgnoreNamingRules": false,
        "mail_from_address": "***REMOVED SENSITIVE VALUE***",
        "mail_smtpmode": "sendmail",
        "mail_domain": "***REMOVED SENSITIVE VALUE***",
        "mail_smtphost": "***REMOVED SENSITIVE VALUE***",
        "customclient_desktop": "https:\/\/owncloud.com\/desktop-app\/",
        "log_type": "syslog",
        "syslog_tag": "cloud_ifremer_fr",
        "logtimezone": "Europe\/Paris",
        "loglevel": 1,
        "log_rotate_size": 209715200,
        "updatechecker": true,
        "secret": "***REMOVED SENSITIVE VALUE***",
        "theme": "",
        "memcache.local": "\\OC\\Memcache\\APCu",
        "filelocking.enabled": true,
        "memcache.locking": "\\OC\\Memcache\\Redis",
        "redis": {
            "host": "\/var\/run\/redis\/redis-server.sock",
            "port": 0,
            "timeout": 0,
            "password": "***REMOVED SENSITIVE VALUE***"
        },
        "appstore.experimental.enabled": true,
        "trashbin_retention_obligation": "auto",
        "skeletondirectory": "",
        "singleuser": false,
        "strict_login_enforced": true,
        "onlyoffice": {
            "jwt_secret": "***REMOVED SENSITIVE VALUE***",
            "jwt_header": "***REMOVED SENSITIVE VALUE***"
        },
        "files_antivirus.av_cmd_options": "",
        "files_antivirus.av_path": "\/usr\/bin\/clamscan",
        "allow_user_to_change_mail_address": ""
    },

List of activated apps:

root@vextracloud2:/export/home/cloud# sudo -u www-data php occ app:list
Enabled:
  - activity:
    - Version: 2.7.1
    - Path: /export/home/cloud/apps/activity
  - comments:
    - Version: 0.3.0
    - Path: /export/home/cloud/apps/comments
  - configreport:
    - Version: 0.2.1
    - Path: /export/home/cloud/apps/configreport
  - contacts:
    - Version: 1.5.5
    - Path: /export/home/cloud/apps/contacts
  - dav:
    - Version: 0.7.0
    - Path: /export/home/cloud/apps/dav
  - federatedfilesharing:
    - Version: 0.5.0
    - Path: /export/home/cloud/apps/federatedfilesharing
  - federation:
    - Version: 0.1.0
    - Path: /export/home/cloud/apps/federation
  - files:
    - Version: 1.5.2
    - Path: /export/home/cloud/apps/files
  - files_external:
    - Version: 0.9.0
    - Path: /export/home/cloud/apps/files_external
  - files_mediaviewer:
    - Version: 1.0.5
    - Path: /export/home/cloud/apps/files_mediaviewer
  - files_pdfviewer:
    - Version: 1.0.1
    - Path: /export/home/cloud/apps/files_pdfviewer
  - files_sharing:
    - Version: 0.14.0
    - Path: /export/home/cloud/apps/files_sharing
  - files_texteditor:
    - Version: 2.4.1
    - Path: /export/home/cloud/apps/files_texteditor
  - files_trashbin:
    - Version: 0.9.1
    - Path: /export/home/cloud/apps/files_trashbin
  - files_versions:
    - Version: 1.3.0
    - Path: /export/home/cloud/apps/files_versions
  - firstrunwizard:
    - Version: 1.2.0
    - Path: /export/home/cloud/apps/firstrunwizard
  - impersonate:
    - Version: 0.5.2
    - Path: /export/home/cloud/apps/impersonate
  - market:
    - Version: 0.7.0
    - Path: /export/home/cloud/apps/market
  - notifications:
    - Version: 0.5.4
    - Path: /export/home/cloud/apps/notifications
  - onlyoffice:
    - Version: 7.6.7
    - Path: /export/home/cloud/apps/onlyoffice
  - provisioning_api:
    - Version: 0.5.0
    - Path: /export/home/cloud/apps/provisioning_api
  - systemtags:
    - Version: 0.3.0
    - Path: /export/home/cloud/apps/systemtags
  - templateeditor:
    - Version: 0.4.0
    - Path: /export/home/cloud/apps/templateeditor
  - updatenotification:
    - Version: 0.2.1
    - Path: /export/home/cloud/apps/updatenotification
  - user_ldap:
    - Version: 0.16.0
    - Path: /export/home/cloud/apps/user_ldap
Disabled:
  - admin_audit:
    - Path: /export/home/cloud/apps/admin_audit
  - announcementcenter:
    - Path: /export/home/cloud/apps/announcementcenter
  - customgroups:
    - Path: /export/home/cloud/apps/customgroups
  - encryption:
    - Path: /export/home/cloud/apps/encryption
  - enterprise_key:
    - Path: /export/home/cloud/apps/enterprise_key
  - external:
    - Path: /export/home/cloud/apps/external
  - files_antivirus:
    - Path: /export/home/cloud/apps/files_antivirus
  - files_classifier:
    - Path: /export/home/cloud/apps/files_classifier
  - files_external_dropbox:
    - Path: /export/home/cloud/apps/files_external_dropbox
  - files_external_ftp:
    - Path: /export/home/cloud/apps/files_external_ftp
  - files_ldap_home:
    - Path: /export/home/cloud/apps/files_ldap_home
  - files_lifecycle:
    - Path: /export/home/cloud/apps/files_lifecycle
  - firewall:
    - Path: /export/home/cloud/apps/firewall
  - graphapi:
    - Path: /export/home/cloud/apps/graphapi
  - guests:
    - Path: /export/home/cloud/apps/guests
  - metrics:
    - Path: /export/home/cloud/apps/metrics
  - oauth2:
    - Path: /export/home/cloud/apps/oauth2
  - openidconnect:
    - Path: /export/home/cloud/apps/openidconnect
  - password_policy:
    - Path: /export/home/cloud/apps/password_policy
  - ransomware_protection:
    - Path: /export/home/cloud/apps/ransomware_protection
  - sharepoint:
    - Path: /export/home/cloud/apps/sharepoint
  - systemtags_management:
    - Path: /export/home/cloud/apps/systemtags_management
  - theme-enterprise:
    - Path: /export/home/cloud/apps/theme-enterprise
  - user_external:
    - Path: /export/home/cloud/apps/user_external
  - user_shibboleth:
    - Path: /export/home/cloud/apps/user_shibboleth
  - web:
    - Path: /export/home/cloud/apps/web
  - windows_network_drive:
    - Path: /export/home/cloud/apps/windows_network_drive
  - wopi:
    - Path: /export/home/cloud/apps/wopi
  - workflow:
    - Path: /export/home/cloud/apps/workflow

Are you using external storage, if yes which one: no

Are you using encryption: no

Are you using an external user-backend, if yes which one: LDAP

LDAP configuration (delete this part if not used)

Doesn't seems relevant to this issue

Client configuration

Browser: Firefox

Operating system:

Logs

Web server error log

When accessing owncloud after upgrades I get 500 errors in access logs

134.246.142.39 - ***REMOVED SENSITIVE VALUE*** [22/Nov/2022:06:21:01 +0100] "PROPFIND /remote.php/dav/files/***REMOVED SENSITIVE VALUE***/ HTTP/1.1" 500 1157 "-" "Mozilla/5.0 (Linux) mirall/2.11.1 (build 8946) (ownCloud, debian-4.19.0-22-amd64 ClientArchitecture: x86_64 OsArchitecture: x86_64)"
...
134.246.142.39 - - [22/Nov/2022:06:14:29 +0100] "GET /index.php/settings/personal HTTP/1.1" 500 10758 "-" "Mozilla/5.0 (X11; Linux x86_64; rv:107.0) Gecko/20100101 Firefox/107.0"

ownCloud log (data/owncloud.log)

And specific ownloud error

Nov 22 06:14:29 vextracloud2 cloud_ifremer_fr[3974]: [Y3xatUgTJzCDnz4r4wbDogAAAAA][134.246.167.95][***REMOVED SENSITIVE VALUE***][index][GET][/index.php/settings/undefined/img/notifications.svg] Exception: {"Exception":"ParseError","Message":"syntax error, unexpected 'AppConfig' (T_STRING), expecting function (T_FUNCTION) or const (T_CONST)","Code":0,"Trace":"#0 \/export\/home\/cloud\/lib\/composer\/composer\/ClassLoader.php(428): Composer\\Autoload\\includeFile('\/export\/home\/cl...')\n#1 [internal function]: Composer\\Autoload\\ClassLoader->loadClass('OCA\\\\Files_Antiv...')\n#2 \/export\/home\/cloud\/apps\/files_antivirus\/lib\/AppInfo\/Application.php(60): spl_autoload_call('OCA\\\\Files_Antiv...')\n#3 \/export\/home\/cloud\/lib\/composer\/pimple\/pimple\/src\/Pimple\/Container.php(122): OCA\\Files_Antivirus\\AppInfo\\Application->OCA\\Files_Antivirus\\AppInfo\\{closure}(*** sensitive parameters replaced ***)\n#4 \/export\/home\/cloud\/lib\/private\/AppFramework\/Utility\/SimpleContainer.php(108): Pimple\\Container->offsetGet('ScannerFactory')\n#5 \/export\/home\/cloud\/apps\/files_antivirus\/lib\/AppInfo\/Application.php(152): OC\\AppFramework\\Utility\\SimpleContainer->query('ScannerFactory')\n#6 \/export\/home\/cloud\/lib\/private\/Files\/Storage\/StorageFactory.php(100): OCA\\Files_Antivirus\\AppInfo\\Application->OCA\\Files_Antivirus\\AppInfo\\{closure}(*** sensitive parameters replaced ***)\n#7 \/export\/home\/cloud\/lib\/private\/Files\/Storage\/StorageFactory.php(82): OC\\Files\\Storage\\StorageFactory->wrap(Object(OC\\Files\\Mount\\MountPoint), Object(OC\\Files\\Storage\\Wrapper\\Checksum))\n#8 \/export\/home\/cloud\/lib\/private\/Files\/Mount\/MountPoint.php(142): OC\\Files\\Storage\\StorageFactory->getInstance(Object(OC\\Files\\Mount\\MountPoint), '\\\\OC\\\\Files\\\\Stora...', Array)\n#9 \/export\/home\/cloud\/lib\/private\/Files\/Mount\/MountPoint.php(165): OC\\Files\\Mount\\MountPoint->createStorage()\n#10 \/export\/home\/cloud\/lib\/private\/Files\/Filesystem.php(319): OC\\Files\\Mount\\MountPoint->getStorage()\n#11 \/export\/home\/cloud\/lib\/private\/Files\/Filesystem.php(442): OC\\Files\\Filesystem::getStorage('***REMOVED SENSITIVE VALUE***')\n#12 \/export\/home\/cloud\/lib\/private\/Files\/Filesystem.php(374): OC\\Files\\Filesystem::initMountPoints('***REMOVED SENSITIVE VALUE***', true)\n#13 \/export\/home\/cloud\/lib\/private\/legacy\/util.php(316): OC\\Files\\Filesystem::init('***REMOVED SENSITIVE VALUE***', '\/***REMOVED SENSITIVE VALUE***\/files', true)\n#14 \/export\/home\/cloud\/lib\/base.php(913): OC_Util::setupFS()\n#15 \/export\/home\/cloud\/index.php(54): OC::handleRequest()\n#16 {main}","File":"\/export\/home\/cloud\/apps\/files_antivirus\/lib\/ScannerFactory.php","Line":32}
Scarchu commented 1 year ago

I have the exact same problem.

phil-davis commented 1 year ago

I will make a PR to convert all these class variable type declarations to PHPdoc.

https://www.php.net/manual/en/language.oop5.properties.php "As of PHP 7.4.0, property definitions can include Type declarations,..."

That does not work with PHP 7.3, and PHP 7.3 is still supported by the latest ownCloud core 10.11 release.

jnweiger commented 1 year ago

Ouch. Looks like we'll follow up with a 1.2.1 release....

phil-davis commented 1 year ago

Ouch. Looks like we'll follow up with a 1.2.1 release....

Release issue #527 created. That can be worked on after PR #526 has been merged.

phil-davis commented 1 year ago

Note: since we dropped PHP 7.3 in core master, all pipelines in oC10 app CI run with PHP 7.4.

For apps that we release to run on existing oC10 releases 10.11 and before, we need to check that the code released is valid for PHP 7.3. Probably adding a test php-code-style pipeline on PHP 7.3 in CI will be the easiest thing to do so that we have some confidence. I will try that on the various oC10 apps.

jnweiger commented 1 year ago

https://github.com/owncloud/files_antivirus/releases/tag/v1.2.1 was released yesterday to fix this issue. @gregoryR @Scarchu please upgrade to 1.2.1 and see if that makes it work on PHP 7.3 again. If not, please reopen.

gregoryR commented 1 year ago

https://github.com/owncloud/files_antivirus/releases/tag/v1.2.1 was released yesterday to fix this issue. @gregoryR @Scarchu please upgrade to 1.2.1 and see if that makes it work on PHP 7.3 again. If not, please reopen.

Hi, sorry I may not have been clear/visible in https://github.com/owncloud/files_antivirus/pull/526#issuecomment-1324587573

But the new 1.2.1 was proposed by the web UI this morning. Even if the app was deactivated. I have updated the app and activated it

Thanks again for the quick patch !

Scarchu commented 1 year ago

https://github.com/owncloud/files_antivirus/releases/tag/v1.2.1 was released yesterday to fix this issue. @gregoryR @Scarchu please upgrade to 1.2.1 and see if that makes it work on PHP 7.3 again. If not, please reopen.

Yes, everything works perfectly! Thank you!