-
Notifications
You must be signed in to change notification settings - Fork 301
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Development
: Improve background image input validation
#7170
Development
: Improve background image input validation
#7170
Conversation
Development
: Improved input validation.
Development
: Improved input validation.Development
: Improve background image input validation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Due to the changes, some import quiz exercise tests from QuizExerciseIntegrationTest
seem to fail with Status response 500 now.
I am guessing this is because they use images with invalid paths. Additionally, could you move the two new tests into QuizExerciseIntegrationTest
since quiz import is already tested there? Alternatively, you could move the existing quiz import tests into the new class, but then make sure to keep it package-private (see Codacy and failing architecture test).
…ontains("files/temp").
…ePathElseThrow method from QuizExerciseImportTest.java to QuizExerciseIntegrationTest.java.
Fixed in: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Works on ts1
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Testing Session TS1
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tested in testing session on TS1. We tested
- normal quiz creation with background image
- exam quiz creation with background image
- importing those quiz exercises (exam and non-exam)
- importing whole exams
The images were always intact and available, also in the student view.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Manual test on TS1
Drag and drop worked in all places
src/main/java/de/tum/in/www1/artemis/service/QuizExerciseImportService.java
Outdated
Show resolved
Hide resolved
src/main/java/de/tum/in/www1/artemis/service/QuizExerciseImportService.java
Outdated
Show resolved
Hide resolved
src/main/java/de/tum/in/www1/artemis/service/QuizExerciseImportService.java
Outdated
Show resolved
Hide resolved
src/main/java/de/tum/in/www1/artemis/service/QuizExerciseImportService.java
Outdated
Show resolved
Hide resolved
src/main/java/de/tum/in/www1/artemis/service/QuizExerciseImportService.java
Outdated
Show resolved
Hide resolved
src/test/java/de/tum/in/www1/artemis/exercise/quizexercise/QuizExerciseIntegrationTest.java
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tested in a testing session everything worked so far.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code: As @julian-christl mentioned, the paths to check are actually URL paths relative to the domain, so we should not use File
utils to check them. Also, I found one other place in the code where it might sense to introduce a similar check.
src/main/java/de/tum/in/www1/artemis/service/QuizExerciseImportService.java
Outdated
Show resolved
Hide resolved
963d701
…tService.java Co-authored-by: Julian Christl <[email protected]>
2. Rename sanitizeByCheckingIfPathContainsSubPathElseThrow to sanitizeByCheckingIfPathStartsWithSubPathElseThrow.
src/main/java/de/tum/in/www1/artemis/service/QuizExerciseImportService.java
Outdated
Show resolved
Hide resolved
Co-authored-by: Lucas Welscher <[email protected]>
Co-authored-by: Julian Christl <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now that looks good. Thank you.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code LGTM 👍🏻 Change works on TS4
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The code looks really solid now! I also manually tested the upload on TS4 again.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code looks good to me
Development
: Improve background image input validation.Development
: Improve background image input validation
Checklist
General
Server
Changes affecting Programming Exercises
Motivation and Context
Several endpoints in the classes ExamResource, ExerciseGroupResource and QuizExerciseResource do not sanitise the background file path of imported quiz exercises, which can lead to path traversal when being used without sanatisation.
Description
We now:
/api/files/drag-and-drop/backgrounds
Steps for Testing
Prerequisites:
Exam Mode Testing
Prerequisites:
Review Progress
Performance Review
Code Review
Manual Tests
Exam Mode Test
Test Coverage