@@ -908,21 +908,21 @@ system("/bin/echo","hello; rm *")
908
908
` Kernel#open ` executes OS command if the argument starts with a vertical bar (` | ` ).
909
909
910
910
``` ruby
911
- open (' | ls' ) { |f | f .read }
911
+ open (' | ls' ) { |file | file .read }
912
912
# returns file list as a String via `ls` command
913
913
```
914
914
915
915
Countermeasures are to use ` File.open ` , ` IO.open ` or ` URI#open ` instead. They don't execute an OS command.
916
916
917
917
``` ruby
918
- File .open (' | ls' ) { |f | f .read }
918
+ File .open (' | ls' ) { |file | file .read }
919
919
# doesn't execute `ls` command, just opens `| ls` file if it exists
920
920
921
- IO .open (0 ) { |f | f .read }
921
+ IO .open (0 ) { |file | file .read }
922
922
# opens stdin. doesn't accept a String as the argument
923
923
924
924
require ' open-uri'
925
- URI (' https://example.com' ).open { |f | f .read }
925
+ URI (' https://example.com' ).open { |file | file .read }
926
926
# opens the URI. `URI()` doesn't accept `| ls`
927
927
```
928
928
@@ -1098,22 +1098,22 @@ Example controller overrides:
1098
1098
``` ruby
1099
1099
# Override policy inline
1100
1100
class PostsController < ApplicationController
1101
- content_security_policy do |p |
1102
- p .upgrade_insecure_requests true
1101
+ content_security_policy do |policy |
1102
+ policy .upgrade_insecure_requests true
1103
1103
end
1104
1104
end
1105
1105
1106
1106
# Using literal values
1107
1107
class PostsController < ApplicationController
1108
- content_security_policy do |p |
1109
- p .base_uri " https://www.example.com"
1108
+ content_security_policy do |policy |
1109
+ policy .base_uri " https://www.example.com"
1110
1110
end
1111
1111
end
1112
1112
1113
1113
# Using mixed static and dynamic values
1114
1114
class PostsController < ApplicationController
1115
- content_security_policy do |p |
1116
- p .base_uri :self , -> { " https://#{ current_user.domain } .example.com" }
1115
+ content_security_policy do |policy |
1116
+ policy .base_uri :self , -> { " https://#{ current_user.domain } .example.com" }
1117
1117
end
1118
1118
end
1119
1119
0 commit comments