Skip to content
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

Enable content security policy by default #1031

Merged
merged 39 commits into from Jul 14, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
0f5346c
lightwindow.js: use about:blank instead of javascript:false
candrews Nov 24, 2020
e977532
resizable_tables.js: don't use innerHTML
candrews Nov 24, 2020
25b6a6b
RUM Injector: don't use inline script to run BOOMR.init
candrews Nov 24, 2020
efcc55b
Only run PROBLEMATIC_ATTRIBUTE_READING check if IE
candrews Nov 24, 2020
f838f8e
Eliminate all inline script and styles
candrews Nov 24, 2020
ca49860
Remove no longer used methods
candrews Nov 24, 2020
641bd2f
Add a configuration option for CSP header (enabled by default)
candrews Nov 24, 2020
4ec6a83
In the database reports, fix the dropdown that selects the report
candrews Jan 31, 2021
6b0e459
Don't showHide twice
candrews Jan 31, 2021
323aff9
Don't allow floating elements on either side of .chapterTitle
candrews Jan 31, 2021
d82da83
In HtmlMBeansReport, move inline CSS to .css file
candrews Mar 10, 2021
434af40
Fix HtmlReport.toHtml to call the correct htmlCoreReport.toHtml overload
candrews Mar 12, 2021
a08a099
Fix typo in '.alertAndRedirect' handler resulting in alerts not working
candrews Mar 12, 2021
f75a0a1
Remove redundant alertDialogAndRedirect - use alertAndRedirect
candrews Mar 12, 2021
a11f31b
Reset "part" portion of URL when doing alertAndRedirect
candrews Mar 12, 2021
637a161
Load request graphs on hover, not on page load
candrews Mar 12, 2021
7623fae
Handle single ' and double " quotes when HTML encoding
candrews Mar 31, 2021
6ebefff
Alert the message for required messages
candrews Mar 31, 2021
5cb4e2a
Add DOCTYPE and required js to the collector page
candrews Mar 31, 2021
d232d2c
Fix required message for appName and appUrls html form fields
candrews Mar 31, 2021
b201bb5
Use prototype's $ function to wrap dom elements
candrews Mar 31, 2021
3dfbb80
Have Collector Server service resources
candrews Mar 31, 2021
a5b35f1
CollectorController.showAlertAndRedirectTo should return a full, vali…
candrews Mar 31, 2021
e2f01f2
Fix single and double quote HTML escaping
candrews Apr 7, 2021
ae11ef3
Merge branch 'master' into content-security-policy
evernat Apr 14, 2021
daa8d3d
Merge branch 'master' into content-security-policy
evernat Apr 14, 2021
b7190c6
remove duplicate
evernat Apr 14, 2021
cd82307
remove duplicate
evernat Apr 14, 2021
249af8a
Merge branch 'master' into content-security-policy
evernat Apr 14, 2021
7b4a48f
accents
evernat Apr 14, 2021
5657ee3
Merge branch 'master' into content-security-policy
evernat May 8, 2021
7ec62bf
Merge branch 'master' into content-security-policy
evernat Jul 8, 2021
782f36f
Merge branch 'master' into content-security-policy
evernat Jul 8, 2021
cf21410
refactoring
evernat Jul 9, 2021
a1c3847
Merge branch 'master' into content-security-policy
evernat Jul 12, 2021
c9af3d7
fix merge
evernat Jul 12, 2021
494925a
Merge branch 'master' into content-security-policy
evernat Jul 14, 2021
4d32683
clean-up
evernat Jul 14, 2021
64995d8
refactoring
evernat Jul 14, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -211,6 +211,11 @@ public enum Parameter {
*/
X_FRAME_OPTIONS("x-frame-options"),

/**
* Parameter to enable or disable the Content Security Policy header (true by default).
*/
CONTENT_SECURITY_POLICY_ENABLED("content-security-policy-enabled"),

/**
* Expression régulière (null par défaut) pour restreindre l'accès au monitoring à certaines adresses IP.
*/
Expand Down
Expand Up @@ -65,6 +65,8 @@
*/
public class HtmlController {
static final String HTML_BODY_FORMAT = "htmlbody";
private static final boolean CONTENT_SECURITY_POLICY_ENABLED = Parameter.CONTENT_SECURITY_POLICY_ENABLED
.getValue() == null || Parameter.CONTENT_SECURITY_POLICY_ENABLED.getValueAsBoolean();
private static final String X_FRAME_OPTIONS = Parameter.X_FRAME_OPTIONS.getValue();
private static final RequestToMethodMapper<HtmlController> REQUEST_TO_METHOD_MAPPER = new RequestToMethodMapper<>(
HtmlController.class);
Expand Down Expand Up @@ -120,6 +122,14 @@ static boolean isLocalCollectNeeded(String part) {

public static BufferedWriter getWriter(HttpServletResponse httpResponse) throws IOException {
httpResponse.setContentType("text/html; charset=UTF-8");
if (CONTENT_SECURITY_POLICY_ENABLED) {
final String analyticsId = Parameter.ANALYTICS_ID.getValue();
final boolean analyticsEnabled = analyticsId != null && !"disabled".equals(analyticsId);
httpResponse.setHeader("Content-Security-Policy",
"default-src 'self'"
+ (analyticsEnabled ? " https://ssl.google-analytics.com" : "")
+ "; object-src 'none';");
}
if (X_FRAME_OPTIONS == null) {
// default value of X-Frame-Options is SAMEORIGIN
httpResponse.setHeader("X-Frame-Options", "SAMEORIGIN");
Expand Down