Skip to content

Conversation

@jernst
Copy link
Contributor

@jernst jernst commented Jul 5, 2016

This is to support setups where no reliable DNS entry is available (e.g. mDNS) or for simple-to-setup aliasing (e.g. *.example.com)

This time, I hope, tabs and formatting are all in the right places for your coding standards. We had been doing this patch just for UBOS, but now that you are doing checksums on PHP files, such as private patch leads to warnings in the management console, and I hope it can be merged into the main.

As using a * in a trusted domain is entirely optional, this should have no security implications for the default setup.

If you'd like me to augment some existing tests, I'd appreciate a pointer to which tests.

…re no reliable DNS entry is available (e.g. mDNS) or for simple-to-setup aliasing (e.g. *.example.com)
@mention-bot
Copy link

@jernst, thanks for your PR! By analyzing the annotation information on this pull request, we identified @LukasReschke, @DeepDiver1975 and @MorrisJobke to be potential reviewers


// If a value contains a *, apply glob-style matching. Any second * is ignored.
foreach ($trustedList as $trusted) {
if($trusted == '*') {
Copy link
Member

Choose a reason for hiding this comment

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

===

@LukasReschke
Copy link
Member

LukasReschke commented Jul 5, 2016

That's a lot of code for a very minor feature and it also contains some syntax errors (which the unit tests have spotted!). Can you by any chance make the code smaller by switching to a regex or so?

}
$star = strpos($trusted, '*');
if($star === false) {
next;
Copy link
Member

Choose a reason for hiding this comment

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

Syntax error.

@LukasReschke
Copy link
Member

You can add test entries at

public function trustedDomainDataProvider() {
$trustedHostTestList = [
'host.one.test',
'host.two.test',
'[1fff:0:a88:85a3::ac1f]',
'host.three.test:443',
];
return [
// empty defaults to false with 8.1
[null, 'host.one.test:8080', false],
['', 'host.one.test:8080', false],
[[], 'host.one.test:8080', false],
// trust list when defined
[$trustedHostTestList, 'host.two.test:8080', true],
[$trustedHostTestList, 'host.two.test:9999', true],
[$trustedHostTestList, 'host.three.test:8080', false],
[$trustedHostTestList, 'host.two.test:8080:aa:222', false],
[$trustedHostTestList, '[1fff:0:a88:85a3::ac1f]', true],
[$trustedHostTestList, '[1fff:0:a88:85a3::ac1f]:801', true],
[$trustedHostTestList, '[1fff:0:a88:85a3::ac1f]:801:34', false],
[$trustedHostTestList, 'host.three.test:443', true],
[$trustedHostTestList, 'host.three.test:80', false],
[$trustedHostTestList, 'host.three.test', false],
// trust localhost regardless of trust list
[$trustedHostTestList, 'localhost', true],
[$trustedHostTestList, 'localhost:8080', true],
[$trustedHostTestList, '127.0.0.1', true],
[$trustedHostTestList, '127.0.0.1:8080', true],
// do not trust invalid localhosts
[$trustedHostTestList, 'localhost:1:2', false],
[$trustedHostTestList, 'localhost: evil.host', false],
// do not trust casting
[[1], '1', false],
];
}
and run the tests with cd tests && phpunit lib/Security/TrustedDomainHelperTest.php

@LukasReschke
Copy link
Member

LukasReschke commented Jul 5, 2016

Can you by any chance make the code smaller by switching to a regex or so?

Something like:

[a-zA-Z0-9]+.foo.com

Wheras you replace all stars with [a-zA-Z0-9]+. Should make the code way simpler.

Use === instead of == for extra paranoia.
@jernst
Copy link
Contributor Author

jernst commented Jul 6, 2016

I'll see what I can do to make it shorter tomorrow. Regexes for security checks of domains containing . and patterns containing * are easy to get wrong ...

@MorrisJobke
Copy link
Member

I really would love to see the test cases extended for this: https://github.com/nextcloud/server/blob/master/tests/lib/Security/TrustedDomainHelperTest.php

😉

@MorrisJobke MorrisJobke added 3. to review Waiting for reviews and removed 2. developing Work in progress labels Jul 7, 2016
@MorrisJobke
Copy link
Member

@LukasReschke Please recheck ;)

@LukasReschke
Copy link
Member

Code looks good to me. Thanks a lot 🚀

Can I ask you to add a small note to the config option in config.sample.php that the * symbol has a special meaning? Then this should be good to get in for Nextcloud Next :)

@LukasReschke LukasReschke added this to the Nextcloud Next milestone Jul 7, 2016
@jernst
Copy link
Contributor Author

jernst commented Jul 7, 2016

You mean Next++cloud? :-)

@LukasReschke
Copy link
Member

Thanks a lot for your Pull Request. LGTM! 🚀 ❤️ 🎉

@icewind1991
Copy link
Member

👍

@LukasReschke LukasReschke merged commit 487d150 into nextcloud:master Jul 7, 2016
R0Wi pushed a commit to R0Wi/server that referenced this pull request Nov 22, 2025
…extcloud#314)

Resolves: nextcloud#307

- [x] Allow disable and remove actions if default Deploy daemon is not
available.
- [x] Set ping timeout to 3s

---------

Signed-off-by: Andrey Borysenko <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

3. to review Waiting for reviews enhancement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants