forked from bchanot/claude
feat(guardrails): secure-by-default rule and /guardrails scanner
Always-on rules/secure-by-default.md: hosting, a11y, Supabase RLS, SMS/email consent, cloud functions, API hygiene incl. password storage. Stdlib scanner (FAIL/WARN/MANUAL) + skill, 89-check suite, auditor gate wiring, profiles, routing row (plus Explore rows confirmed through the router dialog).
This commit is contained in:
1 parent
c5fad5ee8f
commit
558c49e1a1
45 files changed
+2473
-5
No files matched your search
@@ -0,0 +1,6 @@
|
||||
import { useState } from "react";
|
||||
|
||||
export function Home() {
|
||||
const [n] = useState(0);
|
||||
return <p>{n}</p>;
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
export function ContactForm({ go }: { go: () => void }) {
|
||||
return (
|
||||
<form>
|
||||
<label htmlFor="email">Email</label>
|
||||
<input id="email" type="email" />
|
||||
<label>
|
||||
Message
|
||||
<textarea name="msg" />
|
||||
</label>
|
||||
<input type="hidden" name="token" value="x" />
|
||||
<img src="/logo.png" alt="Company logo" />
|
||||
<img src="/divider.png" alt="" />
|
||||
<button
|
||||
type="submit"
|
||||
className="btn outline-none focus-visible:ring-2 focus-visible:ring-blue-500"
|
||||
>
|
||||
Send
|
||||
</button>
|
||||
<div role="button" tabIndex={0} onClick={go} onKeyDown={go}>
|
||||
Open
|
||||
</div>
|
||||
<div role="presentation" onClick={go}>
|
||||
<div role="dialog" aria-modal="true" onClick={(e) => e.stopPropagation()}>
|
||||
Dialog
|
||||
</div>
|
||||
</div>
|
||||
<input type="file" className="hidden" />
|
||||
<div className="backdrop" onClick={go} />
|
||||
</form>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
import { createClient } from "@supabase/supabase-js";
|
||||
|
||||
export async function getUser(request: Request) {
|
||||
const header = request.headers.get("authorization") ?? "";
|
||||
const token = header.replace("Bearer ", "");
|
||||
if (!token) return null;
|
||||
const sb = createClient(
|
||||
process.env.SUPABASE_URL!, process.env.SUPABASE_ANON_KEY!);
|
||||
const { data } = await sb.auth.getUser(token);
|
||||
return data.user;
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
import { Ratelimit } from "@upstash/ratelimit";
|
||||
|
||||
export const limiter = new Ratelimit({
|
||||
limiter: Ratelimit.slidingWindow(10, "10 s"),
|
||||
});
|
||||
@@ -0,0 +1,7 @@
|
||||
import { getUser } from "../../lib/auth";
|
||||
|
||||
export async function GET(request: Request) {
|
||||
const user = await getUser(request);
|
||||
if (!user) return new Response("unauthorized", { status: 401 });
|
||||
return Response.json({ ok: true });
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
:focus-visible {
|
||||
outline: 2px solid #1a4fd6;
|
||||
outline-offset: 2px;
|
||||
}
|
||||
|
||||
button:focus:not(:focus-visible) {
|
||||
outline: none;
|
||||
}
|
||||
|
||||
.search:focus {
|
||||
outline: none;
|
||||
border-color: #1a4fd6;
|
||||
}
|
||||
Reference in new issue
Block a user