Files
homebrewery-oidc/server/fork/git/errors.js
T
dev-bot BotandClaude Sonnet 5.5 448c67912f
CI / App (npm ci + Build, ESLint, Stylelint, Jest) (push) Successful in 3m25s
CI / Storage (mongo) (push) Successful in 1m24s
CI / Storage (postgres) (push) Successful in 1m13s
Image / Image bauen und pushen (push) Successful in 1m3s
feat(git): Git-Backend über HTTPS + PAT (ADR 0003, FLW-86) (#19)
Repositories gitConnections/brewGitLinks (Mongo/PG), Krypto, SSRF-Policy mit net.BlockList, git-Client ohne Arbeitskopie, Sync/Konflikte, /api/git/*, Client (Verbindungen, Git-Status, Konfliktdialog), Autosave 60 s für Git-Brews (F6), Tests und Doku.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: Dev (Paperclip) <dev-bot@noreply.git.morlana.online>
2026-11-25 21:16:42 +00:00

40 lines
1.9 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
// Fehlercodes des Git-Backends (ADR 0003). G01–G07 stehen in der ADR, G08–G10 sind Ergänzungen der Umsetzung.
export const GIT_ERRORS = {
G01 : { status: 409, message: 'Die Datei wurde im Repository geändert (Konflikt).' },
G02 : { status: 502, message: 'Anmeldung am Git-Server fehlgeschlagen (Token ungültig oder ohne Schreibrecht).' },
G03 : { status: 502, message: 'Repository, Branch oder Datei nicht gefunden.' },
G04 : { status: 504, message: 'Der Git-Server ist nicht erreichbar oder zu langsam.' },
G05 : { status: 503, message: 'Speichern im Repository nicht möglich (zu viele gleichzeitige Änderungen oder Server ausgelastet).' },
G06 : { status: 409, message: 'Die Datei existiert im Repository bereits.' },
G07 : { status: 403, message: 'Das Git-Backend steht nur Konten mit OIDC-Anmeldung zur Verfügung.' },
G08 : { status: 400, message: 'Ungültige Eingabe.' },
G09 : { status: 413, message: 'Die Datei ist zu groß.' },
G10 : { status: 503, message: 'Das Git-Backend ist auf diesem Server nicht aktiviert (HB_GIT_TOKEN_KEY fehlt).' }
};
export class GitError extends Error {
constructor(code, message, extra = {}) {
super(message ?? GIT_ERRORS[code]?.message ?? code);
this.name = 'GitError';
this.HBErrorCode = code;
this.status = extra.status ?? GIT_ERRORS[code]?.status ?? 500;
this.extra = extra.extra ?? {};
}
toBody() {
return { HBErrorCode: this.HBErrorCode, message: this.message, ...this.extra };
}
}
// Entfernt Token (auch als Basic-Header) und Authorization-Header aus Text vor dem Loggen/Ausliefern.
export const redact = (text, ...secrets)=>{
let out = String(text ?? '');
for (const secret of secrets.filter((s)=>s && String(s).length >= 3)) {
const s = String(secret);
out = out.split(s).join('***');
out = out.split(Buffer.from(s).toString('base64')).join('***');
}
return out
.replace(/(authorization:\s*(?:basic|bearer)\s+)\S+/gi, '$1***')
.replace(/(https?:\/\/)[^\s/@]+@/gi, '$1***@');
};