Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .jules/palette.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,3 +65,7 @@
## 2025-02-18 - Search Input Escape Key
**Learning:** Users who heavily rely on keyboard navigation (and power users) experience friction when forced to backspace manually or switch to the mouse to click a "Clear" button after filtering a list.
**Action:** Always provide an `Escape` key listener on search inputs to instantly clear the query and re-render the view, matching native OS text field behavior.

## 2026-08-07 - Refactoring inline handlers to Event Listeners for CSP Compliance
**Learning:** Hard-coded `onclick` attributes in plain HTML UI viewers (like `scanner/dashboard/index.html`) break Content Security Policy (CSP) guidelines because they execute inline scripts. Relying on them creates vulnerabilities and prevents deployment in strict security contexts. Additionally, missing `<button>` styling can make file inputs look jarring.
**Action:** Always avoid `onclick` handlers in HTML. Extract interactivity to a `<script>` block and bind behaviors using `addEventListener`. For unstylable elements like `<input type="file">`, visually hide them with `class="sr-only" tabindex="-1" aria-hidden="true"` and use a styled proxy `<button>` with an `addEventListener` that triggers the hidden input's click event.
23 changes: 19 additions & 4 deletions scanner/dashboard/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,8 @@
<span class="logo"></span><span class="brand">AppGuardrail</span>
<span class="spacer"></span>
<span class="meta" id="src">no findings loaded</span>
<input type="file" id="file" accept="application/json,.json" aria-label="Upload findings file" style="margin-left:12px">
<button type="button" id="header-browse-btn" class="primary-action" aria-label="Upload findings file" style="margin-left:12px; min-height: 28px; padding: 4px 12px; font-size: 13px;">Load Findings</button>
<input type="file" id="file" accept="application/json,.json" class="sr-only" tabindex="-1" aria-hidden="true">
</header>
<p id="findings-summary" class="sr-only" role="status" aria-live="polite" aria-atomic="true"></p>
<main id="app"></main>
Comment on lines +85 to +99

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

๐ŸŽฏ Functional Correctness | ๐ŸŸ  Major | โšก Quick win

์Šคํ‚ต ๋งํฌ์™€ main ํฌ์ปค์Šค ๊ฒฝ๋กœ๋ฅผ ๋ณต์›ํ•˜์„ธ์š”.

๊ธฐ์กด ์Šคํ‚ต ๋งํฌ๊ฐ€ ์ œ๊ฑฐ๋˜์—ˆ๊ณ , ํ˜„์žฌ <main id="app">์—๋Š” tabindex="-1"์ด ์—†์Šต๋‹ˆ๋‹ค. ํ‚ค๋ณด๋“œ ์‚ฌ์šฉ์ž๊ฐ€ ํ—ค๋” ์ปจํŠธ๋กค์„ ๊ฑด๋„ˆ๋›ฐ๊ณ  ๋ณธ๋ฌธ์œผ๋กœ ์ด๋™ํ•  ์ˆ˜ ์—†์Šต๋‹ˆ๋‹ค. ํŒŒ์ผ ์ž…๋ ฅ ๋ณ€๊ฒฝ๊ณผ ๋ฌด๊ด€ํ•œ ์ ‘๊ทผ์„ฑ ํšŒ๊ท€์ž…๋‹ˆ๋‹ค. ์Šคํ‚ต ๋งํฌ๋ฅผ ์œ ์ง€ํ•˜๊ณ  main์„ ํฌ์ปค์Šค ๋Œ€์ƒ์œผ๋กœ ๋ณต์›ํ•˜์„ธ์š”.

๐Ÿค– Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@scanner/dashboard/index.html` around lines 85 - 99, Restore the skip link in
the document header so keyboard users can bypass the header controls, and add
tabindex="-1" to the main element with id="app" to restore its programmatic
focus target. Keep the existing file input and findings-summary behavior
unchanged.

Expand Down Expand Up @@ -226,11 +227,11 @@ <h1>Dashboard</h1>
${SEV_ORDER.map(s=>`<option value="${s}" ${s===filterSev?'selected':''}>${s}</option>`).join('')}
</select>
</div>
<div class="panel"><table>
<div class="panel"><table id="findings-table">
<thead><tr><th scope="col">Severity</th><th scope="col">Finding</th><th scope="col">File</th><th scope="col">Category</th><th scope="col">Status</th></tr></thead>
<tbody>${rows||`<tr><td colspan="5" style="padding:32px 24px;text-align:center">
<div style="color:var(--text);font-weight:600;font-size:14px;margin-bottom:8px">No findings match the filter</div>
<button type="button" aria-label="Clear filters" onclick="query=''; filterSev=''; render(); document.getElementById('q')?.focus();" style="padding:6px 12px;border-radius:6px;border:1px solid var(--border);background:var(--surface);cursor:pointer;font:inherit;color:var(--text);font-weight:500;transition:background 0.2s">Clear filters</button>
<button type="button" id="clear-filters-btn" aria-label="Clear filters" style="padding:6px 12px;border-radius:6px;border:1px solid var(--border);background:var(--surface);cursor:pointer;font:inherit;color:var(--text);font-weight:500;transition:background 0.2s">Clear filters</button>
</td></tr>`}</tbody>
</table></div>
</div>
Expand All @@ -240,6 +241,16 @@ <h1>Dashboard</h1>
liveSummary.textContent = summaryText;
}

document.getElementById('findings-table')?.addEventListener('click', e => {
const btn = e.target.closest('#clear-filters-btn');
if (btn) {
query = '';
filterSev = '';
render();
document.getElementById('q')?.focus();
}
});

document.getElementById('q').addEventListener('input', e=>{
query = e.target.value.toLowerCase();
render();
Expand Down Expand Up @@ -285,7 +296,7 @@ <h1>Dashboard</h1>
<div class="dlg-head">
<span class="chip" style="background:${SEV[s]?SEV[s].color:'var(--info)'}">${esc(s)}</span>
<span class="t" id="dlg-title">${esc(f.rule_id)}</span>
<button aria-label="Close" title="Close (Esc)" onclick="document.getElementById('detail').close()">โœ•</button>
<button id="detail-close-btn" aria-label="Close" title="Close (Esc)">โœ•</button>
</div>
<div class="dlg-body">
<p class="file">${esc(f.file)}:${esc(f.line)} ยท ${esc(f.category)} ยท context: ${esc(f.context||'app-code')}${isDeployBlocking(f)?' ยท <span class="tag block">deploy-blocking</span>':''}</p>
Expand All @@ -298,6 +309,9 @@ <h1>Dashboard</h1>
${cwe?`<div class="kv">CWE: ${esc(cwe)}</div>`:''}
${refs?`<div style="margin-top:6px">${refs}</div>`:''}</div>`:''}
</div>`;
document.getElementById('detail-close-btn')?.addEventListener('click', () => {
document.getElementById('detail').close();
});
d.showModal();
}

Expand All @@ -320,6 +334,7 @@ <h1>Dashboard</h1>
}

const fileInput = document.getElementById('file');
document.getElementById('header-browse-btn')?.addEventListener('click', () => fileInput.click());
fileInput.addEventListener('change', () => {
const selectedFile = fileInput.files?.[0];
fileInput.value = '';
Expand Down
3 changes: 2 additions & 1 deletion tests/test_dashboard_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,8 @@ def test_dashboard_empty_state_clear_filters():

assert "No findings match the filter" in html
assert "aria-label=\"Clear filters\"" in html
assert "onclick=\"query=''; filterSev=''; render(); document.getElementById('q')?.focus();\"" in html
assert "id=\"clear-filters-btn\"" in html
assert ".addEventListener('click'" in html
assert "Clear filters</button>" in html


Expand Down
Loading