Skip to content

Commit 06fab2c

Browse files
committed
fix(security): bump soupsieve and harden AMC students import
1 parent c160db4 commit 06fab2c

4 files changed

Lines changed: 28 additions & 11 deletions

File tree

‎examc_app/utils/amc/back/amc_layout_functions.py‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,10 @@
33
from dataclasses import dataclass, field
44
from pathlib import Path
55

6-
from PyPDF2 import PdfReader
6+
try:
7+
from pypdf import PdfReader
8+
except ImportError:
9+
from PyPDF2 import PdfReader
710
from django.db import transaction
811

912
from examc_app.models import (
@@ -607,4 +610,4 @@ def get_subject_copy_and_page_counts_from_xy(xy_path):
607610
"total_copies": max_copy,
608611
"pages_per_copy": max_page,
609612
"total_pages": max_copy * max_page,
610-
}
613+
}

‎examc_app/utils/amc_functions.py‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,10 @@
2121
import pandas as pd
2222
import xmltodict
2323
from PIL import Image
24-
from PyPDF2 import PdfReader, PdfWriter
24+
try:
25+
from pypdf import PdfReader, PdfWriter
26+
except ImportError:
27+
from PyPDF2 import PdfReader, PdfWriter
2528
from django.conf import settings
2629
from django.contrib.admin.utils import unquote
2730
from django.core.exceptions import ValidationError

‎examc_app/utils/review_functions.py‎

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,8 +141,19 @@ def import_scans(exam, path,delete_old,progress_recorder,process_count,process_n
141141
return result
142142

143143
def create_students_from_amc(exam):
144-
students_csv_file_path = get_amc_project_path(exam,False)+"/students.csv"
145-
if os.path.exists(students_csv_file_path):
144+
amc_project_path = get_amc_project_path(exam, False)
145+
if not amc_project_path:
146+
return
147+
148+
amc_root = pathlib.Path(settings.AMC_PROJECTS_ROOT).resolve()
149+
students_csv_file_path = (pathlib.Path(amc_project_path) / "students.csv").resolve()
150+
151+
try:
152+
students_csv_file_path.relative_to(amc_root)
153+
except ValueError:
154+
return
155+
156+
if students_csv_file_path.is_file():
146157
line_nr = 0
147158
headers = None
148159
with open(students_csv_file_path, newline='', encoding="utf-8") as csv_file:

‎requirements.txt‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ certifi==2025.7.14
1616
cffi==2.0.0
1717
chardet==5.2.0
1818
charset-normalizer==3.4.2
19-
click==8.2.1
19+
click==8.3.3
2020
click-didyoumean==0.3.1
2121
click-plugins==1.1.1.2
2222
click-repl==0.3.0
@@ -29,7 +29,7 @@ decorator==5.2.1
2929
defusedxml==0.7.1
3030
Deprecated==1.2.18
3131
diff-match-patch==20241021
32-
Django==5.2.15
32+
Django==5.2.16
3333
django-celery-beat==2.8.1
3434
django-constance==4.3.3
3535
django-crispy-forms==2.4
@@ -70,7 +70,7 @@ lxml==6.1.0
7070
MarkupSafe==3.0.2
7171
matplotlib==3.10.3
7272
matplotlib-inline==0.1.7
73-
mistune==3.2.1
73+
mistune==3.3.0
7474
mozilla-django-oidc==4.0.1
7575
mysqlclient==2.2.7
7676
narwhals==2.8.0
@@ -88,7 +88,7 @@ parso==0.8.4
8888
pexpect==4.9.0
8989
pickleshare==0.7.5
9090
pikepdf==9.10.2
91-
pillow==12.2.0
91+
pillow==12.3.0
9292
pipreqs==0.5.0
9393
platformdirs==4.3.8
9494
plotly==6.3.1
@@ -100,7 +100,7 @@ pycparser==2.22
100100
Pygments==2.20.0
101101
pypandoc==1.15
102102
pyparsing==3.2.3
103-
PyPDF2==3.0.1
103+
pypdf==6.14.2
104104
python-crontab==3.3.0
105105
python-dateutil==2.9.0.post0
106106
python-dotenv==1.2.2
@@ -120,7 +120,7 @@ setuptools==80.9.0
120120
shapely==2.1.1
121121
six==1.17.0
122122
snowballstemmer==3.0.1
123-
soupsieve==2.7
123+
soupsieve==2.8.4
124124
Sphinx==8.2.3
125125
sphinx-basic-ng==1.0.0b2
126126
sphinxcontrib-applehelp==2.0.0

0 commit comments

Comments
 (0)