Skip to content
Merged
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
2 changes: 1 addition & 1 deletion apps/ui/public/_headers
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
X-Frame-Options: DENY
Referrer-Policy: strict-origin-when-cross-origin
Permissions-Policy: camera=(), microphone=(), geolocation=(), payment=()
Content-Security-Policy: default-src 'none'; script-src 'self' 'sha256-v1Z7Kqt3raaiGY/lFSvXBk1xU46FLzlYiiPgmqkaa0Y=' https://static.cloudflareinsights.com https://challenges.cloudflare.com; style-src 'self' 'unsafe-inline'; font-src 'self'; img-src 'self' data:; connect-src 'self' https://cloudflareinsights.com; frame-src https://challenges.cloudflare.com; base-uri 'self'; form-action 'self'; frame-ancestors 'none'
Content-Security-Policy: default-src 'none'; script-src 'self' 'unsafe-inline' https://static.cloudflareinsights.com https://challenges.cloudflare.com; style-src 'self' 'unsafe-inline'; font-src 'self'; img-src 'self' data:; connect-src 'self' https://cloudflareinsights.com; frame-src https://challenges.cloudflare.com; base-uri 'self'; form-action 'self'; frame-ancestors 'none'

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Restore restrictive script-src policy

The updated CSP now allows script-src 'unsafe-inline', which is a security regression from the previous hash-based allowlist because any injected inline script or inline event handler can execute in production browsers. This weakens XSS protections for all pages served under this header and is not equivalent to permitting only the known hashed script.

Useful? React with 👍 / 👎.


/assets/*
Cache-Control: public, max-age=31536000, immutable
38 changes: 24 additions & 14 deletions apps/ui/src/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {
} from "./features/navigation/app-route";
import type { AppRoute } from "./features/navigation/app-route";
import { PrivacyPolicyView } from "./features/navigation/privacy-policy-view";
import { StatsView } from "./features/stats/stats-view";

type NavItem = Readonly<{
code: string;
Expand All @@ -34,12 +35,18 @@ const appNavItems: readonly NavItem[] = [
label: "Privacy policy",
route: "privacy",
},
{
code: "04",
label: "Stats",
route: "stats",
},
];

const appRouteTitles: Record<AppRoute, string> = {
home: "Rehoboam \u2014 Divergence",
hud: "Developer HUD \u2014 Rehoboam",
privacy: "Privacy Policy \u2014 Rehoboam",
stats: "Stats \u2014 Rehoboam",
};

export const App = () => {
Expand Down Expand Up @@ -108,7 +115,22 @@ export const App = () => {
mainRef.current?.focus();
}, [appRoute]);

const isSceneRoute = appRoute !== "privacy";
const viewClassName =
appRoute === "home" || appRoute === "hud"
? "app-shell__view app-shell__view--scene"
: `app-shell__view app-shell__view--${appRoute}`;

const renderView = () => {
switch (appRoute) {
case "home":
case "hud":
return <RehoboamScene forceHudEnabled={appRoute === "hud"} />;
case "stats":
return <StatsView />;
case "privacy":
return <PrivacyPolicyView />;
}
};

return (
<div className="app-shell">
Expand Down Expand Up @@ -136,19 +158,7 @@ export const App = () => {
</nav>
</aside>
<main className="app-shell__content" ref={mainRef} tabIndex={-1}>
<div
className={
isSceneRoute
? "app-shell__view app-shell__view--scene"
: "app-shell__view app-shell__view--privacy"
}
>
{isSceneRoute ? (
<RehoboamScene forceHudEnabled={appRoute === "hud"} />
) : (
<PrivacyPolicyView />
)}
</div>
<div className={viewClassName}>{renderView()}</div>
</main>
</div>
);
Expand Down
6 changes: 5 additions & 1 deletion apps/ui/src/features/navigation/app-route.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export type AppRoute = "home" | "hud" | "privacy";
export type AppRoute = "home" | "hud" | "privacy" | "stats";

const normalizePathname = (pathname: string): string => {
return pathname.trim().toLowerCase().replace(/\/+$/u, "") || "/";
Expand All @@ -14,6 +14,8 @@ export const getAppRouteFromPathname = (pathname: string): AppRoute => {
case "/privacy":
case "/privacy-policy":
return "privacy";
case "/stats":
return "stats";
default:
return "home";
}
Expand All @@ -27,5 +29,7 @@ export const getPathForAppRoute = (route: AppRoute): string => {
return "/hud";
case "privacy":
return "/privacy";
case "stats":
return "/stats";
}
};
12 changes: 9 additions & 3 deletions apps/ui/src/features/navigation/app-shell.css
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,10 @@
min-width: 202px;
}

.app-shell__nav-link--stats {
min-width: 134px;
}

.app-shell__nav-meta {
position: relative;
z-index: 1;
Expand Down Expand Up @@ -199,7 +203,8 @@
height: 100dvh;
}

.app-shell__view--privacy {
.app-shell__view--privacy,
.app-shell__view--stats {
min-height: 100dvh;
box-sizing: border-box;
display: flex;
Expand Down Expand Up @@ -315,7 +320,7 @@
}

.app-shell__nav {
grid-template-columns: repeat(3, minmax(0, 1fr));
grid-template-columns: repeat(4, minmax(0, 1fr));
}

.app-shell__nav-link {
Expand Down Expand Up @@ -365,7 +370,8 @@
);
}

.app-shell__view--privacy {
.app-shell__view--privacy,
.app-shell__view--stats {
align-items: flex-start;
padding: clamp(18px, 5vw, 24px) var(--app-shell-gutter)
calc(
Expand Down
Loading
Loading