Merge pull request #10667 from jumpserver/pr@dev@fix_login_regex_error

perf: 修复 正则匹配的 bug
pull/10672/head
老广 2023-06-09 18:35:23 +08:00 committed by GitHub
commit ba353271ad
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 1 deletions

View File

@ -468,7 +468,12 @@ class JSONManyToManyDescriptor:
elif rule_match == 'endswith':
res &= str(value).endswith(str(rule_value))
elif rule_match == 'regex':
res &= re.match(rule_value, value)
try:
matched = bool(re.match(rule_value, value))
except Exception as e:
logging.error('Error regex match: %s', e)
matched = False
res &= matched
elif rule_match == 'not':
res &= value != rule_value
elif rule['match'] == 'gte':