forked from farhoodlabs/paperclip
fix(plugin): restrict kubernetes cilium cidr egress
This commit is contained in:
@@ -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);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user