[pbs-devel] [PATCH proxmox-backup v3 2/4][optional] pbs-api-types: make regex for ciphers more strict
Hannes Laimer
h.laimer at proxmox.com
Sat Jan 8 08:08:07 CET 2022
Signed-off-by: Hannes Laimer <h.laimer at proxmox.com>
---
if applied should be squashed with patch 0001
pbs-api-types/src/lib.rs | 30 ++++++++++++++++++++++++++++--
1 file changed, 28 insertions(+), 2 deletions(-)
diff --git a/pbs-api-types/src/lib.rs b/pbs-api-types/src/lib.rs
index b4882064..8ad9f23a 100644
--- a/pbs-api-types/src/lib.rs
+++ b/pbs-api-types/src/lib.rs
@@ -100,6 +100,20 @@ mod local_macros {
macro_rules! DNS_ALIAS_NAME {
() => (concat!(r"(?:(?:", DNS_ALIAS_LABEL!() , r"\.)*", DNS_ALIAS_LABEL!(), ")"))
}
+ macro_rules! TLS_CIPHERSUITE_RE {
+ () => (
+ r"TLS_AES_256_GCM_SHA384|TLS_CHACHA20_POLY1305_SHA256|TLS_AES_128_GCM_SHA256|TLS_AES_128_CCM_8_SHA256|TLS_AES_128_CCM_SHA256"
+ )
+ }
+ macro_rules! OPENSSL_CIPHER_STRING_RE {
+ () => (concat!(
+ r"([!\-+]?(COMPLEMENTOFDEFAULT|ALL|COMPLEMENTOFALL|HIGH|MEDIUM|LOW|[ae]?NULL|[ka]?RSA|",
+ "kDH[rdE]?|kEDH|DHE?|EDH|ADH|kEECDH|kECDHE|ECDH|ECDHE|EECDH|AECDH|a?DSS|aDH|a?ECDSA|",
+ "SSLv3|AES(128|256)?|GCM|AESGCM|AESCCM|AESCCM8|ARIA(128|256)?|CAMELLIA(128|256)?|",
+ "CHACHA20|3?DES|RC[24]|IDEA|SEED|MD5|SHA(1|256|384)?|aGOST(01)?|kGOST|GOST94|GOST89MAC|",
+ "[ak]?PSK|kECDHEPSK|kDHEPSK|kRSAPSK|SUITEB(128|128ONLY|192)?|CBC3?|POLY1305))+"
+ ))
+ }
}
const_regex! {
@@ -124,9 +138,21 @@ const_regex! {
pub FINGERPRINT_SHA256_REGEX = r"^(?:[0-9a-fA-F][0-9a-fA-F])(?::[0-9a-fA-F][0-9a-fA-F]){31}$";
- pub OPENSSL_CIPHER_LIST_REGEX = r"^[A-Za-z0-9!\-+=@, :]+$";
+ pub OPENSSL_CIPHER_LIST_REGEX = concat!(
+ r"^((",
+ OPENSSL_CIPHER_STRING_RE!(),
+ ")([: ,](",
+ OPENSSL_CIPHER_STRING_RE!(),
+ "))*)$"
+ );
- pub TLS_CIPHERSUITE_LIST_REGEX = r"^[A-Za-z0-9_:]+$";
+ pub TLS_CIPHERSUITE_LIST_REGEX = concat!(
+ r"^((",
+ TLS_CIPHERSUITE_RE!(),
+ ")(:(",
+ TLS_CIPHERSUITE_RE!(),
+ "))*)$"
+ );
/// Regex for safe identifiers.
///
--
2.30.2
More information about the pbs-devel
mailing list