fleet/frontend/pages/hosts/ManageHostsPage/helpers.ts

24 lines
837 B
TypeScript
Raw Normal View History

export const isAcceptableStatus = (filter: string): boolean => {
return (
filter === "new" ||
filter === "online" ||
filter === "offline" ||
filter === "missing"
);
};
export const isValidPolicyResponse = (filter: string): boolean => {
return filter === "pass" || filter === "fail";
};
// Performs a grossly oversimplied validation that subject string includes substrings
// that would be expected in a textual encoding of a certificate chain per the PEM spec
// (see https://datatracker.ietf.org/doc/html/rfc7468#section-2)
// Consider using a third-party library if more robust validation is desired
export const isValidPemCertificate = (cert: string): boolean => {
const regexPemHeader = /-----BEGIN/;
const regexPemFooter = /-----END/;
return regexPemHeader.test(cert) && regexPemFooter.test(cert);
};