!67 [sync] PR-66: Add IPV4 validation method
From: @openeuler-sync-bot Reviewed-by: @zhu-yuncheng Signed-off-by: @zhu-yuncheng
This commit is contained in:
commit
b28ea577a5
45
0001-update-ValidateRules.patch
Normal file
45
0001-update-ValidateRules.patch
Normal file
@ -0,0 +1,45 @@
|
||||
From 77f2c6a864baac31d7e6b4bee924dad82214092c Mon Sep 17 00:00:00 2001
|
||||
From: rabbitali <wenxin32@foxmail.com>
|
||||
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
|
||||
|
||||
@ -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<wenxin32@foxmail.com> - v1.3.1-2
|
||||
- add IPV4 validation method to ValidateRules
|
||||
|
||||
* Mon Dec 18 2023 gongzhengtang<gong_zhengtang@163.com> - v1.3.1-1
|
||||
- Optimize paging statistics and software dependency versions
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user