Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(occ): occ integrity:check-app and Admin panel "rescan" deliver inconsistent results #49577

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

ehfd
Copy link

@ehfd ehfd commented Dec 1, 2024

Summary

This issue fixes the behavior discrepancy between the occ integrity:check-app command and the Admin panel "rescan" button.
The fix allows occ integrity:check-app to gracefully skip the signature check of the app instead of throwing an exception, as instructed in #17801 (comment).

TODO

  • Independent validation by a reviewer. Check the below custom_apps apps (open the dropdown) that do not ship with signatures. bookmarks is a good example (Add signature to app bookmarks#1941).
Technical information
=====================
The following list covers which files have failed the integrity check. Please read
the previous linked documentation to learn more about the errors and how to fix
them.

Results
=======
- apporder
	- EXCEPTION
		- OC\IntegrityCheck\Exceptions\InvalidSignatureException
		- Signature data not found.
- bookmarks
	- EXCEPTION
		- OC\IntegrityCheck\Exceptions\InvalidSignatureException
		- Signature data not found.
- bruteforcesettings
	- EXCEPTION
		- OC\IntegrityCheck\Exceptions\InvalidSignatureException
		- Signature data not found.
- calendar
	- EXCEPTION
		- OC\IntegrityCheck\Exceptions\InvalidSignatureException
		- Signature data not found.
- drawio
	- EXCEPTION
		- OC\IntegrityCheck\Exceptions\InvalidSignatureException
		- Signature data not found.
- event_update_notification
	- EXCEPTION
		- OC\IntegrityCheck\Exceptions\InvalidSignatureException
		- Signature data not found.
- impersonate
	- EXCEPTION
		- OC\IntegrityCheck\Exceptions\InvalidSignatureException
		- Signature data not found.
- metadata
	- EXCEPTION
		- OC\IntegrityCheck\Exceptions\InvalidSignatureException
		- Signature data not found.
- previewgenerator
	- EXCEPTION
		- OC\IntegrityCheck\Exceptions\InvalidSignatureException
		- Signature data not found.
- twofactor_admin
	- EXCEPTION
		- OC\IntegrityCheck\Exceptions\InvalidSignatureException
		- Signature data not found.
- twofactor_totp
	- EXCEPTION
		- OC\IntegrityCheck\Exceptions\InvalidSignatureException
		- Signature data not found.
- twofactor_u2f
	- EXCEPTION
		- OC\IntegrityCheck\Exceptions\InvalidSignatureException
		- Signature data not found.

Raw output
==========
Array
(
    [apporder] => Array
        (
            [EXCEPTION] => Array
                (
                    [class] => OC\IntegrityCheck\Exceptions\InvalidSignatureException
                    [message] => Signature data not found.
                )

        )

    [bookmarks] => Array
        (
            [EXCEPTION] => Array
                (
                    [class] => OC\IntegrityCheck\Exceptions\InvalidSignatureException
                    [message] => Signature data not found.
                )

        )

    [bruteforcesettings] => Array
        (
            [EXCEPTION] => Array
                (
                    [class] => OC\IntegrityCheck\Exceptions\InvalidSignatureException
                    [message] => Signature data not found.
                )

        )

    [calendar] => Array
        (
            [EXCEPTION] => Array
                (
                    [class] => OC\IntegrityCheck\Exceptions\InvalidSignatureException
                    [message] => Signature data not found.
                )

        )

    [drawio] => Array
        (
            [EXCEPTION] => Array
                (
                    [class] => OC\IntegrityCheck\Exceptions\InvalidSignatureException
                    [message] => Signature data not found.
                )

        )

    [event_update_notification] => Array
        (
            [EXCEPTION] => Array
                (
                    [class] => OC\IntegrityCheck\Exceptions\InvalidSignatureException
                    [message] => Signature data not found.
                )

        )

    [impersonate] => Array
        (
            [EXCEPTION] => Array
                (
                    [class] => OC\IntegrityCheck\Exceptions\InvalidSignatureException
                    [message] => Signature data not found.
                )

        )

    [metadata] => Array
        (
            [EXCEPTION] => Array
                (
                    [class] => OC\IntegrityCheck\Exceptions\InvalidSignatureException
                    [message] => Signature data not found.
                )

        )

    [previewgenerator] => Array
        (
            [EXCEPTION] => Array
                (
                    [class] => OC\IntegrityCheck\Exceptions\InvalidSignatureException
                    [message] => Signature data not found.
                )

        )

    [twofactor_admin] => Array
        (
            [EXCEPTION] => Array
                (
                    [class] => OC\IntegrityCheck\Exceptions\InvalidSignatureException
                    [message] => Signature data not found.
                )

        )

    [twofactor_totp] => Array
        (
            [EXCEPTION] => Array
                (
                    [class] => OC\IntegrityCheck\Exceptions\InvalidSignatureException
                    [message] => Signature data not found.
                )

        )

    [twofactor_u2f] => Array
        (
            [EXCEPTION] => Array
                (
                    [class] => OC\IntegrityCheck\Exceptions\InvalidSignatureException
                    [message] => Signature data not found.
                )

        )

)
  • Identify unit testing requirements.

Checklist

  • Code is properly formatted - Correct if workflow passes
  • Sign-off message is added to all commits - Done
  • Tests (unit, integration, api and/or acceptance) are included
  • Screenshots before/after for front-end changes - Not applicable
  • Documentation (manuals or wiki) has been updated or is not required - Not required
  • Backports requested where applicable (ex: critical bugfixes) - Not required because this is annoying but not critical, but may be nonetheless preferred, based on reviewer discretion

CC @joshtrichards @simonspa @szaimen

@ehfd ehfd changed the title Fix occ integrity:check-app and Admin panel "rescan" deliver inconsistent results fix: occ integrity:check-app and Admin panel "rescan" deliver inconsistent results Dec 4, 2024
@ehfd ehfd changed the title fix: occ integrity:check-app and Admin panel "rescan" deliver inconsistent results fix(occ): occ integrity:check-app and Admin panel "rescan" deliver inconsistent results Dec 6, 2024
@ehfd
Copy link
Author

ehfd commented Dec 8, 2024

No labels, nothing? @joshtrichards @simonspa @szaimen

Copy link
Member

@joshtrichards joshtrichards left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the only thing missing that I see (for parity) is an isShipped() check (shipped apps are always verified; if they're missing a signature file something is wrong so we still want to throw an exception for those). Looks reasonable otherwise.

// If an application is shipped a valid signature is required
$isShipped = $this->appManager->isShipped($appId);
$appNeedsToBeChecked = false;
if ($isShipped) {
$appNeedsToBeChecked = true;
} elseif ($this->fileAccessHelper->file_exists($this->appLocator->getAppPath($appId) . '/appinfo/signature.json')) {
// Otherwise only if the application explicitly ships a signature.json file
$appNeedsToBeChecked = true;
}
if ($appNeedsToBeChecked) {
$this->verifyAppSignature($appId);
}

I'm mildly tempted to add another return/exit code (3 maybe) so that automated runners can easily detect if things only passed due to a missing signature file, but that opens a can of worms we should probably avoid right now (i.e. auditing the return codes we use across our occ commands; adding one arbitrarily right now just creates later tech debt... so probably easier to add that code later when/if deemed important I guess).

@joshtrichards
Copy link
Member

Hi @ehfd - Thanks for the ping and PR. And sorry for the delay.

@joshtrichards
Copy link
Member

Identify unit testing requirements.

Hmm. I don't currently see any test coverage for the integrity command namespace themselves:

https://github.com/nextcloud/server/tree/f5f9691f387473982bff7d9788fe3350979e7cbc/tests/Core/Command

Might be a good opportunity to add some. :)

We do have test coverage for the underlying IntegrityCheck\Checker itself however at least.

ehfd added 3 commits December 14, 2024 19:14
…istent results

Signed-off-by: Seungmin Kim <8457324+ehfd@users.noreply.github.com>
Signed-off-by: Seungmin Kim <8457324+ehfd@users.noreply.github.com>
Signed-off-by: Seungmin Kim <8457324+ehfd@users.noreply.github.com>
@ehfd
Copy link
Author

ehfd commented Dec 14, 2024

#49577 (review)
@joshtrichards
Requested changes are implemented in 2314a2f.
I agree that returning a new exit code should be something for the future.

As for the tests, feel free to modify the branch. Otherwise, new issue and PR for the tests in order to not bloat the PR.

ehfd and others added 2 commits December 15, 2024 01:14
Co-authored-by: Joas Schilling <213943+nickvergessen@users.noreply.github.com>
Signed-off-by: Seungmin Kim <8457324+ehfd@users.noreply.github.com>
Signed-off-by: Seungmin Kim <8457324+ehfd@users.noreply.github.com>
Copy link
Contributor

Hello there,
Thank you so much for taking the time and effort to create a pull request to our Nextcloud project.

We hope that the review process is going smooth and is helpful for you. We want to ensure your pull request is reviewed to your satisfaction. If you have a moment, our community management team would very much appreciate your feedback on your experience with this PR review process.

Your feedback is valuable to us as we continuously strive to improve our community developer experience. Please take a moment to complete our short survey by clicking on the following link: https://cloud.nextcloud.com/apps/forms/s/i9Ago4EQRZ7TWxjfmeEpPkf6

Thank you for contributing to Nextcloud and we hope to hear from you soon!

(If you believe you should not receive this message, you can add yourself to the blocklist.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

occ integrity:check-app and Admin panel "rescan" deliver inconsistent results
4 participants