-
Notifications
You must be signed in to change notification settings - Fork 62
OTWO-7715 CSP misconfigured — unsafe-inline, unsafe-eval, overly broa… #1945
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
Open
Niharika1117
wants to merge
2
commits into
staging
Choose a base branch
from
OTWO-7715
base: staging
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 6 additions & 5 deletions
11
app/views/layouts/tracking_scripts/_google_analytics.html.haml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,7 @@ | ||
| %script{async: "", src: "https://www.googletagmanager.com/gtag/js?id=G-6NX4NYJ2SJ"} | ||
| :javascript | ||
| window.dataLayer = window.dataLayer || []; | ||
| function gtag(){dataLayer.push(arguments);} | ||
| gtag('js', new Date()); | ||
| gtag('config', 'G-6NX4NYJ2SJ'); | ||
| %script{ nonce: content_security_policy_nonce } | ||
| :plain | ||
| window.dataLayer = window.dataLayer || []; | ||
| function gtag(){dataLayer.push(arguments);} | ||
| gtag('js', new Date()); | ||
| gtag('config', 'G-6NX4NYJ2SJ'); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,63 +1,64 @@ | ||
| :javascript | ||
| function number_with_delimiter(n) { | ||
| var d = ","; | ||
| n = n.toString(); | ||
| %script{ nonce: content_security_policy_nonce } | ||
| :plain | ||
| function number_with_delimiter(n) { | ||
| var d = ","; | ||
| n = n.toString(); | ||
|
|
||
| if (n.length > 3) { | ||
| var mod = n.length % 3; | ||
| var output = (mod > 0 ? (n.substring(0,mod)) : ""); | ||
| for (i=0 ; i < Math.floor(n.length / 3); i++) { | ||
| if ((mod == 0) && (i == 0)) | ||
| output += n.substring(mod+ 3 * i, mod + 3 * i + 3); | ||
| else | ||
| output+= d + n.substring(mod + 3 * i, mod + 3 * i + 3); | ||
| if (n.length > 3) { | ||
| var mod = n.length % 3; | ||
| var output = (mod > 0 ? (n.substring(0,mod)) : ""); | ||
| for (i=0 ; i < Math.floor(n.length / 3); i++) { | ||
| if ((mod == 0) && (i == 0)) | ||
| output += n.substring(mod+ 3 * i, mod + 3 * i + 3); | ||
| else | ||
| output+= d + n.substring(mod + 3 * i, mod + 3 * i + 3); | ||
| } | ||
| return output; | ||
| } | ||
| else { | ||
| return n; | ||
| } | ||
| return output; | ||
| } | ||
| else { | ||
| return n; | ||
| } | ||
| } | ||
|
|
||
| function calc_man_years(loc) { | ||
| var a_term = 2.4; | ||
| var b_term = 1.05; | ||
| var months = a_term * Math.pow(loc/1000.0, b_term); | ||
| return months/12; | ||
| } | ||
| function calc_man_years(loc) { | ||
| var a_term = 2.4; | ||
| var b_term = 1.05; | ||
| var months = a_term * Math.pow(loc/1000.0, b_term); | ||
| return months/12; | ||
| } | ||
|
|
||
| function loc_from_index(i) { | ||
| var cocomo_loc = document.getElementById("cocomo_loc_dropdown"); | ||
| return parseInt(cocomo_loc.options[i].value); | ||
| } | ||
| function loc_from_index(i) { | ||
| var cocomo_loc = document.getElementById("cocomo_loc_dropdown"); | ||
| return parseInt(cocomo_loc.options[i].value); | ||
| } | ||
|
|
||
| function update_cocomo() { | ||
| var cocomo_loc = document.getElementById("cocomo_loc_dropdown"); | ||
| var man_years = 0; | ||
| var loc_markup = loc_from_index(1); | ||
| var loc_code = loc_from_index(2); | ||
| var loc = 0; | ||
| function update_cocomo() { | ||
| var cocomo_loc = document.getElementById("cocomo_loc_dropdown"); | ||
| var man_years = 0; | ||
| var loc_markup = loc_from_index(1); | ||
| var loc_code = loc_from_index(2); | ||
| var loc = 0; | ||
|
|
||
| switch(cocomo_loc.selectedIndex) { | ||
| case 0: | ||
| loc = loc_markup + loc_code; | ||
| man_years = calc_man_years(loc_markup) + calc_man_years(loc_code); | ||
| break; | ||
| case 1: | ||
| loc = loc_markup; | ||
| man_years = calc_man_years(loc); | ||
| break; | ||
| case 2: | ||
| loc = loc_code; | ||
| man_years = calc_man_years(loc); | ||
| break; | ||
| } | ||
| switch(cocomo_loc.selectedIndex) { | ||
| case 0: | ||
| loc = loc_markup + loc_code; | ||
| man_years = calc_man_years(loc_markup) + calc_man_years(loc_code); | ||
| break; | ||
| case 1: | ||
| loc = loc_markup; | ||
| man_years = calc_man_years(loc); | ||
| break; | ||
| case 2: | ||
| loc = loc_code; | ||
| man_years = calc_man_years(loc); | ||
| break; | ||
| } | ||
|
|
||
| salary = parseFloat(document.getElementById("cocomo_salary").value); | ||
| final_cost = man_years * salary; | ||
| if (isNaN(final_cost)) final_cost = 0; | ||
| salary = parseFloat(document.getElementById("cocomo_salary").value); | ||
| final_cost = man_years * salary; | ||
| if (isNaN(final_cost)) final_cost = 0; | ||
|
|
||
| document.getElementById("cocomo_years").innerHTML = number_with_delimiter(Math.round(man_years)); | ||
| document.getElementById("cocomo_loc").innerHTML = number_with_delimiter(Math.round(loc)); | ||
| document.getElementById("cocomo_value").innerHTML = number_with_delimiter(Math.round(final_cost)); | ||
| } | ||
| document.getElementById("cocomo_years").innerHTML = number_with_delimiter(Math.round(man_years)); | ||
| document.getElementById("cocomo_loc").innerHTML = number_with_delimiter(Math.round(loc)); | ||
| document.getElementById("cocomo_value").innerHTML = number_with_delimiter(Math.round(final_cost)); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,29 +1,31 @@ | ||
| :ruby | ||
| background = '-webkit-gradient(linear, left top, right bottom, color-stop(0%, #828181), '\ | ||
| 'color-stop(55%, #A4A3A3), color-stop(130%, #828181))' | ||
| :javascript | ||
| function mouseOverForUsers(parent) { | ||
| var elem = parent.getElementsByClassName('used_link')[0]; | ||
| elem.style.background = '#ffffff'; | ||
| elem.style.backgroundColor = '#ffffff'; | ||
| elem.style.color = '#000000'; | ||
| } | ||
| js = <<~JS | ||
| function mouseOverForUsers(parent) { | ||
| var elem = parent.getElementsByClassName('used_link')[0]; | ||
| elem.style.background = '#ffffff'; | ||
| elem.style.backgroundColor = '#ffffff'; | ||
| elem.style.color = '#000000'; | ||
| } | ||
|
|
||
| function mouseOutForUsers(parent) { | ||
| var elem = parent.getElementsByClassName('used_link')[0]; | ||
| elem.style.color = '#ffffff'; | ||
| elem.style.background = '#828181'; | ||
| elem.style.background = 'linear-gradient(to right, #828181, #A4A3A3, #828181)'; | ||
| elem.style.background = '#{background}'; | ||
| elem.style.backgroundColor = '#828181'; | ||
| } | ||
| function mouseOutForUsers(parent) { | ||
| var elem = parent.getElementsByClassName('used_link')[0]; | ||
| elem.style.color = '#ffffff'; | ||
| elem.style.background = '#828181'; | ||
| elem.style.background = 'linear-gradient(to right, #828181, #A4A3A3, #828181)'; | ||
| elem.style.background = '#{background}'; | ||
| elem.style.backgroundColor = '#828181'; | ||
| } | ||
|
|
||
| function mouseOverForUsersWithoutStyle(parent) { | ||
| parent.getElementsByClassName('non_css_used_link')[0].style.color = '#000'; | ||
| parent.getElementsByClassName('non_css_used_link')[0].style.fontWeight = 'bold'; | ||
| } | ||
| function mouseOverForUsersWithoutStyle(parent) { | ||
| parent.getElementsByClassName('non_css_used_link')[0].style.color = '#000'; | ||
| parent.getElementsByClassName('non_css_used_link')[0].style.fontWeight = 'bold'; | ||
| } | ||
|
|
||
| function mouseOutForUsersWithoutStyle(parent) { | ||
| parent.getElementsByClassName('non_css_used_link')[0].style.color = '#5F6062'; | ||
| parent.getElementsByClassName('non_css_used_link')[0].style.fontWeight = 'normal'; | ||
| } | ||
| function mouseOutForUsersWithoutStyle(parent) { | ||
| parent.getElementsByClassName('non_css_used_link')[0].style.color = '#5F6062'; | ||
| parent.getElementsByClassName('non_css_used_link')[0].style.fontWeight = 'normal'; | ||
| } | ||
| JS | ||
| = javascript_tag js, nonce: true |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,10 +1,11 @@ | ||
| :javascript | ||
| function usersLogoMouseOver(elem){ | ||
| elem.style.background='#A5A3A5'; | ||
| elem.style.color='#ffffff'; | ||
| } | ||
| %script{ nonce: content_security_policy_nonce } | ||
| :plain | ||
| function usersLogoMouseOver(elem){ | ||
| elem.style.background='#A5A3A5'; | ||
| elem.style.color='#ffffff'; | ||
| } | ||
|
|
||
| function usersLogoMouseOut(elem){ | ||
| elem.style.background='none transparent'; | ||
| elem.style.color='#000000'; | ||
| } | ||
| function usersLogoMouseOut(elem){ | ||
| elem.style.background='none transparent'; | ||
| elem.style.color='#000000'; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,13 +1,20 @@ | ||
| # frozen_string_literal: true | ||
|
|
||
| allowed_script_sources = %w[www.google.com www.gstatic.com maps.googleapis.com maps.gstatic.com s7.addthis.com | ||
| cdnjs.cloudflare.com] | ||
| allowed_script_sources = %w[https://www.google.com https://www.gstatic.com https://maps.googleapis.com | ||
| https://maps.gstatic.com https://s7.addthis.com https://cdnjs.cloudflare.com | ||
| https://www.googletagmanager.com] | ||
|
|
||
| Rails.application.config.content_security_policy do |policy| | ||
| policy.default_src :self, :https | ||
| policy.connect_src :self, :https, 'maps.googleapis.com' | ||
| policy.font_src :self, :https, :data | ||
| policy.img_src :self, :https, :data | ||
| policy.object_src :none | ||
| policy.script_src :self, :https, :unsafe_inline, :unsafe_eval, *allowed_script_sources | ||
| policy.script_src :self, *allowed_script_sources | ||
| policy.style_src :self, :https, :unsafe_inline | ||
| policy.base_uri :self | ||
| policy.form_action :self | ||
| end | ||
|
|
||
| Rails.application.config.content_security_policy_nonce_generator = ->(_request) { SecureRandom.base64(16) } | ||
| Rails.application.config.content_security_policy_nonce_directives = %w[script-src] | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.