From 88383bb3f93efe8fbcf19d6ff07bcb63a8162fd6 Mon Sep 17 00:00:00 2001 From: Daniel Rentz Date: Mon, 24 Sep 2018 11:11:34 +0200 Subject: [PATCH] proposed fix for missing callback type for reportUri/reportTo --- types/helmet/helmet-tests.ts | 8 +++++++- types/helmet/index.d.ts | 8 ++++---- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/types/helmet/helmet-tests.ts b/types/helmet/helmet-tests.ts index 59e5613408..1ec548e49b 100644 --- a/types/helmet/helmet-tests.ts +++ b/types/helmet/helmet-tests.ts @@ -58,12 +58,18 @@ function contentSecurityPolicyTest() { disableAndroid: false }; + function reportCb(req: express.Request, res: express.Response) { return '/some-uri'; } + app.use(helmet.contentSecurityPolicy()); app.use(helmet.contentSecurityPolicy({})); app.use(helmet.contentSecurityPolicy(config)); app.use(helmet.contentSecurityPolicy({ directives: { - defaultSrc: ["'self'"] + defaultSrc: ["'self'"], + reportUri: reportCb, + 'report-uri': reportCb, + reportTo: reportCb, + 'report-to': reportCb }, loose: false, setAllHeaders: true diff --git a/types/helmet/index.d.ts b/types/helmet/index.d.ts index 3625d029a0..bdee793cdb 100644 --- a/types/helmet/index.d.ts +++ b/types/helmet/index.d.ts @@ -69,8 +69,8 @@ declare namespace helmet { objectSrc?: HelmetCspDirectiveValue[]; pluginTypes?: HelmetCspDirectiveValue[]; prefetchSrc?: HelmetCspDirectiveValue[]; - reportTo?: string; - reportUri?: string; + reportTo?: HelmetCspDirectiveValue; + reportUri?: HelmetCspDirectiveValue; requireSriFor?: HelmetCspRequireSriForValue[]; sandbox?: HelmetCspSandboxDirective[]; scriptSrc?: HelmetCspDirectiveValue[]; @@ -95,8 +95,8 @@ declare namespace helmet { 'object-src'?: HelmetCspDirectiveValue[]; 'plugin-types'?: HelmetCspDirectiveValue[]; 'prefetch-src'?: HelmetCspDirectiveValue[]; - 'report-to'?: string; - 'report-uri'?: string; + 'report-to'?: HelmetCspDirectiveValue; + 'report-uri'?: HelmetCspDirectiveValue; 'require-sri-for'?: HelmetCspRequireSriForValue[]; 'sandbox'?: HelmetCspSandboxDirective[]; 'script-src'?: HelmetCspDirectiveValue;