angular_xss 0.2.3 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
data/README.md
CHANGED
@@ -3,7 +3,7 @@ angular_xss [![Build Status](https://travis-ci.org/makandra/angular_xss.png?bran
|
|
3
3
|
|
4
4
|
When rendering AngularJS templates with a server-side templating engine like ERB or Haml it is easy to introduce XSS vulnerabilities. These vulnerabilities are enabled by AngularJS evaluating user-provided strings containing interpolation symbols (default symbols are `{{` and `}}`).
|
5
5
|
|
6
|
-
This gem patches ERB/rails_xss and Haml so Angular interpolation symbols are auto-escaped in unsafe strings. And by auto-escaped we mean replacing `{{` with `
|
6
|
+
This gem patches ERB/rails_xss and Haml so Angular interpolation symbols are auto-escaped in unsafe strings. And by auto-escaped we mean replacing `{{` with `{{ $root.DOUBLE_LEFT_CURLY_BRACE }}`. To leave AngularJS interpolation marks unescaped, mark the string as `html_safe`.
|
7
7
|
|
8
8
|
**This is an unsatisfactory hack.** A better solution is very much desired, but is not possible without some changes in AngularJS. See the [related AngularJS issue](https://github.com/angular/angular.js/issues/5601).
|
9
9
|
|
@@ -32,9 +32,17 @@ Installation
|
|
32
32
|
|
33
33
|
2. Run `bundle install`.
|
34
34
|
|
35
|
-
3.
|
35
|
+
3. Add this to your Angular code (replacing "myApp" of course):
|
36
36
|
|
37
|
-
|
37
|
+
```
|
38
|
+
angular.module('myApp', []).run(['$rootScope', function($rootScope) {
|
39
|
+
$rootScope.DOUBLE_LEFT_CURLY_BRACE = '{{';
|
40
|
+
}]);
|
41
|
+
```
|
42
|
+
|
43
|
+
4. Run your test suite to find the places that broke.
|
44
|
+
|
45
|
+
5. Mark any string that is allowed to contain Angular expressions as `#html_safe`.
|
38
46
|
|
39
47
|
|
40
48
|
Known limitations
|
data/lib/angular_xss/escaper.rb
CHANGED
data/lib/angular_xss/version.rb
CHANGED
data/spec/rails-2.3/Gemfile.lock
CHANGED
data/spec/rails-3.2/Gemfile.lock
CHANGED
data/spec/rails-4.2/Gemfile.lock
CHANGED
@@ -6,12 +6,12 @@ shared_examples_for 'engine preventing Angular XSS' do
|
|
6
6
|
|
7
7
|
it 'escapes Angular interpolation marks in unsafe strings' do
|
8
8
|
html.should_not include('{{unsafe}}')
|
9
|
-
html.should include('
|
9
|
+
html.should include('{{ $root.DOUBLE_LEFT_CURLY_BRACE }}unsafe}}')
|
10
10
|
end
|
11
11
|
|
12
12
|
it 'recognizes the many ways to express an opening curly brace in HTML' do
|
13
13
|
|
14
|
-
html.should include("
|
14
|
+
html.should include("{{ $root.DOUBLE_LEFT_CURLY_BRACE }}unsafe}}")
|
15
15
|
html.should_not include("{{unsafe}}")
|
16
16
|
|
17
17
|
braces = [
|
@@ -37,7 +37,7 @@ shared_examples_for 'engine preventing Angular XSS' do
|
|
37
37
|
|
38
38
|
it 'does not escape Angular interpolation marks in safe strings' do
|
39
39
|
html.should include("{{safe}}")
|
40
|
-
html.should_not include("
|
40
|
+
html.should_not include("{{ $root.DOUBLE_LEFT_CURLY_BRACE }}safe}}")
|
41
41
|
end
|
42
42
|
|
43
43
|
it 'does not escape Angular interpolation marks in a block where AngularXSS is disabled' do
|
@@ -47,7 +47,7 @@ shared_examples_for 'engine preventing Angular XSS' do
|
|
47
47
|
end
|
48
48
|
|
49
49
|
result.should include('{{unsafe}}')
|
50
|
-
result.should_not include('
|
50
|
+
result.should_not include('{{ $root.DOUBLE_LEFT_CURLY_BRACE }}unsafe}}')
|
51
51
|
end
|
52
52
|
|
53
53
|
it 'does escape Angular interpolation marks after the block where AngularXSS is disabled' do
|
@@ -55,7 +55,7 @@ shared_examples_for 'engine preventing Angular XSS' do
|
|
55
55
|
end
|
56
56
|
result = html
|
57
57
|
|
58
|
-
result.should include('
|
58
|
+
result.should include('{{ $root.DOUBLE_LEFT_CURLY_BRACE }}unsafe}}')
|
59
59
|
result.should_not include('{{unsafe}}')
|
60
60
|
end
|
61
61
|
|
@@ -68,7 +68,7 @@ shared_examples_for 'engine preventing Angular XSS' do
|
|
68
68
|
end
|
69
69
|
}.should raise_error(SomeException)
|
70
70
|
|
71
|
-
html.should include('
|
71
|
+
html.should include('{{ $root.DOUBLE_LEFT_CURLY_BRACE }}unsafe}}')
|
72
72
|
html.should_not include('{{unsafe}}')
|
73
73
|
end
|
74
74
|
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: angular_xss
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 19
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
|
-
- 2
|
9
8
|
- 3
|
10
|
-
|
9
|
+
- 0
|
10
|
+
version: 0.3.0
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Henning Koch
|
@@ -15,8 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date:
|
19
|
-
default_executable:
|
18
|
+
date: 2017-07-31 00:00:00 Z
|
20
19
|
dependencies:
|
21
20
|
- !ruby/object:Gem::Dependency
|
22
21
|
name: activesupport
|
@@ -138,7 +137,6 @@ files:
|
|
138
137
|
- spec/shared/tests/erb_spec.rb
|
139
138
|
- spec/shared/tests/haml_spec.rb
|
140
139
|
- spec/shared/tests/safe_buffer_spec.rb
|
141
|
-
has_rdoc: true
|
142
140
|
homepage: https://github.com/makandra/angular_xss
|
143
141
|
licenses:
|
144
142
|
- MIT
|
@@ -168,7 +166,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
168
166
|
requirements: []
|
169
167
|
|
170
168
|
rubyforge_project:
|
171
|
-
rubygems_version: 1.
|
169
|
+
rubygems_version: 1.8.30
|
172
170
|
signing_key:
|
173
171
|
specification_version: 3
|
174
172
|
summary: Patches rails_xss and Haml so AngularJS interpolations are auto-escaped in unsafe strings.
|
@@ -241,3 +239,4 @@ test_files:
|
|
241
239
|
- spec/shared/tests/erb_spec.rb
|
242
240
|
- spec/shared/tests/haml_spec.rb
|
243
241
|
- spec/shared/tests/safe_buffer_spec.rb
|
242
|
+
has_rdoc:
|