address audit findings: schedule validation, settings json guard, pipeline types, a11y labels
Build and Push Docker Image / build (push) Successful in 58s
Build and Push Docker Image / build (push) Successful in 58s
This commit is contained in:
@@ -41,10 +41,33 @@ export function getScheduleConfig(): ScheduleConfig {
|
||||
};
|
||||
}
|
||||
|
||||
const HHMM = /^([01]\d|2[0-3]):[0-5]\d$/;
|
||||
|
||||
function validateWindow(kind: WindowKind, w: Partial<ScheduleWindow>): void {
|
||||
if (w.start != null && !HHMM.test(w.start)) {
|
||||
throw new Error(`${kind}.start must be HH:MM 24h, got ${JSON.stringify(w.start)}`);
|
||||
}
|
||||
if (w.end != null && !HHMM.test(w.end)) {
|
||||
throw new Error(`${kind}.end must be HH:MM 24h, got ${JSON.stringify(w.end)}`);
|
||||
}
|
||||
}
|
||||
|
||||
export function updateScheduleConfig(updates: Partial<ScheduleConfig>): void {
|
||||
if (updates.job_sleep_seconds != null) setConfig("job_sleep_seconds", String(updates.job_sleep_seconds));
|
||||
if (updates.scan) writeWindow("scan", updates.scan);
|
||||
if (updates.process) writeWindow("process", updates.process);
|
||||
if (updates.job_sleep_seconds != null) {
|
||||
const n = updates.job_sleep_seconds;
|
||||
if (!Number.isFinite(n) || !Number.isInteger(n) || n < 0 || n > 86_400) {
|
||||
throw new Error(`job_sleep_seconds must be an integer in [0, 86400], got ${JSON.stringify(n)}`);
|
||||
}
|
||||
setConfig("job_sleep_seconds", String(n));
|
||||
}
|
||||
if (updates.scan) {
|
||||
validateWindow("scan", updates.scan);
|
||||
writeWindow("scan", updates.scan);
|
||||
}
|
||||
if (updates.process) {
|
||||
validateWindow("process", updates.process);
|
||||
writeWindow("process", updates.process);
|
||||
}
|
||||
}
|
||||
|
||||
function parseTime(hhmm: string): number {
|
||||
|
||||
Reference in New Issue
Block a user