Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
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
5 changes: 5 additions & 0 deletions .jules/sentinel.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,8 @@
**Vulnerability:** Use of `innerHTML` for dynamic content and missing Content Security Policy (CSP).
**Learning:** Even if the content is currently static, using `innerHTML` is a dangerous pattern that can lead to XSS if the application grows. Prefer `textContent` and explicit DOM node creation.
**Prevention:** Establish a strong CSP and enforce secure DOM manipulation practices through documentation and code reviews.

## 2025-05-14 - Playwright Verification & CSP 'unsafe-eval'
**Vulnerability:** Playwright's `wait_for_function` and `evaluate` with string arguments trigger CSP 'unsafe-eval' violations.
**Learning:** In a security-hardened environment with a strict CSP, automated tests can fail not because of application bugs, but because the testing tools themselves use patterns (like `eval()`) that the policy forbids.
**Prevention:** Use `expect` assertions or native function handles in Playwright instead of string-based evaluation to verify state in environments with strict Content Security Policies.
9 changes: 6 additions & 3 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="Content-Security-Policy" content="default-src 'self'; style-src 'self' 'sha256-fgxmLOznNmVf4GAd24jy5Eiv/Rer+7sVLOBqnsVx0nY='; script-src 'self' 'sha256-cPRnZP+O4z5KsN+vdFstQwgKExGtoN98I3Gq+Tm1aSA='; object-src 'none'; base-uri 'self'; upgrade-insecure-requests;">
<meta http-equiv="Content-Security-Policy" content="default-src 'self'; style-src 'self' 'sha256-fgxmLOznNmVf4GAd24jy5Eiv/Rer+7sVLOBqnsVx0nY='; script-src 'self' 'sha256-bvRFa2jHqchEkcg/SXOyHM45aOrU7HTFskUExbCEwc4='; object-src 'none'; base-uri 'self'; form-action 'none'; upgrade-insecure-requests;">
<meta name="referrer" content="no-referrer">
<title>5ive - UX Sample</title>
<style>
Expand Down Expand Up @@ -167,18 +167,21 @@ <h1>Welcome to 5ive</h1>
feedback.appendChild(content);

const closeBtn = document.createElement('button');
// ✅ Sentinel: Explicitly set type="button" to prevent accidental form submission (Defense in Depth)
closeBtn.type = 'button';
closeBtn.className = 'close-btn';
closeBtn.setAttribute('aria-label', 'Close notification');
closeBtn.textContent = '×';
closeBtn.onclick = () => {
// ✅ Sentinel: Use addEventListener instead of onclick for better security and coding standards
closeBtn.addEventListener('click', () => {
if (feedbackTimeout) clearTimeout(feedbackTimeout);
feedback.classList.remove('visible');
setTimeout(() => {
if (!feedback.classList.contains('visible')) {
feedback.textContent = '';
}
}, 300);
};
});
feedback.appendChild(closeBtn);

// Trigger reflow/transition
Expand Down