From a777772f13e61be6e181aead4a842b9d9c8dd654 Mon Sep 17 00:00:00 2001 From: rabbitali Date: Thu, 21 Dec 2023 11:42:37 +0800 Subject: [PATCH] Add IPV4 validation method --- 0001-update-ValidateRules.patch | 45 +++++++++++++++++++++++++++++++++ aops-vulcanus.spec | 8 ++++-- 2 files changed, 51 insertions(+), 2 deletions(-) create mode 100644 0001-update-ValidateRules.patch diff --git a/0001-update-ValidateRules.patch b/0001-update-ValidateRules.patch new file mode 100644 index 0000000..da3be63 --- /dev/null +++ b/0001-update-ValidateRules.patch @@ -0,0 +1,45 @@ +From 77f2c6a864baac31d7e6b4bee924dad82214092c Mon Sep 17 00:00:00 2001 +From: rabbitali +Date: Wed, 20 Dec 2023 15:37:29 +0800 +Subject: [PATCH] update ValidateRules + +--- + vulcanus/restful/serialize/validate.py | 14 ++++++++++++-- + 1 file changed, 12 insertions(+), 2 deletions(-) + +diff --git a/vulcanus/restful/serialize/validate.py b/vulcanus/restful/serialize/validate.py +index d6eacbe..3050693 100644 +--- a/vulcanus/restful/serialize/validate.py ++++ b/vulcanus/restful/serialize/validate.py +@@ -64,7 +64,7 @@ class ValidateRules: + """ + validation rules for username, which only contains string or number + """ +- if not re.findall("[a-zA-Z0-9]{5,20}", string): ++ if not re.findall("^[a-zA-Z0-9]{5,20}$", string): + raise ValidationError("username should only contains string or number, between 5 and 20 characters!") + + @staticmethod +@@ -72,8 +72,18 @@ class ValidateRules: + """ + validation rules for password, which only contains string or number + """ +- if not re.findall("[a-zA-Z0-9]{6,20}", string): ++ if not re.findall("^[a-zA-Z0-9]{6,20}$", string): + raise ValidationError("password should only contains string or number, between 6 and 20 characters!!") ++ ++ @staticmethod ++ def ipv4_address_check(string: str): ++ """ ++ validation rules for IPV4 address ++ """ ++ ipv4_address_pattern = r"^((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$" ++ if not re.findall(ipv4_address_pattern, string): ++ raise ValidationError("Not a valid IPV4 address.") ++ + + + class PaginationSchema(Schema): +-- +2.33.0 + diff --git a/aops-vulcanus.spec b/aops-vulcanus.spec index 1b107dc..9123a6c 100644 --- a/aops-vulcanus.spec +++ b/aops-vulcanus.spec @@ -1,10 +1,11 @@ Name: aops-vulcanus Version: v1.3.1 -Release: 1 +Release: 2 Summary: A basic tool libraries of aops, including logging, configure and response, etc. License: MulanPSL2 URL: https://gitee.com/openeuler/%{name} Source0: %{name}-%{version}.tar.gz +Patch0001: 0001-update-ValidateRules.patch @@ -31,7 +32,7 @@ tools for aops, it's about aops deploy %prep -%autosetup -n %{name}-%{version} +%autosetup -n %{name}-%{version} -p1 # build for aops-vulcanus @@ -61,6 +62,9 @@ cp -r scripts %{buildroot}/opt/aops/ %changelog +* Thu Dec 21 2023 wenxin - v1.3.1-2 +- add IPV4 validation method to ValidateRules + * Mon Dec 18 2023 gongzhengtang - v1.3.1-1 - Optimize paging statistics and software dependency versions -- Gitee