nextcloud / server

☁️ Nextcloud server, a safe home for all your data
https://nextcloud.com
GNU Affero General Public License v3.0
27.38k stars 4.07k forks source link

`occ files:scan` not honoring output format #27030

Open tgoeg opened 3 years ago

tgoeg commented 3 years ago

Steps to reproduce

1.occ files:scan --output=json_pretty -- user

{"reqId":"UPIugY3Zgb2Oo5c0EFiw","level":1,"time":"2021-05-19T10:20:31+00:00","remoteAddr":"","user":"--","app":"admin_audit","method":"","url":"--","message":"Console command executed: files:scan --output=json_pretty -- user","userAgent":"--","version":"19.0.8.1"}
Unknown user 1 user
+---------+-------+--------------+
| Folders | Files | Elapsed time |
+---------+-------+--------------+
| 0       | 0     | 00:00:00     |
+---------+-------+--------------+

occ files:scan --output=json -- user

{"reqId":"71yPn7HwMRty0OuhXFXH","level":1,"time":"2021-05-19T10:20:40+00:00","remoteAddr":"","user":"--","app":"admin_audit","method":"","url":"--","message":"Console command executed: files:scan --output=json -- user","userAgent":"--","version":"19.0.8.1"}
Unknown user 1 user
+---------+-------+--------------+
| Folders | Files | Elapsed time |
+---------+-------+--------------+
| 0       | 0     | 00:00:00     |
+---------+-------+--------------+

occ files:scan --output=plain -- user

{"reqId":"7SR7CkmnEtTrcZXtfYFX","level":1,"time":"2021-05-19T10:20:46+00:00","remoteAddr":"","user":"--","app":"admin_audit","method":"","url":"--","message":"Console command executed: files:scan --output=plain -- user","userAgent":"--","version":"19.0.8.1"}
Unknown user 1 user
+---------+-------+--------------+
| Folders | Files | Elapsed time |
+---------+-------+--------------+
| 0       | 0     | 00:00:00     |
+---------+-------+--------------+

Expected behaviour

The output format should actually change. In conjunction with #27029 this makes parsing for errors even harder.

Server configuration

Nextcloud version: 19.0.8.1

szaimen commented 3 years ago

Is this Issue still valid in NC21.0.3? If not, please close this issue. Thanks! :)

ghost commented 3 years ago

This issue has been automatically marked as stale because it has not had recent activity and seems to be missing some essential information. It will be closed if no further activity occurs. Thank you for your contributions.

tgoeg commented 3 years ago

Sorry for the delay - had to update OS to be able to update NC as well. Yes, I can confirm it is the same on NC 21.0.3 No matter which output format I choose, the output stays the same.

szaimen commented 1 year ago

Hi, please update to 24.0.9 or better 25.0.3 and report back if it fixes the issue. Thank you!

My goal is to add a label like e.g. 25-feedback to this ticket of an up-to-date major Nextcloud version where the bug could be reproduced. However this is not going to work without your help. So thanks for all your effort!

If you don't manage to reproduce the issue in time and the issue gets closed but you can reproduce the issue afterwards, feel free to create a new bug report with up-to-date information by following this link: https://github.com/nextcloud/server/issues/new?assignees=&labels=bug%2C0.+Needs+triage&template=BUG_REPORT.yml&title=%5BBug%5D%3A+

tgoeg commented 1 year ago

Is this supposed to have changed? It has not, at least not here.

$ occ files:scan --output=json_pretty -- user
{"reqId":"wbhEdGGGGwpSqUszxRHD","level":1,"time":"2023-01-25T16:17:27+00:00","remoteAddr":"","user":"--","app":"admin_audit","method":"","url":"--","message":"Console command executed: files:scan --output=json_pretty -- user","userAgent":"--","version":"25.0.3.2","data":{"app":"admin_audit"}}
Starting scan for user 1 out of 1 (user)
+---------+-------+--------------+
| Folders | Files | Elapsed time |
+---------+-------+--------------+
| 95      | 467   | 00:00:01     |
+---------+-------+--------------+
$ occ files:scan --output=json -- user
{"reqId":"bn9e1KUPB7RYC5CKtkSA","level":1,"time":"2023-01-25T16:17:40+00:00","remoteAddr":"","user":"--","app":"admin_audit","method":"","url":"--","message":"Console command executed: files:scan --output=json -- user","userAgent":"--","version":"25.0.3.2","data":{"app":"admin_audit"}}
Starting scan for user 1 out of 1 (user)
+---------+-------+--------------+
| Folders | Files | Elapsed time |
+---------+-------+--------------+
| 95      | 467   | 00:00:00     |
+---------+-------+--------------+
$ occ files:scan --output=plain -- user
{"reqId":"Cn25tbdhF3km9T0EgQxf","level":1,"time":"2023-01-25T16:17:49+00:00","remoteAddr":"","user":"--","app":"admin_audit","method":"","url":"--","message":"Console command executed: files:scan --output=plain -- user","userAgent":"--","version":"25.0.3.2","data":{"app":"admin_audit"}}
Starting scan for user 1 out of 1 (user)
+---------+-------+--------------+
| Folders | Files | Elapsed time |
+---------+-------+--------------+
| 95      | 467   | 00:00:00     |
+---------+-------+--------------+
$ occ --version
{"reqId":"oBXu3ACXs8YyEIjGhgpY","level":1,"time":"2023-01-25T16:20:43+00:00","remoteAddr":"","user":"--","app":"admin_audit","method":"","url":"--","message":"Console command executed: --version","userAgent":"--","version":"25.0.3.2","data":{"app":"admin_audit"}}
Nextcloud Instance 25.0.3
joshtrichards commented 1 year ago

Can you please provide your config.php? Simply using admin_audit should not generate that additional runtime output for occ. I don't experience that.

As for the output format...

It's simply not yet implemented for the occ files subcommands:

https://github.com/nextcloud/server/blob/333ab4de68706205c955ca82f1e58d80a7c6d8c3/apps/files/lib/Command/Scan.php#L82

The only reason the option is valid is because it's inherited from the Base class:

https://github.com/nextcloud/server/blob/333ab4de68706205c955ca82f1e58d80a7c6d8c3/core/Command/Base.php

If someone wants to implement it, they can model after one that does support it like here (or many others):

https://github.com/nextcloud/server/blob/master/core/Command/Background/ListCommand.php#L70

tgoeg commented 1 year ago

There you go:

$ occ config:list system
{"reqId":"dX5goeRILv84DQJk1HCG","level":1,"time":"2023-11-07T09:23:03+00:00","remoteAddr":"","user":"--","app":"admin_audit","method":"","url":"--","message":"Console command executed: config:list system","userAgent":"--","version":"27.1.3.2","data":{"app":"admin_audit"}}
{
    "system": {
        "config_is_read_only": true,
        "instanceid": "***REMOVED SENSITIVE VALUE***",
        "passwordsalt": "***REMOVED SENSITIVE VALUE***",
        "secret": "***REMOVED SENSITIVE VALUE***",
        "trusted_domains": [
            "my.domain.com"
        ],
        "datadirectory": "***REMOVED SENSITIVE VALUE***",
        "overwrite.cli.url": "https:\/\/my.domain.com",
        "dbtype": "mysql",
        "version": "27.1.3.2",
        "dbname": "***REMOVED SENSITIVE VALUE***",
        "dbhost": "***REMOVED SENSITIVE VALUE***",
        "dbport": "",
        "dbtableprefix": "oc_",
        "mysql.utf8mb4": false,
        "dbuser": "***REMOVED SENSITIVE VALUE***",
        "dbpassword": "***REMOVED SENSITIVE VALUE***",
        "installed": true,
        "memcache.local": "\\OC\\Memcache\\APCu",
        "filelocking.enabled": "true",
        "memcache.locking": "\\OC\\Memcache\\Redis",
        "memcache.distributed": "\\OC\\Memcache\\Redis",
        "redis": {
            "host": "***REMOVED SENSITIVE VALUE***",
            "port": 4444,
            "timeout": 0
        },
        "mail_from_address": "***REMOVED SENSITIVE VALUE***",
        "mail_smtpmode": "smtp",
        "mail_smtpauthtype": "LOGIN",
        "mail_domain": "***REMOVED SENSITIVE VALUE***",
        "ldapIgnoreNamingRules": false,
        "ldapProviderFactory": "\\OCA\\User_LDAP\\LDAPProviderFactory",
        "log_type": "file",
        "log_rotate_size": 10000000,
        "loglevel": 0,
        "logfile": "\/path\/to\/nextcloud-data\/nextcloud.log",
        "logfilemode": 0600,
        "log.condition": {
            "apps": [
                "admin_audit"
            ]
        },
        "log_type_audit": "file",
        "log_rotate_size_audit": 10000000,
        "logfile_audit": "\/path\/to\/nextcloud-data\/audit.log",
        "logfilemode_audit": 0600,
        "mail_smtphost": "***REMOVED SENSITIVE VALUE***",
        "mail_smtpport": "25",
        "maintenance": false,
        "updater.release.channel": "stable",
        "trashbin_retention_obligation": "auto, 14",
        "mail_sendmailmode": "smtp",
        "app_install_overwrite": [
            "impersonate",
            "spreed",
            "files_accesscontrol",
            "quota_warning",
            "richdocuments"
        ],
        "encryption.key_storage_migrated": false,
        "defaultapp": "files",
        "data-fingerprint": "12345678901234568790123456789012"
    }
}

This issue is related to #31172