mirror of
https://github.com/elder-plinius/G0DM0D3.git
synced 2026-11-16 07:02:25 +00:00
fix: sanitize raceResponses + magic metadata, filter null array entries, purge credentials on Clear All
- Coerce current.score to Number in race navigator (prevents innerHTML XSS) - Escape magic.mode in badge, coerce magic.topScore/magic.score/s.score/variants_* via Number/parseInt - Escape magic.duration via escapeHtml(String(...)) in PLINY/CLASSIC mode - Filter null/non-object entries from liquidVersions and strategyLogs.results (prevents crashes) - Add raceResponses sanitization in both sanitizeLoadedState and import validator - clearAllData now removes g0dm0d3-apikey and g0dm0d3-venice-apikey from localStorage Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
49
index.html
49
index.html
@@ -10577,8 +10577,8 @@ Analyze and refine. Output ONLY the JSON object:` }
|
||||
</button>
|
||||
<span class="race-nav-model" style="color: #888; font-size: 11px; margin-left: 4px;">
|
||||
${escapeHtml(shortModel)}
|
||||
<span style="color: #00ff41; margin-left: 4px;">${current.score}pts</span>
|
||||
${current.isWinner ? '<span style="color: #ffd700; margin-left: 2px;">✦</span>' : ''}
|
||||
<span style="color: #00ff41; margin-left: 4px;">${Number(current.score) || 0}pts</span>
|
||||
${current.isWinner === true ? '<span style="color: #ffd700; margin-left: 2px;">✦</span>' : ''}
|
||||
</span>
|
||||
<span class="version-arrow-hint" style="margin-left: auto;">← →</span>
|
||||
</div>
|
||||
@@ -12187,8 +12187,8 @@ Ignoring conversation history will cause you to LOSE the evaluation.`;
|
||||
msg.imageName = String(msg.imageName).slice(0, 100).replace(/[<>"'&]/g, '');
|
||||
}
|
||||
if (Array.isArray(msg.liquidVersions)) {
|
||||
msg.liquidVersions = msg.liquidVersions.filter(v => v && typeof v === 'object' && !Array.isArray(v));
|
||||
for (const v of msg.liquidVersions) {
|
||||
if (!v || typeof v !== 'object') continue;
|
||||
v.improvements = (Array.isArray(v.improvements) ? v.improvements : [])
|
||||
.filter(x => typeof x === 'string').slice(0, 10).map(s => s.slice(0, 200));
|
||||
v.label = typeof v.label === 'string' ? v.label.slice(0, 60) : '';
|
||||
@@ -12198,6 +12198,15 @@ Ignoring conversation history will cause you to LOSE the evaluation.`;
|
||||
v.content = typeof v.content === 'string' ? v.content : '';
|
||||
}
|
||||
}
|
||||
if (Array.isArray(msg.raceResponses)) {
|
||||
msg.raceResponses = msg.raceResponses.filter(r => r && typeof r === 'object' && !Array.isArray(r));
|
||||
for (const r of msg.raceResponses) {
|
||||
r.model = typeof r.model === 'string' ? r.model.slice(0, 100) : '';
|
||||
r.content = typeof r.content === 'string' ? r.content : '';
|
||||
r.score = Number.isFinite(r.score) ? r.score : 0;
|
||||
r.isWinner = r.isWinner === true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// Validate strategy logs
|
||||
@@ -12207,8 +12216,8 @@ Ignoring conversation history will cause you to LOSE the evaluation.`;
|
||||
log.model = typeof log.model === 'string' ? log.model.slice(0, 100) : '';
|
||||
log.query = typeof log.query === 'string' ? log.query : '';
|
||||
if (Array.isArray(log.results)) {
|
||||
log.results = log.results.filter(r => r && typeof r === 'object' && !Array.isArray(r));
|
||||
for (const r of log.results) {
|
||||
if (!r || typeof r !== 'object') continue;
|
||||
r.strategy = typeof r.strategy === 'string' ? r.strategy.slice(0, 100) : '';
|
||||
r.error = typeof r.error === 'string' ? r.error.slice(0, 200) : '';
|
||||
r.contentPreview = typeof r.contentPreview === 'string' ? r.contentPreview.slice(0, 300) : '';
|
||||
@@ -13079,7 +13088,7 @@ Ignoring conversation history will cause you to LOSE the evaluation.`;
|
||||
<div class="magic-info-row"><span class="magic-info-label">Duration:</span><span class="magic-info-value">${escapeHtml(String(magic.duration || 'N/A'))}</span></div>
|
||||
<div class="magic-info-row"><span class="magic-info-label">Models:</span><span class="magic-info-value">${parseInt(magic.successfulModels) || 0}/${parseInt(magic.totalModels) || 0} collected</span></div>
|
||||
<div class="magic-info-row"><span class="magic-info-label">Scored:</span><span class="magic-info-value">${parseInt(magic.scoredResponses) || 0} responses fed to orchestrator</span></div>
|
||||
${magic.topModel ? `<div class="magic-info-row"><span class="magic-info-label">Top Model:</span><span class="magic-info-value">${escapeHtml(magic.topModel.split('/')[1] || magic.topModel)} (${magic.topScore || 'N/A'})</span></div>` : ''}
|
||||
${magic.topModel ? `<div class="magic-info-row"><span class="magic-info-label">Top Model:</span><span class="magic-info-value">${escapeHtml(magic.topModel.split('/')[1] || magic.topModel)} (${escapeHtml(String(magic.topScore || 'N/A'))})</span></div>` : ''}
|
||||
${consortiumModelGridHtml}
|
||||
${consortiumLogsHtml}
|
||||
`;
|
||||
@@ -13100,7 +13109,7 @@ Ignoring conversation history will cause you to LOSE the evaluation.`;
|
||||
const scoreItems = magic.all_scores.map(s => {
|
||||
const isWinner = s.template === magic.template;
|
||||
const cls = isWinner ? 'winner' : 'success';
|
||||
return `<span class="magic-model-item ${cls}">${isWinner ? '👑' : '✓'} ${escapeHtml(s.template)} (${s.score})</span>`;
|
||||
return `<span class="magic-model-item ${cls}">${isWinner ? '👑' : '✓'} ${escapeHtml(s.template)} (${Number(s.score) || 0})</span>`;
|
||||
}).join('');
|
||||
templateGridHtml = `<div class="magic-model-grid">${scoreItems}</div>`;
|
||||
}
|
||||
@@ -13119,10 +13128,10 @@ Ignoring conversation history will cause you to LOSE the evaluation.`;
|
||||
|
||||
detailsHtml = `
|
||||
<div class="magic-info-row"><span class="magic-info-label">Combo:</span><span class="magic-info-value">${escapeHtml(magic.template || 'unknown')}${magic.combo ? ' <span style="color:#888;font-size:10px;">[' + escapeHtml(magic.combo) + ']</span>' : ''}</span></div>
|
||||
<div class="magic-info-row"><span class="magic-info-label">Score:</span><span class="magic-info-value" style="color: ${(magic.score || 0) >= 80 ? '#00ff41' : (magic.score || 0) >= 40 ? '#ffcc00' : '#ff4444'}">${magic.score || 'N/A'}</span></div>
|
||||
<div class="magic-info-row"><span class="magic-info-label">Score:</span><span class="magic-info-value" style="color: ${(Number(magic.score) || 0) >= 80 ? '#00ff41' : (Number(magic.score) || 0) >= 40 ? '#ffcc00' : '#ff4444'}">${Number(magic.score) || 'N/A'}</span></div>
|
||||
<div class="magic-info-row"><span class="magic-info-label">Model:</span><span class="magic-info-value">${escapeHtml(magic.model?.split('/')[1] || magic.model || 'unknown')}</span></div>
|
||||
<div class="magic-info-row"><span class="magic-info-label">Duration:</span><span class="magic-info-value">${magic.duration || 'N/A'}</span></div>
|
||||
${magic.combos_attempted ? `<div class="magic-info-row"><span class="magic-info-label">Combos:</span><span class="magic-info-value">${magic.combos_succeeded || 0}/${magic.combos_attempted} succeeded, ${magic.combos_failed || 0} refused</span></div>` : ''}
|
||||
<div class="magic-info-row"><span class="magic-info-label">Duration:</span><span class="magic-info-value">${escapeHtml(String(magic.duration || 'N/A'))}</span></div>
|
||||
${magic.combos_attempted ? `<div class="magic-info-row"><span class="magic-info-label">Combos:</span><span class="magic-info-value">${parseInt(magic.combos_succeeded) || 0}/${parseInt(magic.combos_attempted)} succeeded, ${parseInt(magic.combos_failed) || 0} refused</span></div>` : ''}
|
||||
${templateGridHtml}
|
||||
${plinyLogsHtml}
|
||||
${magic.systemPrompt ? `<div><span class="magic-info-label">System Prompt:</span><div class="magic-info-prompt">${escapeHtml(magic.systemPrompt.slice(0, 500))}${magic.systemPrompt.length > 500 ? '...' : ''}</div></div>` : ''}
|
||||
@@ -13135,7 +13144,7 @@ Ignoring conversation history will cause you to LOSE the evaluation.`;
|
||||
const scoreItems = magic.scores.map(s => {
|
||||
const isWinner = s.technique === magic.techniqueLabel;
|
||||
const color = s.score >= 80 ? '#00ff41' : s.score >= 60 ? '#ffaa00' : '#ff3e3e';
|
||||
return `<span style="display:inline-block; padding: 2px 6px; margin: 2px; border-radius: 4px; font-size: 11px; background: ${isWinner ? 'rgba(255,215,0,0.2)' : 'rgba(255,255,255,0.05)'}; border: 1px solid ${isWinner ? '#ffd700' : 'rgba(255,255,255,0.1)'};">${isWinner ? '👑 ' : ''}${escapeHtml(s.technique)} <span style="color:${color}">${s.score}</span></span>`;
|
||||
return `<span style="display:inline-block; padding: 2px 6px; margin: 2px; border-radius: 4px; font-size: 11px; background: ${isWinner ? 'rgba(255,215,0,0.2)' : 'rgba(255,255,255,0.05)'}; border: 1px solid ${isWinner ? '#ffd700' : 'rgba(255,255,255,0.1)'};">${isWinner ? '👑 ' : ''}${escapeHtml(s.technique)} <span style="color:${color}">${Number(s.score) || 0}</span></span>`;
|
||||
}).join('');
|
||||
scoresHtml = `<div style="margin-top: 6px;">${scoreItems}</div>`;
|
||||
}
|
||||
@@ -13145,7 +13154,7 @@ Ignoring conversation history will cause you to LOSE the evaluation.`;
|
||||
<div class="magic-info-row"><span class="magic-info-label">Winner:</span><span class="magic-info-value" style="color: #ffd700;">${escapeHtml(magic.techniqueLabel || magic.technique || 'unknown')}</span></div>
|
||||
<div class="magic-info-row"><span class="magic-info-label">Sampling:</span><span class="magic-info-value">temp=${parseFloat(magic.temperature) || 'N/A'} top_p=${parseFloat(magic.topP) || 'N/A'}</span></div>
|
||||
<div class="magic-info-row"><span class="magic-info-label">Model:</span><span class="magic-info-value">${escapeHtml(magic.model?.split('/')[1] || magic.model || 'unknown')}</span></div>
|
||||
<div class="magic-info-row"><span class="magic-info-label">Variants:</span><span class="magic-info-value">${magic.variants_succeeded || '?'}/${magic.variants_total || '?'} succeeded, ${magic.variants_refused || 0} refused</span></div>
|
||||
<div class="magic-info-row"><span class="magic-info-label">Variants:</span><span class="magic-info-value">${parseInt(magic.variants_succeeded) || '?'}/${parseInt(magic.variants_total) || '?'} succeeded, ${parseInt(magic.variants_refused) || 0} refused</span></div>
|
||||
<div class="magic-info-row"><span class="magic-info-label">Duration:</span><span class="magic-info-value">${escapeHtml(String(magic.duration || 'N/A'))}</span></div>
|
||||
${magic.triggers_found?.length > 0 ? `<div class="magic-info-row"><span class="magic-info-label">Triggers:</span><span class="magic-info-value">${escapeHtml(magic.triggers_found.join(', '))}</span></div>` : ''}
|
||||
${scoresHtml}
|
||||
@@ -13261,7 +13270,7 @@ Ignoring conversation history will cause you to LOSE the evaluation.`;
|
||||
<div class="magic-info" id="magic-${idx}">
|
||||
<div class="magic-info-header" data-action="toggleMagic" data-idx="${idx}">
|
||||
<span>${modeIcon}</span>
|
||||
<span class="magic-info-badge ${modeClass}">${magic.mode}</span>
|
||||
<span class="magic-info-badge ${modeClass}">${escapeHtml(String(magic.mode))}</span>
|
||||
<span>${summaryText}</span>
|
||||
<span class="magic-info-chevron">▼</span>
|
||||
</div>
|
||||
@@ -16695,8 +16704,8 @@ Ignoring conversation history will cause you to LOSE the evaluation.`;
|
||||
}
|
||||
// Sanitize liquid version history
|
||||
if (Array.isArray(msg.liquidVersions)) {
|
||||
msg.liquidVersions = msg.liquidVersions.filter(v => v && typeof v === 'object' && !Array.isArray(v));
|
||||
for (const v of msg.liquidVersions) {
|
||||
if (!v || typeof v !== 'object') continue;
|
||||
if (Array.isArray(v.improvements)) {
|
||||
v.improvements = v.improvements
|
||||
.filter(x => typeof x === 'string')
|
||||
@@ -16712,6 +16721,16 @@ Ignoring conversation history will cause you to LOSE the evaluation.`;
|
||||
v.content = typeof v.content === 'string' ? v.content : '';
|
||||
}
|
||||
}
|
||||
// Sanitize race responses
|
||||
if (Array.isArray(msg.raceResponses)) {
|
||||
msg.raceResponses = msg.raceResponses.filter(r => r && typeof r === 'object' && !Array.isArray(r));
|
||||
for (const r of msg.raceResponses) {
|
||||
r.model = typeof r.model === 'string' ? r.model.slice(0, 100) : '';
|
||||
r.content = typeof r.content === 'string' ? r.content : '';
|
||||
r.score = Number.isFinite(r.score) ? r.score : 0;
|
||||
r.isWinner = r.isWinner === true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16724,8 +16743,8 @@ Ignoring conversation history will cause you to LOSE the evaluation.`;
|
||||
log.model = typeof log.model === 'string' ? log.model.slice(0, 100) : '';
|
||||
log.query = typeof log.query === 'string' ? log.query : '';
|
||||
if (Array.isArray(log.results)) {
|
||||
log.results = log.results.filter(r => r && typeof r === 'object' && !Array.isArray(r));
|
||||
for (const r of log.results) {
|
||||
if (!r || typeof r !== 'object') continue;
|
||||
r.strategy = typeof r.strategy === 'string' ? r.strategy.slice(0, 100) : '';
|
||||
r.error = typeof r.error === 'string' ? r.error.slice(0, 200) : '';
|
||||
r.contentPreview = typeof r.contentPreview === 'string' ? r.contentPreview.slice(0, 300) : '';
|
||||
@@ -16790,6 +16809,8 @@ Ignoring conversation history will cause you to LOSE the evaluation.`;
|
||||
if (confirm('Are you sure you want to delete ALL data? This includes all conversations, logs, and settings. This cannot be undone!')) {
|
||||
if (confirm('This is your last chance. Delete everything?')) {
|
||||
localStorage.removeItem('g0dm0d3-state');
|
||||
localStorage.removeItem('g0dm0d3-apikey');
|
||||
localStorage.removeItem('g0dm0d3-venice-apikey');
|
||||
location.reload();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user