feat(pki-118): add spiffe machine auth#5610
feat(pki-118): add spiffe machine auth#5610PrestigePvP wants to merge 3 commits intoInfisical:mainfrom
Conversation
✅ Snyk checks have passed. No issues have been found so far.
💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse. |
Greptile SummaryThis PR introduces SPIFFE machine authentication with a complete service, router, schema, and frontend components. However, it has critical blockers that prevent it from functioning: Critical Issues:
Security Issues:
These must be resolved before merging. Confidence Score: 0/5
Last reviewed commit: 96245d2 |
| const SPIFFE_ID_REGEX = /^spiffe:\/\/([^/]+)(\/.*)?$/; | ||
|
|
||
| export const isValidSpiffeId = (value: string): boolean => { | ||
| return SPIFFE_ID_REGEX.test(value); | ||
| }; | ||
|
|
||
| export const extractTrustDomainFromSpiffeId = (spiffeId: string): string => { | ||
| const match = spiffeId.match(SPIFFE_ID_REGEX); | ||
| if (!match) { | ||
| throw new Error(`Invalid SPIFFE ID: ${spiffeId}`); | ||
| } | ||
| return match[1]; | ||
| }; |
There was a problem hiding this comment.
Security: Use re2 package instead of native regex
Per project security rules, all regex must use the re2 package to prevent ReDoS. The SPIFFE_ID_REGEX is a native JavaScript regex used at lines 8 and 12.
Replace with:
import RE2 from "re2";
const SPIFFE_ID_REGEX = new RE2(String.raw`^spiffe://([^/]+)(/.*)?$`);
export const isValidSpiffeId = (value: string): boolean => {
return SPIFFE_ID_REGEX.test(value);
};
export const extractTrustDomainFromSpiffeId = (spiffeId: string): string => {
const match = SPIFFE_ID_REGEX.exec(spiffeId);
if (!match) throw new Error(`Invalid SPIFFE ID: ${spiffeId}`);
return match[1];
};| export const validateTrustDomain = z | ||
| .string() | ||
| .trim() | ||
| .min(1, "Trust domain is required") | ||
| .regex(/^[a-zA-Z0-9]([a-zA-Z0-9.-]*[a-zA-Z0-9])?$/, "Invalid trust domain format"); |
There was a problem hiding this comment.
Security: Use re2 package instead of native regex
Per project security rules, all regex must use the re2 package. The .regex() call at line 31 uses a native JavaScript regex.
Replace with:
import RE2 from "re2";
const TRUST_DOMAIN_RE2 = new RE2(String.raw`^[a-zA-Z0-9]([a-zA-Z0-9.\-]*[a-zA-Z0-9])?$`);
export const validateTrustDomain = z
.string()
.trim()
.min(1, "Trust domain is required")
.refine((val) => TRUST_DOMAIN_RE2.test(val), "Invalid trust domain format");
Context
Screenshots
TODO
Steps to verify the change
Type
Checklist
type(scope): short description(scope is optional, e.g.,fix: prevent crash on syncorfix(api): handle null response).