PluginProbe
HTTP Headers / 1.14.2
HTTP Headers v1.14.2
1.19.5 trunk 1.0.0 1.1.0 1.1.1 1.1.2 1.10.0 1.10.1 1.10.2 1.10.3 1.10.4 1.10.5 1.11.0 1.12.0 1.12.1 1.12.2 1.13.0 1.13.1 1.13.2 1.13.3 1.13.4 1.14.0 1.14.1 1.14.2 1.15.0 All 60 releases
http-headers / views / content-security-policy.php

content-security-policy.php in HTTP Headers 1.14.2, at views/content-security-policy.php

112 lines 3.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 if (!defined('ABSPATH')) {
3 exit;
4 }
5 $content_security_policy = get_option('hh_content_security_policy', 0);
6 ?>
7 <tr valign="top">
8 <th scope="row">Content Security Policy
9 <p class="description"><?php _e('Content Security Policy (CSP) is an added layer of security that helps to detect and mitigate certain types of attacks, including Cross Site Scripting (XSS) and data injection attacks. These attacks are used for everything from data theft to site defacement or distribution of malware.', 'http-headers'); ?></p>
10
11 <p>
12 <label><input type="checkbox" class="http-header-value"
13 name="hh_content_security_policy_report_only" value="1"
14 <?php checked(get_option('hh_content_security_policy_report_only'), 1, true); ?>
15 <?php echo $content_security_policy == 1 ? NULL : ' readonly'; ?> /> "Report-Only" (<?php _e('for reporting-only purposes', 'http-headers'); ?>)</label>
16 </p>
17 <hr>
18 <p class="description">Useful tools:</p>
19 <p class="description">
20 <a target="_blank" href="https://zinoui.com/tools/sri-generator">SRI Hash Generator</a>
21 - generates subresource integrity hashes using a cryptographic algorithm.
22 </p>
23 <p class="description">
24 <a target="_blank" href="https://zinoui.com/tools/csp-hash">CSP Hash Generator</a>
25 - generates CSP hashes to use in script-src and style-src directives.
26 </p>
27 </th>
28 <td>
29 <fieldset>
30 <legend class="screen-reader-text">Content-Security-Policy</legend>
31 <?php
32 foreach ($bools as $k => $v)
33 {
34 ?><p><label><input type="radio" class="http-header" name="hh_content_security_policy" value="<?php echo $k; ?>"<?php checked($content_security_policy, $k, true); ?> /> <?php echo $v; ?></label></p><?php
35 }
36 ?>
37 </fieldset>
38 </td>
39 <td>
40 <?php settings_fields( 'http-headers-csp' ); ?>
41 <?php do_settings_sections( 'http-headers-csp' ); ?>
42 <table>
43 <tbody>
44 <tr>
45 <td><strong><?php _e('Directive', 'http-headers'); ?></strong></td>
46 <td><strong><?php _e('Value', 'http-headers'); ?></strong></td>
47 </tr>
48 <?php
49 $directives = array(
50 'default-src',
51 'script-src',
52 'style-src',
53 'img-src',
54 'connect-src',
55 'font-src',
56 'media-src',
57 'report-uri',
58 'child-src',
59 'form-action',
60 'frame-ancestors',
61 'object-src',
62 'frame-src',
63 'worker-src',
64 'manifest-src',
65 'base-uri',
66 'plugin-types',
67 'report-to',
68 'sandbox',
69 'require-sri-for',
70 'block-all-mixed-content',
71 'upgrade-insecure-requests',
72 );
73 $csp_value = get_option('hh_content_security_policy_value');
74 foreach ($directives as $item)
75 {
76 ?>
77 <tr>
78 <td><?php echo $item; ?></td>
79 <td>
80 <?php
81
82 if ($item == 'sandbox')
83 {
84 include 'includes/csp-sandbox.inc.php';
85
86 } elseif (in_array($item, array('block-all-mixed-content', 'upgrade-insecure-requests'))) {
87
88 include 'includes/csp-inc.inc.php';
89
90 } elseif (in_array($item, array('report-to', 'plugin-types'))) {
91
92 include 'includes/csp-text.inc.php';
93
94 } elseif ($item == 'require-sri-for') {
95
96 include 'includes/csp-sri.inc.php';
97
98 } else {
99
100 include 'includes/csp-src.inc.php';
101
102 }
103 ?>
104 </td>
105 </tr>
106 <?php
107 }
108 ?>
109 </tbody>
110 </table>
111 </td>
112 </tr>