Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

sec(http): JSONP should require trusted resource URLs #11623

Closed
wants to merge 1 commit into from

Conversation

chirayuk
Copy link
Contributor

WORK-IN-PROGRESS. Do NOT merge. More work needs to be done and the tests are currently broken.

  • JSONP should require trusted resource URLs. This would be a breaking
    change but maybe not too onerous since same origin URLs are trusted in
    the default config and you can easily whitelist any 3rd party URLs you
    trust in one single place (your app/module config.)
  • fix a bug where $http can't handle $sce wrapper URLs.

Closes #11352
Closes #11328

WORK-IN-PROGRESS.  Do **NOT** merge.  More work needs to be done and the tests are currently broken.

- JSONP should require trusted resource URLs.  This would be a breaking
  change but maybe not too onerous since same origin URLs are trusted in
  the default config and you can easily whitelist any 3rd party URLs you
  trust in one single place (your app/module config.)
- fix a bug where $http can't handle $sce wrapper URLs.

Closes angular#11352
Closes angular#11328
@@ -255,7 +256,22 @@ describe('$httpBackend', function() {
});


describe('JSONP', function() {
[true, false].forEach(function(trustAsResourceUrl) {
Copy link
Member

Choose a reason for hiding this comment

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

It seems like a good place for the they() helper :)

Copy link
Member

Choose a reason for hiding this comment

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

Or maybe not (since it's on the describe level, not the it level)...

@caitp
Copy link
Contributor

caitp commented Apr 17, 2015

are the ng-mock edits enough to not break application tests?

@caitp
Copy link
Contributor

caitp commented Apr 17, 2015

@chirayuk it generally looks good ok, a few nits --- I'll leave it up to you whether you think this can land today or not.

@chirayuk chirayuk modified the milestones: 1.4.0-rc.1, 1.4.0-rc.2 Apr 24, 2015
@petebacondarwin
Copy link
Contributor

@chirayuk - the description says DO NOT MERGE - is this still accurate or are you happy that this is ready to go in now?

@IgorMinar
Copy link
Contributor

can we move this to 1.5?

Also, I don't see an easy way to define the whitelist, do we piggy-back on the existing means to define whitelist or is there no current way to whitelist urls that are ok for jsonp?

@petebacondarwin petebacondarwin modified the milestones: 1.5.x - migration-facilitation, 1.4.0-rc.2 May 5, 2015
@petebacondarwin petebacondarwin modified the milestones: 1.6.x, 1.5.x, 1.6.0 Sep 12, 2016
@@ -1095,7 +1095,7 @@ angular.mock.dump = function(object) {
```
*/
angular.mock.$HttpBackendProvider = function() {
this.$get = ['$rootScope', '$timeout', createHttpBackendMock];
this.$get = ['$sce', '$rootScope', '$timeout', createHttpBackendMock];
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't see why the changes in this file are needed...

expect(function() { $backend.apply(null, args); }).toThrowMinErr(
'$sce', 'insecurl', 'Blocked loading resource from url not allowed by $sceDelegate policy. URL: ' + badUrlPrefix);
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

There is too much work going on here for a test. We should just duplicate what is needed so that we can easily read the tests.

@petebacondarwin
Copy link
Contributor

Closing in favour of #15143 which is a rebased and tidied up version of this.

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.

$http's JSONP should require trusted resource URLs Inconsistent handling of $sce trustedUrl with $http
6 participants