From 35e5c133f744f3995e27226abe43ab4f6ecf9739 Mon Sep 17 00:00:00 2001 From: zgaetano Date: Tue, 6 Oct 2026 09:41:27 -0400 Subject: [PATCH] security: read session cookie from DF_SESSION_COOKIE env var The dragonflight.sid cookie was hardcoded in 12 Playwright capture scripts. Read it from the environment instead, fail fast when unset, and add .env.example /.env gitignore. The leaked session has been revoked. --- .env.example | 1 + .gitignore | 1 + capture-ai-reframe.js | 3 ++- capture-bmg-media.js | 3 ++- capture-rec-sched.js | 3 ++- capture.js | 3 ++- dl-text.js | 3 ++- editor.js | 3 ++- explore-details.js | 3 ++- explore-pages.js | 3 ++- inspect-library.js | 3 ++- page-text.js | 3 ++- recapture-asset.js | 3 ++- recapture.js | 3 ++- 14 files changed, 26 insertions(+), 12 deletions(-) create mode 100644 .env.example diff --git a/.env.example b/.env.example new file mode 100644 index 0000000..fe0694d --- /dev/null +++ b/.env.example @@ -0,0 +1 @@ +DF_SESSION_COOKIE=s: diff --git a/.gitignore b/.gitignore index dbacc88..dc8b5c3 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ node_modules/ page-text.json capture-log.json +.env diff --git a/capture-ai-reframe.js b/capture-ai-reframe.js index 3534d9a..9554da2 100644 --- a/capture-ai-reframe.js +++ b/capture-ai-reframe.js @@ -1,6 +1,7 @@ const { chromium } = require('playwright'); +if (!process.env.DF_SESSION_COOKIE) { console.error('DF_SESSION_COOKIE env var not set — grab the dragonflight.sid cookie value from your browser devtools, export it, rerun.'); process.exit(1); } const OUT='/home/zgaetano/media-command-guide/screenshots'; -const COOKIE='REDACTED'; +const COOKIE=process.env.DF_SESSION_COOKIE; const ASSET=process.argv[2]||'9b648563-2159-43af-9b02-40ae04821714'; const pause=p=>p.evaluate(()=>document.querySelectorAll('video').forEach(v=>{try{v.pause()}catch(e){}})); const clickText=(p,re)=>p.evaluate(s=>{const r=new RegExp(s);const el=[...document.querySelectorAll('button,[role=tab],a,div,span')].filter(e=>e.offsetHeight>0&&e.children.length<4).find(e=>r.test(e.innerText.trim()));if(el){el.click();return el.innerText.trim().slice(0,40)}return null},re.source); diff --git a/capture-bmg-media.js b/capture-bmg-media.js index 92729d3..ae59b88 100644 --- a/capture-bmg-media.js +++ b/capture-bmg-media.js @@ -1,8 +1,9 @@ const { chromium } = require('playwright'); +if (!process.env.DF_SESSION_COOKIE) { console.error('DF_SESSION_COOKIE env var not set — grab the dragonflight.sid cookie value from your browser devtools, export it, rerun.'); process.exit(1); } const path = require('path'); const OUT_DIR = '/home/zgaetano/media-command-guide/screenshots'; -const COOKIE_VAL = 'REDACTED'; +const COOKIE_VAL = process.env.DF_SESSION_COOKIE; (async () => { const browser = await chromium.launch({ diff --git a/capture-rec-sched.js b/capture-rec-sched.js index 435cf83..880cf62 100644 --- a/capture-rec-sched.js +++ b/capture-rec-sched.js @@ -1,6 +1,7 @@ const { chromium } = require('playwright'); +if (!process.env.DF_SESSION_COOKIE) { console.error('DF_SESSION_COOKIE env var not set — grab the dragonflight.sid cookie value from your browser devtools, export it, rerun.'); process.exit(1); } const OUT='/home/zgaetano/media-command-guide/screenshots'; -const COOKIE='REDACTED'; +const COOKIE=process.env.DF_SESSION_COOKIE; const esc=p=>p.keyboard.press('Escape'); (async()=>{ const b=await chromium.launch({args:['--no-sandbox','--autoplay-policy=no-user-gesture-required']}); diff --git a/capture.js b/capture.js index 21df1db..eb6eeb3 100644 --- a/capture.js +++ b/capture.js @@ -1,11 +1,12 @@ const { chromium } = require('playwright'); +if (!process.env.DF_SESSION_COOKIE) { console.error('DF_SESSION_COOKIE env var not set — grab the dragonflight.sid cookie value from your browser devtools, export it, rerun.'); process.exit(1); } const path = require('path'); const fs = require('fs'); const OUT_DIR = '/home/zgaetano/media-command-guide/screenshots'; fs.mkdirSync(OUT_DIR, { recursive: true }); -const COOKIE_VAL = 'REDACTED'; +const COOKIE_VAL = process.env.DF_SESSION_COOKIE; (async () => { const browser = await chromium.launch({ diff --git a/dl-text.js b/dl-text.js index baafb43..796959f 100644 --- a/dl-text.js +++ b/dl-text.js @@ -1,6 +1,7 @@ const { chromium } = require('playwright'); +if (!process.env.DF_SESSION_COOKIE) { console.error('DF_SESSION_COOKIE env var not set — grab the dragonflight.sid cookie value from your browser devtools, export it, rerun.'); process.exit(1); } (async()=>{const b=await chromium.launch({args:['--no-sandbox']});const c=await b.newContext({viewport:{width:1920,height:1080}}); -await c.addCookies([{name:'dragonflight.sid',value:'REDACTED',domain:'mediacmdr.com',path:'/',httpOnly:true,secure:true}]); +await c.addCookies([{name:'dragonflight.sid',value:process.env.DF_SESSION_COOKIE,domain:'mediacmdr.com',path:'/',httpOnly:true,secure:true}]); const p=await c.newPage();await p.goto('https://mediacmdr.com/#home',{waitUntil:'networkidle'});await p.waitForTimeout(3000); const ct=(s)=>p.evaluate(s=>{const e=[...document.querySelectorAll('button,[role=tab],a,div,span')].filter(x=>x.offsetHeight>0&&x.children.length<4).find(x=>new RegExp(s,'i').test((x.innerText||'').trim()));e&&e.click();return !!e},s); await ct('^Downloads');await p.waitForTimeout(2000);await ct('^Desktop apps');await p.waitForTimeout(2000); diff --git a/editor.js b/editor.js index 8ceeb19..a3977bf 100644 --- a/editor.js +++ b/editor.js @@ -1,6 +1,7 @@ const { chromium } = require('playwright'); +if (!process.env.DF_SESSION_COOKIE) { console.error('DF_SESSION_COOKIE env var not set — grab the dragonflight.sid cookie value from your browser devtools, export it, rerun.'); process.exit(1); } (async()=>{const b=await chromium.launch({args:['--no-sandbox']});const c=await b.newContext({viewport:{width:1920,height:1080}}); -await c.addCookies([{name:'dragonflight.sid',value:'REDACTED',domain:'mediacmdr.com',path:'/',httpOnly:true,secure:true}]); +await c.addCookies([{name:'dragonflight.sid',value:process.env.DF_SESSION_COOKIE,domain:'mediacmdr.com',path:'/',httpOnly:true,secure:true}]); const p=await c.newPage();await p.goto('https://mediacmdr.com/editor.html',{waitUntil:'networkidle'});await p.waitForTimeout(3000); const r=await p.evaluate(()=>{const s=[...document.querySelectorAll('select')].find(s=>[...s.options].some(o=>/Broadcast Managment/.test(o.text)));if(!s)return 'nosel';const o=[...s.options].find(o=>/Broadcast Managment/.test(o.text));s.value=o.value;s.dispatchEvent(new Event('change',{bubbles:true}));return o.value}); console.log('sel',r);await p.waitForTimeout(6000); diff --git a/explore-details.js b/explore-details.js index df5df30..f7f0e14 100644 --- a/explore-details.js +++ b/explore-details.js @@ -1,6 +1,7 @@ const { chromium } = require('playwright'); +if (!process.env.DF_SESSION_COOKIE) { console.error('DF_SESSION_COOKIE env var not set — grab the dragonflight.sid cookie value from your browser devtools, export it, rerun.'); process.exit(1); } const OUT = '/home/zgaetano/media-command-guide/screenshots'; -const COOKIE = 'REDACTED'; +const COOKIE = process.env.DF_SESSION_COOKIE; const pause = p => p.evaluate(() => document.querySelectorAll('video').forEach(v => { try { v.pause() } catch(e){} })); (async () => { diff --git a/explore-pages.js b/explore-pages.js index 29440e6..f114323 100644 --- a/explore-pages.js +++ b/explore-pages.js @@ -1,8 +1,9 @@ const { chromium } = require('playwright'); +if (!process.env.DF_SESSION_COOKIE) { console.error('DF_SESSION_COOKIE env var not set — grab the dragonflight.sid cookie value from your browser devtools, export it, rerun.'); process.exit(1); } const fs = require('fs'); const OUT = '/home/zgaetano/media-command-guide/screenshots'; const BMG = '5ebf74aa-f5b4-4a83-b089-c9af2cb25d1f'; -const COOKIE = 'REDACTED'; +const COOKIE = process.env.DF_SESSION_COOKIE; const pause = p => p.evaluate(() => document.querySelectorAll('video').forEach(v => { try { v.pause() } catch(e){} })); (async () => { diff --git a/inspect-library.js b/inspect-library.js index 2b18a31..96a6697 100644 --- a/inspect-library.js +++ b/inspect-library.js @@ -1,11 +1,12 @@ const { chromium } = require('playwright'); +if (!process.env.DF_SESSION_COOKIE) { console.error('DF_SESSION_COOKIE env var not set — grab the dragonflight.sid cookie value from your browser devtools, export it, rerun.'); process.exit(1); } (async () => { const browser = await chromium.launch({ headless: true }); const context = await browser.newContext({ viewport: { width: 1920, height: 1080 } }); await context.addCookies([{ name: 'dragonflight.sid', - value: 'REDACTED', + value: process.env.DF_SESSION_COOKIE, domain: 'mediacmdr.com', path: '/', httpOnly: true, diff --git a/page-text.js b/page-text.js index b753fb5..b1e2907 100644 --- a/page-text.js +++ b/page-text.js @@ -1,7 +1,8 @@ const { chromium } = require('playwright');const fs=require('fs'); +if (!process.env.DF_SESSION_COOKIE) { console.error('DF_SESSION_COOKIE env var not set — grab the dragonflight.sid cookie value from your browser devtools, export it, rerun.'); process.exit(1); } const R=['home','recorders','schedule','graphics','multiview','projects','library?project=5ebf74aa-f5b4-4a83-b089-c9af2cb25d1f','upload','contribution','youtube','cloud-import','jobs','staging','playout','playout-tria','engineering','applications','users','tokens','containers','logs','audit','cluster','alerts','settings','rundown','playout-schedule','playout-ads']; (async()=>{const b=await chromium.launch({args:['--no-sandbox']});const c=await b.newContext({viewport:{width:1920,height:1080}}); -await c.addCookies([{name:'dragonflight.sid',value:'REDACTED',domain:'mediacmdr.com',path:'/',httpOnly:true,secure:true}]); +await c.addCookies([{name:'dragonflight.sid',value:process.env.DF_SESSION_COOKIE,domain:'mediacmdr.com',path:'/',httpOnly:true,secure:true}]); const p=await c.newPage();await p.goto('https://mediacmdr.com/',{waitUntil:'networkidle'});const out={}; for(const r of R){await p.evaluate(h=>{location.hash=h},r);await p.waitForTimeout(4000); out[r]=await p.evaluate(()=>{const m=document.querySelector('main,[class*=content],[class*=page]')||document.body;return m.innerText.replace(/\n{2,}/g,'\n').slice(0,1400)});} diff --git a/recapture-asset.js b/recapture-asset.js index 8e5a09b..1417f43 100644 --- a/recapture-asset.js +++ b/recapture-asset.js @@ -1,4 +1,5 @@ const { chromium } = require('playwright'); +if (!process.env.DF_SESSION_COOKIE) { console.error('DF_SESSION_COOKIE env var not set — grab the dragonflight.sid cookie value from your browser devtools, export it, rerun.'); process.exit(1); } const OUT = '/home/zgaetano/media-command-guide/screenshots'; const BMG = '5ebf74aa-f5b4-4a83-b089-c9af2cb25d1f'; const pause = p => p.evaluate(() => document.querySelectorAll('video').forEach(v => { try { v.pause() } catch (e) {} })); @@ -12,7 +13,7 @@ const clickText = (p, src) => p.evaluate(src => { (async () => { const b = await chromium.launch({ headless: true, args: ['--no-sandbox', '--autoplay-policy=no-user-gesture-required'] }); const c = await b.newContext({ viewport: { width: 1920, height: 1080 } }); - await c.addCookies([{ name: 'dragonflight.sid', value: 'REDACTED', domain: 'mediacmdr.com', path: '/', httpOnly: true, secure: true }]); + await c.addCookies([{ name: 'dragonflight.sid', value: process.env.DF_SESSION_COOKIE, domain: 'mediacmdr.com', path: '/', httpOnly: true, secure: true }]); const p = await c.newPage(); await p.goto(`https://mediacmdr.com/#library?project=${BMG}`, { waitUntil: 'networkidle' }); await p.waitForTimeout(6000); diff --git a/recapture.js b/recapture.js index 1befc98..bdcee54 100644 --- a/recapture.js +++ b/recapture.js @@ -1,4 +1,5 @@ const { chromium } = require('playwright'); +if (!process.env.DF_SESSION_COOKIE) { console.error('DF_SESSION_COOKIE env var not set — grab the dragonflight.sid cookie value from your browser devtools, export it, rerun.'); process.exit(1); } const fs = require('fs'); const OUT = '/home/zgaetano/media-command-guide/screenshots'; const BMG = '5ebf74aa-f5b4-4a83-b089-c9af2cb25d1f'; @@ -25,7 +26,7 @@ const clickText = (p, re) => p.evaluate(src => { (async () => { const b = await chromium.launch({ headless: true, args: ['--no-sandbox', '--autoplay-policy=no-user-gesture-required'] }); const c = await b.newContext({ viewport: { width: 1920, height: 1080 } }); - await c.addCookies([{ name: 'dragonflight.sid', value: 'REDACTED', domain: 'mediacmdr.com', path: '/', httpOnly: true, secure: true }]); + await c.addCookies([{ name: 'dragonflight.sid', value: process.env.DF_SESSION_COOKIE, domain: 'mediacmdr.com', path: '/', httpOnly: true, secure: true }]); const p = await c.newPage(); await p.goto('https://mediacmdr.com/', { waitUntil: 'networkidle' }); const log = {};