From 7919fe943bec66e670d8b3f3c7bba86b11350dab Mon Sep 17 00:00:00 2001 From: Mathieu Barnachon Date: Tue, 3 Mar 2020 16:10:29 +0100 Subject: [PATCH 1/3] Add 'require-trusted-types-for' --- Sources/Koba/Directives.swift | 4 ++++ Sources/Koba/Utils.swift | 1 + 2 files changed, 5 insertions(+) diff --git a/Sources/Koba/Directives.swift b/Sources/Koba/Directives.swift index dd3c90b..784334a 100644 --- a/Sources/Koba/Directives.swift +++ b/Sources/Koba/Directives.swift @@ -188,6 +188,10 @@ public class CSP { return self } + public func requireTrustedTypesFor(_ values: String...) -> CSP { + directives.append("require-trusted-types-for \(values.joined(separator: " "))") + } + public func reportTo(_ reportTo: ReportTo...) -> CSP { var reporting: [String] = [] _ = reportTo.map { report in diff --git a/Sources/Koba/Utils.swift b/Sources/Koba/Utils.swift index 3298c3f..b149387 100644 --- a/Sources/Koba/Utils.swift +++ b/Sources/Koba/Utils.swift @@ -45,6 +45,7 @@ extension Koba { public static let strictDynamic = "'strict-dynamic'" public static let unsafeEval = "'unsafe-eval'" public static let unsafeInline = "'unsafe-inline'" + public static let script = "'script" public static let wildcard = "*" } From be8f72e422c95bb0334b81b2787a5e2f7034b3b4 Mon Sep 17 00:00:00 2001 From: Mathieu Barnachon Date: Tue, 3 Mar 2020 16:15:50 +0100 Subject: [PATCH 2/3] fix missing return. --- Sources/Koba/Directives.swift | 1 + 1 file changed, 1 insertion(+) diff --git a/Sources/Koba/Directives.swift b/Sources/Koba/Directives.swift index 784334a..ccdcfee 100644 --- a/Sources/Koba/Directives.swift +++ b/Sources/Koba/Directives.swift @@ -190,6 +190,7 @@ public class CSP { public func requireTrustedTypesFor(_ values: String...) -> CSP { directives.append("require-trusted-types-for \(values.joined(separator: " "))") + return self } public func reportTo(_ reportTo: ReportTo...) -> CSP { From 4d4f327d4aeb7b4b80d1eceb239b17c4b70d05b7 Mon Sep 17 00:00:00 2001 From: Mathieu Barnachon Date: Tue, 3 Mar 2020 16:26:31 +0100 Subject: [PATCH 3/3] Missing quote on script Source. --- Sources/Koba/Utils.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sources/Koba/Utils.swift b/Sources/Koba/Utils.swift index b149387..88e77fa 100644 --- a/Sources/Koba/Utils.swift +++ b/Sources/Koba/Utils.swift @@ -45,7 +45,7 @@ extension Koba { public static let strictDynamic = "'strict-dynamic'" public static let unsafeEval = "'unsafe-eval'" public static let unsafeInline = "'unsafe-inline'" - public static let script = "'script" + public static let script = "'script'" public static let wildcard = "*" }