Skip to content

Commit

Permalink
bugfix: Added timeout to mitigate ReDoS issue
Browse files Browse the repository at this point in the history
  • Loading branch information
GaiZhenbiao committed Sep 18, 2024
1 parent 56fc993 commit fcdd5fd
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
4 changes: 2 additions & 2 deletions modules/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@
import csv
import threading
import requests
import re
import hmac
import html
import hashlib

import gradio as gr
import regex as re
import getpass
from pypinyin import lazy_pinyin
import tiktoken
Expand Down Expand Up @@ -511,7 +511,7 @@ def init_history_list(user_name="", prepend=None):
def filter_history(user_name, keyword):
history_names = get_history_names(user_name)
try:
history_names = [name for name in history_names if re.search(keyword, name)]
history_names = [name for name in history_names if re.search(keyword, name, timeout=0.01)]
return gr.update(choices=history_names)
except:
return gr.update(choices=history_names)
Expand Down
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,4 @@ Pillow>=10.1.0
protobuf==3.20.3
ollama>=0.1.6
numexpr
regex

0 comments on commit fcdd5fd

Please sign in to comment.