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

Restrict autoloaded paths to loaded apps (and other enhancements) #18839

Merged
merged 3 commits into from
Sep 6, 2015

Conversation

RobinMcCorkell
Copy link
Member

Unloaded apps (aka not enabled apps) will not get any files autoloaded anymore, which can prevent an unloaded app becoming an attack vector if it is not regularly updated.

In addition, the autoloader will properly resolve symlinked app directories, to allow for a semi-common usecase where apps are stored elsewhere but are symlinked into the ownCloud directory. Fixes issues as noted in #18396 (comment)

@fossxplorer want to test this out with your symlinked apps?

cc @icewind1991 @MorrisJobke @PVince81 @LukasReschke

Robin McCorkell added 2 commits September 5, 2015 00:04
@LukasReschke
Copy link
Member

That's cool 👍

@RobinMcCorkell
Copy link
Member Author

Oh, I've inadvertently fixed some other bugs too 🚀

Fixes #18224, fixes #18317, fixes #18836, fixes #18305, fixes #18296, fixes #18322, fixes #18329, fixes #18333, ........ (yes, I included the issues that were marked as duplicates of the original one, simply to show the impact of the bug).

The line that fixes all those bugs is the move of self::$loadedApps[] = $app; from loadApps() to loadApp(). Give me a second to prepare backport PRs, assuming that's wanted @karlitschek ?

@karlitschek
Copy link
Contributor

nice 👍 please backport

@icewind1991
Copy link
Contributor

Looks goods 👍

@RobinMcCorkell
Copy link
Member Author

CI hasn't run the full autotest suite, so I'm not merging just yet...

Background jobs are tolerant of stale entries left by disabled apps,
which will cause an autoload exception.
@scrutinizer-notifier
Copy link

A new inspection was created.

@RobinMcCorkell
Copy link
Member Author

The latest commit makes the autoloader throw a unique exception class, which the background job runner catches to prevent stale jobs breaking things.

@MorrisJobke
Copy link
Contributor

The line that fixes all those bugs is the move of self::$loadedApps[] = $app; from loadApps() to loadApp(). Give me a second to prepare backport PRs, assuming that's wanted @karlitschek ?

Correct. Because loadApp is also called during app upgrade 🙈

@MorrisJobke
Copy link
Contributor

Code looks good, fixes my issue and CI runs fine locally 👍

MorrisJobke added a commit that referenced this pull request Sep 6, 2015
Restrict autoloaded paths to loaded apps (and other enhancements)
@MorrisJobke MorrisJobke merged commit c57595b into master Sep 6, 2015
@MorrisJobke MorrisJobke deleted the autoloader-supersecure branch September 6, 2015 22:09
@oparoz
Copy link
Contributor

oparoz commented Sep 6, 2015

@Xenopathic - Last time I tried, loading the app did not work. At least it didn't bring routes up, but I'll try again to see if it solves this one.

@RobinMcCorkell
Copy link
Member Author

@nickvergessen when you see this on Monday, before you get too excited and revert immediately, I will be sending out a mailing list email to clarify the updated requirements, as soon as we find an appropriate solution with @oparoz

@oparoz
Copy link
Contributor

oparoz commented Sep 6, 2015

I can confirm that loading the app in the boostrap still does nothing. I suspect a bug in the loader, unless someone can show me an app which loads (1. load the app 2. check the navigation menu).

But adding this to the boostrap fixes the issue: OC::$loader->addValidRoot('../');

It just doesn't make sense to have to whitelist the app being tested, but it's better than hundreds of failing tests ;).

@oparoz
Copy link
Contributor

oparoz commented Sep 6, 2015

Apart from the problems, I do applaud the move to protect the system from dormant apps 👏

@RobinMcCorkell
Copy link
Member Author

@oparoz Well, for unit tests that line will work just fine, but you realise it doesn't work as expected? All paths are relative to the OC::$SERVERROOT, so you basically just disabled the autoloader verification for everything 😆

@oparoz
Copy link
Contributor

oparoz commented Sep 6, 2015

Arf, yes... Missing __DIR__

@oparoz
Copy link
Contributor

oparoz commented Sep 7, 2015

LoadApp() works, but there is a problem with loadApps() #18863

@nickvergessen
Copy link
Contributor

@nickvergessen when you see this on Monday, before you get too excited and revert immediately, I will be sending out a mailing list email to clarify the updated requirements, as soon as we find an appropriate solution with @oparoz

Sorry @Xenopathic but this is 💩
Leaving developers with a known broken system. Please notify people in advance. This really makes developing an app a pain. Third breakage in 5 days on the same part. Please take more time on your fixes and test them, before merging them. All apps are publicly available on github. Check them out and run their unit tests locally, so you see what's the problem and stop messing it up.

So the now required code for the bootstrap.php is:

\OC::$loader->addValidRoot(OC::$SERVERROOT . '/tests');
\OC_App::loadApp('<app name here>');

@RobinMcCorkell
Copy link
Member Author

@nickvergessen Actually, I was wondering why we only load a minimal set of apps in bootstrap.php: https://github.com/owncloud/core/blob/master/tests/bootstrap.php#L14-L15. We should be loading all enabled apps, which would prevent these issues?

@nickvergessen
Copy link
Contributor

@RobinMcCorkell
Copy link
Member Author

OK, so the consensus is that we should explicitly require that the app (and any dependencies of that app) are loaded with OC_App::loadApp() before unit tests are run?

@oparoz
Copy link
Contributor

oparoz commented Sep 7, 2015

@Xenopathic - The boostrap still works when I remove \OC::$loader->addValidRoot(OC::$SERVERROOT . '/tests');. Is that intended?

@MorrisJobke
Copy link
Contributor

@Xenopathic - The boostrap still works when I remove \OC::$loader->addValidRoot(OC::$SERVERROOT . '/tests');. Is that intended?

Yep. The root is added on appLoad()

@oparoz
Copy link
Contributor

oparoz commented Sep 7, 2015

@MorrisJobke - OK, there may be a bug then:
owncloud-archive/mail#1058 (comment)

@oparoz
Copy link
Contributor

oparoz commented Sep 9, 2015

@MorrisJobke - In Gallery, addValidRoot is also still required, even with loadApps();
Keep that in mind for the dev documentation.

MorrisJobke added a commit that referenced this pull request Apr 11, 2016
* same as #18839 for legacy jobs
* avoids spamming the log with useless entries
DeepDiver1975 pushed a commit that referenced this pull request Apr 11, 2016
* same as #18839 for legacy jobs
* avoids spamming the log with useless entries
MorrisJobke added a commit that referenced this pull request Apr 12, 2016
* same as #18839 for legacy jobs
* avoids spamming the log with useless entries
@lock lock bot locked as resolved and limited conversation to collaborators Aug 10, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants