fix(plugin): restrict kubernetes cilium cidr egress

This commit is contained in:
Dotta
2026-05-12 17:30:56 -05:00
committed by Chris Farhood
parent 45621aac53
commit c37e5919ce
4 changed files with 32 additions and 2 deletions
@@ -56,5 +56,6 @@ describe("buildCiliumNetworkPolicyManifest", () => {
});
const cidrRule = cnp.spec.egress.find((e: { toCIDRSet?: { cidr: string }[] }) => e.toCIDRSet);
expect(cidrRule.toCIDRSet[0].cidr).toBe("10.0.0.0/8");
expect(cidrRule.toPorts).toEqual([{ ports: [{ port: "443", protocol: "TCP" }] }]);
});
});
@@ -36,4 +36,12 @@ describe("kubernetesProviderConfigSchema", () => {
parseKubernetesProviderConfig({ inCluster: true, egressAllowCidrs: ["not-a-cidr"] }),
).toThrow(/CIDR/i);
});
it("rejects CIDRs with invalid octets or prefixes", () => {
for (const cidr of ["999.0.0.0/8", "10.0.0.0/99", "10.0.0/24"]) {
expect(() =>
parseKubernetesProviderConfig({ inCluster: true, egressAllowCidrs: [cidr] }),
).toThrow(/CIDR/i);
}
});
});