diff options
author | Ismaël Bouya <ismael.bouya@normalesup.org> | 2023-10-04 01:35:06 +0200 |
---|---|---|
committer | Ismaël Bouya <ismael.bouya@normalesup.org> | 2023-10-04 02:11:48 +0200 |
commit | 1a64deeb894dc95e2645a75771732c6cc53a79ad (patch) | |
tree | 1b9df4838f894577a09b9b260151756272efeb53 /modules/private/websites/tools/tools/landing/report_csp_violation.php | |
parent | fa25ffd4583cc362075cd5e1b4130f33306103f0 (diff) | |
download | Nix-1a64deeb894dc95e2645a75771732c6cc53a79ad.tar.gz Nix-1a64deeb894dc95e2645a75771732c6cc53a79ad.tar.zst Nix-1a64deeb894dc95e2645a75771732c6cc53a79ad.zip |
Squash changes containing private information
There were a lot of changes since the previous commit, but a lot of them
contained personnal information about users. All thos changes got
stashed into a single commit (history is kept in a different place) and
private information was moved in a separate private repository
Diffstat (limited to 'modules/private/websites/tools/tools/landing/report_csp_violation.php')
-rw-r--r-- | modules/private/websites/tools/tools/landing/report_csp_violation.php | 22 |
1 files changed, 0 insertions, 22 deletions
diff --git a/modules/private/websites/tools/tools/landing/report_csp_violation.php b/modules/private/websites/tools/tools/landing/report_csp_violation.php deleted file mode 100644 index 30140b2..0000000 --- a/modules/private/websites/tools/tools/landing/report_csp_violation.php +++ /dev/null | |||
@@ -1,22 +0,0 @@ | |||
1 | <?php | ||
2 | http_response_code(204); | ||
3 | |||
4 | $dbconn = pg_connect(getenv("CSP_REPORT_URI")) or die(); | ||
5 | |||
6 | function _get(&$var, $default=null) { | ||
7 | return isset($var) ? $var : $default; | ||
8 | } | ||
9 | |||
10 | $json_data = file_get_contents('php://input'); | ||
11 | if ($json_data = json_decode($json_data, true)) { | ||
12 | $report = _get($json_data["csp-report"], Array()); | ||
13 | $blocked_uri = _get($report["blocked-uri"], ""); | ||
14 | $document_uri = _get($report["document-uri"], ""); | ||
15 | $original_policy = _get($report["original-policy"], ""); | ||
16 | $referrer = _get($report["referrer"], ""); | ||
17 | $violated_directive = _get($report["violated-directive"], ""); | ||
18 | |||
19 | $query = pg_prepare($dbconn, "insert_query", 'INSERT INTO csp_reports (blocked_uri, document_uri, original_policy, referrer, violated_directive, total_count, last) VALUES ($1, $2, $3, $4, $5, 1, NOW()) ON CONFLICT ON CONSTRAINT csp_report_unique DO UPDATE SET total_count = csp_reports.total_count + 1, last = NOW(), referrer = EXCLUDED.referrer, original_policy = EXCLUDED.original_policy'); | ||
20 | |||
21 | pg_execute($dbconn, "insert_query", Array($blocked_uri, $document_uri, $original_policy, $referrer, $violated_directive)); | ||
22 | } | ||