fix(striker-ui-api): correct ntp and network gateway asserts in build manifest

main
Tsu-ba-me 2 years ago
parent 3ab1fe88d2
commit 84f708f5d1
  1. 8
      striker-ui-api/src/lib/request_handlers/manifest/buildManifest.ts

@ -28,7 +28,7 @@ export const buildManifest = (
hostConfig: { hosts: hostList = {} } = {}, hostConfig: { hosts: hostList = {} } = {},
networkConfig: { networkConfig: {
dnsCsv: rawDns, dnsCsv: rawDns,
mtu: rawMtu, mtu: rawMtu = 1500,
networks: networkList = {}, networks: networkList = {},
ntpCsv: rawNtp, ntpCsv: rawNtp,
} = {}, } = {},
@ -59,7 +59,10 @@ export const buildManifest = (
assert(REP_INTEGER.test(String(mtu)), `MTU must be an integer; got [${mtu}]`); assert(REP_INTEGER.test(String(mtu)), `MTU must be an integer; got [${mtu}]`);
const ntp = sanitize(rawNtp, 'string'); const ntp = sanitize(rawNtp, 'string');
if (ntp) {
assert(REP_IPV4_CSV.test(ntp), `NTP must be an IPv4 CSV; got [${ntp}]`); assert(REP_IPV4_CSV.test(ntp), `NTP must be an IPv4 CSV; got [${ntp}]`);
}
const prefix = sanitize(rawPrefix, 'string'); const prefix = sanitize(rawPrefix, 'string');
assert( assert(
@ -103,10 +106,13 @@ export const buildManifest = (
const networkId = `${networkType}${networkNumber}`; const networkId = `${networkType}${networkNumber}`;
const gateway = sanitize(rawGateway, 'string'); const gateway = sanitize(rawGateway, 'string');
if (networkType === 'ifn') {
assert( assert(
REP_IPV4.test(gateway), REP_IPV4.test(gateway),
`Gateway of ${networkId} must be an IPv4; got [${gateway}]`, `Gateway of ${networkId} must be an IPv4; got [${gateway}]`,
); );
}
const minIp = sanitize(rawMinIp, 'string'); const minIp = sanitize(rawMinIp, 'string');
assert( assert(

Loading…
Cancel
Save