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.
This commit is contained in:
zgaetano 2026-10-06 09:41:27 -04:00
parent 54ad0a0898
commit 35e5c133f7
14 changed files with 26 additions and 12 deletions

1
.env.example Normal file
View file

@ -0,0 +1 @@
DF_SESSION_COOKIE=s:<your-dragonflight.sid-cookie-value>

1
.gitignore vendored
View file

@ -1,3 +1,4 @@
node_modules/
page-text.json
capture-log.json
.env

View file

@ -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);

View file

@ -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({

View file

@ -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']});

View file

@ -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({

View file

@ -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);

View file

@ -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);

View file

@ -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 () => {

View file

@ -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 () => {

View file

@ -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,

View file

@ -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)});}

View file

@ -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);

View file

@ -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 = {};