fix: hardening
This commit is contained in:
168 files changed
+9166
-1644
No files matched your search
@@ -2,8 +2,31 @@
|
||||
{ lib }:
|
||||
let
|
||||
inherit (lib) mkOption types;
|
||||
|
||||
octet = "(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9])";
|
||||
ipv4 = "(${octet}\\.){3}${octet}";
|
||||
ipv4Prefix = "/(3[0-2]|[12]?[0-9])";
|
||||
# Loose on the groups (nft and ip reject a malformed one), strict on the characters.
|
||||
ipv6 = "[0-9A-Fa-f]{0,4}(:[0-9A-Fa-f]{0,4}){2,7}(:${ipv4})?";
|
||||
ipv6Prefix = "/(12[0-8]|1[01][0-9]|[1-9]?[0-9])";
|
||||
# A readable name in docs and errors in place of the pattern.
|
||||
matching =
|
||||
description: pattern:
|
||||
types.strMatching pattern
|
||||
// {
|
||||
inherit description;
|
||||
};
|
||||
in
|
||||
{
|
||||
# Interface names, addresses and CIDRs go into nft rules and scripts as they are: catch
|
||||
# typos early. An interface name is the kernel's (15 bytes at most), no leading "." or "-".
|
||||
interfaceType = matching "network interface name" "[A-Za-z0-9_][A-Za-z0-9_.+-]{0,14}";
|
||||
ipv4CidrType = matching "IPv4 CIDR" "${ipv4}${ipv4Prefix}";
|
||||
ipv6CidrType = matching "IPv6 CIDR" "${ipv6}${ipv6Prefix}";
|
||||
addressOrCidrType = matching "IPv4 or IPv6 address or CIDR" "(${ipv4}(${ipv4Prefix})?|${ipv6}(${ipv6Prefix})?)";
|
||||
# A listen address: an IP or a host name.
|
||||
hostType = matching "IP address or host name" "[A-Za-z0-9._:-]+";
|
||||
|
||||
list =
|
||||
description: example:
|
||||
mkOption {
|
||||
|
||||
Reference in new issue
Block a user