Skip to content
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

Code beautifier #321

Open
franekwitt opened this issue Jan 17, 2024 · 4 comments
Open

Code beautifier #321

franekwitt opened this issue Jan 17, 2024 · 4 comments

Comments

@franekwitt
Copy link

Feature request: "Beautify Code" button in the submission view.
This feature would be beneficial during the manual inspection of suspected plagiarism submissions.

I can implement it but right now I'm not really sure how to approach it. The two main approaches are:

  1. Server-side formatting.
    a) It may create a RCE / DDOS vulnerability if ran without a siojail.

b) Running the formatter in siojail every time somebody requests a formatted view probably has too big overhead. Maybe we could run it once (with reasonable time limit) and store the formatted code in the DB but that would double the disk space taken by submissions.

c) One way to mitigate this would be to lazily generate formatted copy after the first formatted view request and then store it in the DB. However that would mean one can submit a lot of codes during long period of time and then request their formatted versions at once leading to DOS.

I believe that if we decide to do the formatting server-side we will need to restrict it to admins/teachers (that would fix only c) and not a) and b) ).

  1. Client-side formatting.
    Maintaining its javascript dependencies might turn out to be tricky.
    One example of such a formatter is https://prismjs.com/ however it uses web assembly.
@MasloMaslane
Copy link
Member

Does prismjs support beautifying? I think it’s just a syntax highlighter

@MasloMaslane
Copy link
Member

MasloMaslane commented Jan 17, 2024

I think that using prettier would be a good solution. It’s possible to run it on the client-side: https://prettier.io/docs/en/browser

@MasloMaslane
Copy link
Member

Never mind, prettier doesn’t support cpp and python

@MasloMaslane
Copy link
Member

There are wasm based formaters: https://github.com/wasm-fmt/clang-format
and
https://github.com/wasm-fmt/ruff_fmt

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants