Skip to content

Commit

Permalink
Fix hashlib usage by setting usedforsecurity=False
Browse files Browse the repository at this point in the history
  • Loading branch information
movchan74 committed Jan 22, 2024
1 parent 27b26ef commit 541ca8f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 3 additions & 1 deletion aana/tests/test_video.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,9 @@ def test_download_video():

# Test Youtube URL
youtube_url = "https://www.youtube.com/watch?v=dQw4w9WgXcQ"
youtube_url_hash = hashlib.md5(youtube_url.encode()).hexdigest() # noqa: S324
youtube_url_hash = hashlib.md5(
youtube_url.encode(), usedforsecurity=False
).hexdigest()
video_dir = settings.video_dir
expected_path = video_dir / f"{youtube_url_hash}.webm"
# remove the file if it exists
Expand Down
4 changes: 3 additions & 1 deletion aana/utils/video.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,9 @@ def download_video(video_input: VideoInput | Video) -> Video:
return video_input
if video_input.url is not None:
video_dir = settings.video_dir
url_hash = hashlib.md5(video_input.url.encode()).hexdigest() # noqa: S324
url_hash = hashlib.md5(
video_input.url.encode(), usedforsecurity=False
).hexdigest()

# we use yt_dlp to download the video
# it works not only for youtube videos, but also for other websites and direct links
Expand Down

0 comments on commit 541ca8f

Please sign in to comment.