mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-29 21:57:18 +00:00
LibWeb/CSP: Implement the report-to directive
This doesn't do anything by itself, the report a violation algorithm will handle this directive itself.
This commit is contained in:
parent
ed0230bb93
commit
855e17529c
Notes:
github-actions[bot]
2025-08-07 17:26:50 +00:00
Author: https://github.com/Lubrsi
Commit: 855e17529c
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/5765
5 changed files with 49 additions and 0 deletions
|
@ -60,6 +60,7 @@ set(SOURCES
|
||||||
ContentSecurityPolicy/Directives/MediaSourceDirective.cpp
|
ContentSecurityPolicy/Directives/MediaSourceDirective.cpp
|
||||||
ContentSecurityPolicy/Directives/Names.cpp
|
ContentSecurityPolicy/Directives/Names.cpp
|
||||||
ContentSecurityPolicy/Directives/ObjectSourceDirective.cpp
|
ContentSecurityPolicy/Directives/ObjectSourceDirective.cpp
|
||||||
|
ContentSecurityPolicy/Directives/ReportToDirective.cpp
|
||||||
ContentSecurityPolicy/Directives/ReportUriDirective.cpp
|
ContentSecurityPolicy/Directives/ReportUriDirective.cpp
|
||||||
ContentSecurityPolicy/Directives/ScriptSourceAttributeDirective.cpp
|
ContentSecurityPolicy/Directives/ScriptSourceAttributeDirective.cpp
|
||||||
ContentSecurityPolicy/Directives/ScriptSourceDirective.cpp
|
ContentSecurityPolicy/Directives/ScriptSourceDirective.cpp
|
||||||
|
|
|
@ -20,6 +20,7 @@
|
||||||
#include <LibWeb/ContentSecurityPolicy/Directives/MediaSourceDirective.h>
|
#include <LibWeb/ContentSecurityPolicy/Directives/MediaSourceDirective.h>
|
||||||
#include <LibWeb/ContentSecurityPolicy/Directives/Names.h>
|
#include <LibWeb/ContentSecurityPolicy/Directives/Names.h>
|
||||||
#include <LibWeb/ContentSecurityPolicy/Directives/ObjectSourceDirective.h>
|
#include <LibWeb/ContentSecurityPolicy/Directives/ObjectSourceDirective.h>
|
||||||
|
#include <LibWeb/ContentSecurityPolicy/Directives/ReportToDirective.h>
|
||||||
#include <LibWeb/ContentSecurityPolicy/Directives/ReportUriDirective.h>
|
#include <LibWeb/ContentSecurityPolicy/Directives/ReportUriDirective.h>
|
||||||
#include <LibWeb/ContentSecurityPolicy/Directives/ScriptSourceAttributeDirective.h>
|
#include <LibWeb/ContentSecurityPolicy/Directives/ScriptSourceAttributeDirective.h>
|
||||||
#include <LibWeb/ContentSecurityPolicy/Directives/ScriptSourceDirective.h>
|
#include <LibWeb/ContentSecurityPolicy/Directives/ScriptSourceDirective.h>
|
||||||
|
@ -69,6 +70,9 @@ GC::Ref<Directive> create_directive(GC::Heap& heap, String name, Vector<String>
|
||||||
if (name == Names::ObjectSrc)
|
if (name == Names::ObjectSrc)
|
||||||
return heap.allocate<ObjectSourceDirective>(move(name), move(value));
|
return heap.allocate<ObjectSourceDirective>(move(name), move(value));
|
||||||
|
|
||||||
|
if (name == Names::ReportTo)
|
||||||
|
return heap.allocate<ReportToDirective>(move(name), move(value));
|
||||||
|
|
||||||
if (name == Names::ReportUri)
|
if (name == Names::ReportUri)
|
||||||
return heap.allocate<ReportUriDirective>(move(name), move(value));
|
return heap.allocate<ReportUriDirective>(move(name), move(value));
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,18 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2024, Luke Wilde <luke@ladybird.org>
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: BSD-2-Clause
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <LibWeb/ContentSecurityPolicy/Directives/ReportToDirective.h>
|
||||||
|
|
||||||
|
namespace Web::ContentSecurityPolicy::Directives {
|
||||||
|
|
||||||
|
GC_DEFINE_ALLOCATOR(ReportToDirective);
|
||||||
|
|
||||||
|
ReportToDirective::ReportToDirective(String name, Vector<String> value)
|
||||||
|
: Directive(move(name), move(value))
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,25 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2024, Luke Wilde <luke@ladybird.org>
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: BSD-2-Clause
|
||||||
|
*/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <LibWeb/ContentSecurityPolicy/Directives/Directive.h>
|
||||||
|
|
||||||
|
namespace Web::ContentSecurityPolicy::Directives {
|
||||||
|
|
||||||
|
// https://w3c.github.io/webappsec-csp/#directive-report-to
|
||||||
|
class ReportToDirective final : public Directive {
|
||||||
|
GC_CELL(ReportToDirective, Directive)
|
||||||
|
GC_DECLARE_ALLOCATOR(ReportToDirective);
|
||||||
|
|
||||||
|
public:
|
||||||
|
virtual ~ReportToDirective() = default;
|
||||||
|
|
||||||
|
private:
|
||||||
|
ReportToDirective(String name, Vector<String> value);
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
|
@ -149,6 +149,7 @@ class ImageSourceDirective;
|
||||||
class ManifestSourceDirective;
|
class ManifestSourceDirective;
|
||||||
class MediaSourceDirective;
|
class MediaSourceDirective;
|
||||||
class ObjectSourceDirective;
|
class ObjectSourceDirective;
|
||||||
|
class ReportToDirective;
|
||||||
class ReportUriDirective;
|
class ReportUriDirective;
|
||||||
class ScriptSourceAttributeDirective;
|
class ScriptSourceAttributeDirective;
|
||||||
class ScriptSourceDirective;
|
class ScriptSourceDirective;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue