openvibers/openvibe.tools Commits
Every tool host's CSP lets Cloudflare's analytics beacon load and report (#238)
Changes
nnew file mode 100644@@@ -0,0 +1,25 @@++'use strict';++/**++ * Every app's Content-Security-Policy lets Cloudflare's analytics beacon load and report (11-07): the text, image,++ * audio, docs and food apps refused static.cloudflareinsights.com, so every page on their own hosts++ * (case.openvibe.tools and the rest) logged a CSP error, found by the browser sweep of every site's inner pages.++ * node apps/_shared/test/csp-cloudflare-beacon.test.js++ */++const assert = require('assert');++const fs = require('fs');++const path = require('path');++++const APPS = path.join(__dirname, '..', '..');++const apps = fs.readdirSync(APPS).filter((a) => fs.existsSync(path.join(APPS, a, 'server', 'index.js')));++let checked = 0;++apps.forEach((a) => {++ const src = fs.readFileSync(path.join(APPS, a, 'server', 'index.js'), 'utf8');++ const script = src.match(/scriptSrc:\s*\[([^\]\n]*)\]/);++ if (!script) return; // an app that sets no CSP of its own++ checked++;++ assert.ok(/static\.cloudflareinsights\.com/.test(script[1]), `${a}: scriptSrc allows Cloudflare's beacon`);++ const connect = src.match(/connectSrc:\s*\[([^\]\n]*)\]/);++ if (connect) assert.ok(/cloudflareinsights\.com/.test(connect[1]), `${a}: connectSrc lets the beacon report`);++});++assert.ok(checked >= 5, `found the apps' CSPs (${checked})`);++console.log(`csp cloudflare beacon: ${checked} apps let the beacon load and report`);@@@ -95,14 +95,14 @@ app.use(helmet({contentSecurityPolicy: {directives: {defaultSrc: ["'self'"],-- scriptSrc: ["'self'", "'unsafe-inline'", "https://fonts.googleapis.com", "https://openvibe.network"],++ scriptSrc: ["'self'", "'unsafe-inline'", "https://fonts.googleapis.com", "https://openvibe.network", "https://static.cloudflareinsights.com"],styleSrc: ["'self'", "'unsafe-inline'", "https://fonts.googleapis.com", "https://fonts.gstatic.com"],fontSrc: ["'self'", "https://fonts.gstatic.com"],imgSrc: ["'self'", "data:", "blob:", jobsRuntime.mediaOrigin()], // job result previews are 302s to MediamediaSrc: ["'self'", "blob:", jobsRuntime.mediaOrigin()],// openvibe.events: release notifications (release-watch's EventSource, openvibe-shared 2.13.0).// The navbar's Messages count asks Chat (openvibe-shared 4.130.0).-- connectSrc: ["'self'", "https://openvibe.chat", "https://openvibe.network", "https://*.openvibe.tools", "https://openvibe.events"],++ connectSrc: ["'self'", "https://openvibe.chat", "https://openvibe.network", "https://*.openvibe.tools", "https://openvibe.events", "https://cloudflareinsights.com"],workerSrc: ["'self'", "blob:"],scriptSrcAttr: ["'unsafe-inline'"],},@@@ -112,13 +112,13 @@ app.use(helmet({contentSecurityPolicy: {directives: {defaultSrc: ["'self'"],-- scriptSrc: ["'self'", "'unsafe-inline'", "https://fonts.googleapis.com", "https://openvibe.network"],++ scriptSrc: ["'self'", "'unsafe-inline'", "https://fonts.googleapis.com", "https://openvibe.network", "https://static.cloudflareinsights.com"],styleSrc: ["'self'", "'unsafe-inline'", "https://fonts.googleapis.com", "https://fonts.gstatic.com"],fontSrc: ["'self'", "https://fonts.gstatic.com"],imgSrc: ["'self'", "data:", "blob:"],// openvibe.events: release notifications (release-watch's EventSource, openvibe-shared 2.13.0).// The navbar's Messages count asks Chat (openvibe-shared 4.130.0).-- connectSrc: ["'self'", "https://openvibe.chat", "https://openvibe.network", "https://*.openvibe.tools", "https://openvibe.events"],++ connectSrc: ["'self'", "https://openvibe.chat", "https://openvibe.network", "https://*.openvibe.tools", "https://openvibe.events", "https://cloudflareinsights.com"],workerSrc: ["'self'", "blob:"],scriptSrcAttr: ["'unsafe-inline'"],},@@@ -85,13 +85,13 @@ app.use(helmet({contentSecurityPolicy: {directives: {defaultSrc: ["'self'"],-- scriptSrc: ["'self'", "'unsafe-inline'", 'cdn.jsdelivr.net', 'unpkg.com', 'fonts.googleapis.com', 'https://openvibe.network'],++ scriptSrc: ["'self'", "'unsafe-inline'", 'cdn.jsdelivr.net', 'unpkg.com', 'fonts.googleapis.com', 'https://openvibe.network', "https://static.cloudflareinsights.com"],styleSrc: ["'self'", "'unsafe-inline'", 'cdn.jsdelivr.net', 'unpkg.com', 'fonts.googleapis.com', 'fonts.gstatic.com'],fontSrc: ["'self'", 'fonts.gstatic.com'],imgSrc: ["'self'", 'data:', 'image.tmdb.org', '*.tile.openstreetmap.org', '*.basemaps.cartocdn.com', 'server.arcgisonline.com'],// openvibe.events: release notifications (release-watch's EventSource, openvibe-shared 2.13.0).// The navbar's Messages count asks Chat (openvibe-shared 4.130.0).-- connectSrc: ["'self'", 'https://openvibe.chat', 'nominatim.openstreetmap.org', 'https://openvibe.network', 'https://openvibe.events'],++ connectSrc: ["'self'", 'https://openvibe.chat', 'nominatim.openstreetmap.org', 'https://openvibe.network', 'https://openvibe.events', "https://cloudflareinsights.com"],scriptSrcAttr: ["'unsafe-inline'"],},},@@@ -101,13 +101,13 @@ app.use(helmet({contentSecurityPolicy: {directives: {defaultSrc: ["'self'"],-- scriptSrc: ["'self'", "'unsafe-inline'", "https://fonts.googleapis.com", "https://openvibe.network"],++ scriptSrc: ["'self'", "'unsafe-inline'", "https://fonts.googleapis.com", "https://openvibe.network", "https://static.cloudflareinsights.com"],styleSrc: ["'self'", "'unsafe-inline'", "https://fonts.googleapis.com", "https://fonts.gstatic.com"],fontSrc: ["'self'", "https://fonts.gstatic.com"],imgSrc: ["'self'", "data:", "blob:", jobsRuntime.mediaOrigin()], // job result previews are 302s to Media// openvibe.events: release notifications (release-watch's EventSource, openvibe-shared 2.13.0).// The navbar's Messages count asks Chat (openvibe-shared 4.130.0).-- connectSrc: ["'self'", "https://openvibe.chat", "https://openvibe.network", "https://*.openvibe.tools", "https://openvibe.events"],++ connectSrc: ["'self'", "https://openvibe.chat", "https://openvibe.network", "https://*.openvibe.tools", "https://openvibe.events", "https://cloudflareinsights.com"],workerSrc: ["'self'", "blob:"],scriptSrcAttr: ["'unsafe-inline'"],},@@@ -83,7 +83,7 @@ app.use(helmet({imgSrc: ["'self'", "data:", "blob:", "*.tile.openstreetmap.org", "*.basemaps.cartocdn.com", "server.arcgisonline.com", "image.tmdb.org", "*.wp.com"],// openvibe.events: release notifications (release-watch's EventSource, openvibe-shared 2.13.0).// The navbar's Messages count asks Chat (openvibe-shared 4.130.0).-- connectSrc: ["'self'", "https://openvibe.chat", "nominatim.openstreetmap.org", "api.weather.gov", "api.open-meteo.com", "*.tile.openstreetmap.org", "*.basemaps.cartocdn.com", "server.arcgisonline.com", "https://openvibe.network", "https://openvibe.events"],++ connectSrc: ["'self'", "https://openvibe.chat", "nominatim.openstreetmap.org", "api.weather.gov", "api.open-meteo.com", "*.tile.openstreetmap.org", "*.basemaps.cartocdn.com", "server.arcgisonline.com", "https://openvibe.network", "https://openvibe.events", "https://cloudflareinsights.com"],fontSrc: ["'self'", "fonts.gstatic.com", "cdn.jsdelivr.net"],frameSrc: ["'none'"],scriptSrcAttr: ["'unsafe-inline'"],@@@ -64,13 +64,13 @@ app.use(helmet({contentSecurityPolicy: {directives: {defaultSrc: ["'self'"],-- scriptSrc: ["'self'", "'unsafe-inline'", "cdn.jsdelivr.net", "fonts.googleapis.com", "https://openvibe.network"],++ scriptSrc: ["'self'", "'unsafe-inline'", "cdn.jsdelivr.net", "fonts.googleapis.com", "https://openvibe.network", "https://static.cloudflareinsights.com"],styleSrc: ["'self'", "'unsafe-inline'", "fonts.googleapis.com", "fonts.gstatic.com"],fontSrc: ["'self'", "fonts.gstatic.com"],imgSrc: ["'self'", "data:", "blob:"],// openvibe.events: release notifications (release-watch's EventSource, openvibe-shared 2.13.0).// The navbar's Messages count asks Chat (openvibe-shared 4.130.0).-- connectSrc: ["'self'", "https://openvibe.chat", "https://openvibe.network", "https://api.exchangerate-api.com", "https://openvibe.events"],++ connectSrc: ["'self'", "https://openvibe.chat", "https://openvibe.network", "https://api.exchangerate-api.com", "https://openvibe.events", "https://cloudflareinsights.com"],frameSrc: ["'none'"],scriptSrcAttr: ["'unsafe-inline'"],},
new file mode 100644
new file mode 100644
@@ -0,0 +1,25 @@
@@ -0,0 +1,25 @@
+'use strict';
+/**
+ * Every app's Content-Security-Policy lets Cloudflare's analytics beacon load and report (11-07): the text, image,
+ * audio, docs and food apps refused static.cloudflareinsights.com, so every page on their own hosts
+ * (case.openvibe.tools and the rest) logged a CSP error, found by the browser sweep of every site's inner pages.
+ * node apps/_shared/test/csp-cloudflare-beacon.test.js
+ */
+const assert = require('assert');
+const fs = require('fs');
+const path = require('path');
+
+const APPS = path.join(__dirname, '..', '..');
+const apps = fs.readdirSync(APPS).filter((a) => fs.existsSync(path.join(APPS, a, 'server', 'index.js')));
+let checked = 0;
+apps.forEach((a) => {
+ const src = fs.readFileSync(path.join(APPS, a, 'server', 'index.js'), 'utf8');
+ const script = src.match(/scriptSrc:\s*\[([^\]\n]*)\]/);
+ if (!script) return; // an app that sets no CSP of its own
+ checked++;
+ assert.ok(/static\.cloudflareinsights\.com/.test(script[1]), `${a}: scriptSrc allows Cloudflare's beacon`);
+ const connect = src.match(/connectSrc:\s*\[([^\]\n]*)\]/);
+ if (connect) assert.ok(/cloudflareinsights\.com/.test(connect[1]), `${a}: connectSrc lets the beacon report`);
+});
+assert.ok(checked >= 5, `found the apps' CSPs (${checked})`);
+console.log(`csp cloudflare beacon: ${checked} apps let the beacon load and report`);
@@ -95,14 +95,14 @@ app.use(helmet({
@@ -95,14 +95,14 @@ app.use(helmet({
contentSecurityPolicy: {
contentSecurityPolicy: {
directives: {
directives: {
defaultSrc: ["'self'"],
defaultSrc: ["'self'"],
- scriptSrc: ["'self'", "'unsafe-inline'", "https://fonts.googleapis.com", "https://openvibe.network"],
+ scriptSrc: ["'self'", "'unsafe-inline'", "https://fonts.googleapis.com", "https://openvibe.network", "https://static.cloudflareinsights.com"],
styleSrc: ["'self'", "'unsafe-inline'", "https://fonts.googleapis.com", "https://fonts.gstatic.com"],
styleSrc: ["'self'", "'unsafe-inline'", "https://fonts.googleapis.com", "https://fonts.gstatic.com"],
fontSrc: ["'self'", "https://fonts.gstatic.com"],
fontSrc: ["'self'", "https://fonts.gstatic.com"],
imgSrc: ["'self'", "data:", "blob:", jobsRuntime.mediaOrigin()], // job result previews are 302s to Media
imgSrc: ["'self'", "data:", "blob:", jobsRuntime.mediaOrigin()], // job result previews are 302s to Media
mediaSrc: ["'self'", "blob:", jobsRuntime.mediaOrigin()],
mediaSrc: ["'self'", "blob:", jobsRuntime.mediaOrigin()],
// openvibe.events: release notifications (release-watch's EventSource, openvibe-shared 2.13.0).
// openvibe.events: release notifications (release-watch's EventSource, openvibe-shared 2.13.0).
// The navbar's Messages count asks Chat (openvibe-shared 4.130.0).
// The navbar's Messages count asks Chat (openvibe-shared 4.130.0).
- connectSrc: ["'self'", "https://openvibe.chat", "https://openvibe.network", "https://*.openvibe.tools", "https://openvibe.events"],
+ connectSrc: ["'self'", "https://openvibe.chat", "https://openvibe.network", "https://*.openvibe.tools", "https://openvibe.events", "https://cloudflareinsights.com"],
workerSrc: ["'self'", "blob:"],
workerSrc: ["'self'", "blob:"],
scriptSrcAttr: ["'unsafe-inline'"],
scriptSrcAttr: ["'unsafe-inline'"],
},
},
@@ -112,13 +112,13 @@ app.use(helmet({
@@ -112,13 +112,13 @@ app.use(helmet({
contentSecurityPolicy: {
contentSecurityPolicy: {
directives: {
directives: {
defaultSrc: ["'self'"],
defaultSrc: ["'self'"],
- scriptSrc: ["'self'", "'unsafe-inline'", "https://fonts.googleapis.com", "https://openvibe.network"],
+ scriptSrc: ["'self'", "'unsafe-inline'", "https://fonts.googleapis.com", "https://openvibe.network", "https://static.cloudflareinsights.com"],
styleSrc: ["'self'", "'unsafe-inline'", "https://fonts.googleapis.com", "https://fonts.gstatic.com"],
styleSrc: ["'self'", "'unsafe-inline'", "https://fonts.googleapis.com", "https://fonts.gstatic.com"],
fontSrc: ["'self'", "https://fonts.gstatic.com"],
fontSrc: ["'self'", "https://fonts.gstatic.com"],
imgSrc: ["'self'", "data:", "blob:"],
imgSrc: ["'self'", "data:", "blob:"],
// openvibe.events: release notifications (release-watch's EventSource, openvibe-shared 2.13.0).
// openvibe.events: release notifications (release-watch's EventSource, openvibe-shared 2.13.0).
// The navbar's Messages count asks Chat (openvibe-shared 4.130.0).
// The navbar's Messages count asks Chat (openvibe-shared 4.130.0).
- connectSrc: ["'self'", "https://openvibe.chat", "https://openvibe.network", "https://*.openvibe.tools", "https://openvibe.events"],
+ connectSrc: ["'self'", "https://openvibe.chat", "https://openvibe.network", "https://*.openvibe.tools", "https://openvibe.events", "https://cloudflareinsights.com"],
workerSrc: ["'self'", "blob:"],
workerSrc: ["'self'", "blob:"],
scriptSrcAttr: ["'unsafe-inline'"],
scriptSrcAttr: ["'unsafe-inline'"],
},
},
@@ -85,13 +85,13 @@ app.use(helmet({
@@ -85,13 +85,13 @@ app.use(helmet({
contentSecurityPolicy: {
contentSecurityPolicy: {
directives: {
directives: {
defaultSrc: ["'self'"],
defaultSrc: ["'self'"],
- scriptSrc: ["'self'", "'unsafe-inline'", 'cdn.jsdelivr.net', 'unpkg.com', 'fonts.googleapis.com', 'https://openvibe.network'],
+ scriptSrc: ["'self'", "'unsafe-inline'", 'cdn.jsdelivr.net', 'unpkg.com', 'fonts.googleapis.com', 'https://openvibe.network', "https://static.cloudflareinsights.com"],
styleSrc: ["'self'", "'unsafe-inline'", 'cdn.jsdelivr.net', 'unpkg.com', 'fonts.googleapis.com', 'fonts.gstatic.com'],
styleSrc: ["'self'", "'unsafe-inline'", 'cdn.jsdelivr.net', 'unpkg.com', 'fonts.googleapis.com', 'fonts.gstatic.com'],
fontSrc: ["'self'", 'fonts.gstatic.com'],
fontSrc: ["'self'", 'fonts.gstatic.com'],
imgSrc: ["'self'", 'data:', 'image.tmdb.org', '*.tile.openstreetmap.org', '*.basemaps.cartocdn.com', 'server.arcgisonline.com'],
imgSrc: ["'self'", 'data:', 'image.tmdb.org', '*.tile.openstreetmap.org', '*.basemaps.cartocdn.com', 'server.arcgisonline.com'],
// openvibe.events: release notifications (release-watch's EventSource, openvibe-shared 2.13.0).
// openvibe.events: release notifications (release-watch's EventSource, openvibe-shared 2.13.0).
// The navbar's Messages count asks Chat (openvibe-shared 4.130.0).
// The navbar's Messages count asks Chat (openvibe-shared 4.130.0).
- connectSrc: ["'self'", 'https://openvibe.chat', 'nominatim.openstreetmap.org', 'https://openvibe.network', 'https://openvibe.events'],
+ connectSrc: ["'self'", 'https://openvibe.chat', 'nominatim.openstreetmap.org', 'https://openvibe.network', 'https://openvibe.events', "https://cloudflareinsights.com"],
scriptSrcAttr: ["'unsafe-inline'"],
scriptSrcAttr: ["'unsafe-inline'"],
},
},
},
},
@@ -101,13 +101,13 @@ app.use(helmet({
@@ -101,13 +101,13 @@ app.use(helmet({
contentSecurityPolicy: {
contentSecurityPolicy: {
directives: {
directives: {
defaultSrc: ["'self'"],
defaultSrc: ["'self'"],
- scriptSrc: ["'self'", "'unsafe-inline'", "https://fonts.googleapis.com", "https://openvibe.network"],
+ scriptSrc: ["'self'", "'unsafe-inline'", "https://fonts.googleapis.com", "https://openvibe.network", "https://static.cloudflareinsights.com"],
styleSrc: ["'self'", "'unsafe-inline'", "https://fonts.googleapis.com", "https://fonts.gstatic.com"],
styleSrc: ["'self'", "'unsafe-inline'", "https://fonts.googleapis.com", "https://fonts.gstatic.com"],
fontSrc: ["'self'", "https://fonts.gstatic.com"],
fontSrc: ["'self'", "https://fonts.gstatic.com"],
imgSrc: ["'self'", "data:", "blob:", jobsRuntime.mediaOrigin()], // job result previews are 302s to Media
imgSrc: ["'self'", "data:", "blob:", jobsRuntime.mediaOrigin()], // job result previews are 302s to Media
// openvibe.events: release notifications (release-watch's EventSource, openvibe-shared 2.13.0).
// openvibe.events: release notifications (release-watch's EventSource, openvibe-shared 2.13.0).
// The navbar's Messages count asks Chat (openvibe-shared 4.130.0).
// The navbar's Messages count asks Chat (openvibe-shared 4.130.0).
- connectSrc: ["'self'", "https://openvibe.chat", "https://openvibe.network", "https://*.openvibe.tools", "https://openvibe.events"],
+ connectSrc: ["'self'", "https://openvibe.chat", "https://openvibe.network", "https://*.openvibe.tools", "https://openvibe.events", "https://cloudflareinsights.com"],
workerSrc: ["'self'", "blob:"],
workerSrc: ["'self'", "blob:"],
scriptSrcAttr: ["'unsafe-inline'"],
scriptSrcAttr: ["'unsafe-inline'"],
},
},
@@ -83,7 +83,7 @@ app.use(helmet({
@@ -83,7 +83,7 @@ app.use(helmet({
imgSrc: ["'self'", "data:", "blob:", "*.tile.openstreetmap.org", "*.basemaps.cartocdn.com", "server.arcgisonline.com", "image.tmdb.org", "*.wp.com"],
imgSrc: ["'self'", "data:", "blob:", "*.tile.openstreetmap.org", "*.basemaps.cartocdn.com", "server.arcgisonline.com", "image.tmdb.org", "*.wp.com"],
// openvibe.events: release notifications (release-watch's EventSource, openvibe-shared 2.13.0).
// openvibe.events: release notifications (release-watch's EventSource, openvibe-shared 2.13.0).
// The navbar's Messages count asks Chat (openvibe-shared 4.130.0).
// The navbar's Messages count asks Chat (openvibe-shared 4.130.0).
- connectSrc: ["'self'", "https://openvibe.chat", "nominatim.openstreetmap.org", "api.weather.gov", "api.open-meteo.com", "*.tile.openstreetmap.org", "*.basemaps.cartocdn.com", "server.arcgisonline.com", "https://openvibe.network", "https://openvibe.events"],
+ connectSrc: ["'self'", "https://openvibe.chat", "nominatim.openstreetmap.org", "api.weather.gov", "api.open-meteo.com", "*.tile.openstreetmap.org", "*.basemaps.cartocdn.com", "server.arcgisonline.com", "https://openvibe.network", "https://openvibe.events", "https://cloudflareinsights.com"],
fontSrc: ["'self'", "fonts.gstatic.com", "cdn.jsdelivr.net"],
fontSrc: ["'self'", "fonts.gstatic.com", "cdn.jsdelivr.net"],
frameSrc: ["'none'"],
frameSrc: ["'none'"],
scriptSrcAttr: ["'unsafe-inline'"],
scriptSrcAttr: ["'unsafe-inline'"],
@@ -64,13 +64,13 @@ app.use(helmet({
@@ -64,13 +64,13 @@ app.use(helmet({
contentSecurityPolicy: {
contentSecurityPolicy: {
directives: {
directives: {
defaultSrc: ["'self'"],
defaultSrc: ["'self'"],
- scriptSrc: ["'self'", "'unsafe-inline'", "cdn.jsdelivr.net", "fonts.googleapis.com", "https://openvibe.network"],
+ scriptSrc: ["'self'", "'unsafe-inline'", "cdn.jsdelivr.net", "fonts.googleapis.com", "https://openvibe.network", "https://static.cloudflareinsights.com"],
styleSrc: ["'self'", "'unsafe-inline'", "fonts.googleapis.com", "fonts.gstatic.com"],
styleSrc: ["'self'", "'unsafe-inline'", "fonts.googleapis.com", "fonts.gstatic.com"],
fontSrc: ["'self'", "fonts.gstatic.com"],
fontSrc: ["'self'", "fonts.gstatic.com"],
imgSrc: ["'self'", "data:", "blob:"],
imgSrc: ["'self'", "data:", "blob:"],
// openvibe.events: release notifications (release-watch's EventSource, openvibe-shared 2.13.0).
// openvibe.events: release notifications (release-watch's EventSource, openvibe-shared 2.13.0).
// The navbar's Messages count asks Chat (openvibe-shared 4.130.0).
// The navbar's Messages count asks Chat (openvibe-shared 4.130.0).
- connectSrc: ["'self'", "https://openvibe.chat", "https://openvibe.network", "https://api.exchangerate-api.com", "https://openvibe.events"],
+ connectSrc: ["'self'", "https://openvibe.chat", "https://openvibe.network", "https://api.exchangerate-api.com", "https://openvibe.events", "https://cloudflareinsights.com"],
frameSrc: ["'none'"],
frameSrc: ["'none'"],
scriptSrcAttr: ["'unsafe-inline'"],
scriptSrcAttr: ["'unsafe-inline'"],
},
},