Giter VIP home page Giter VIP logo

launchtestrun's Introduction

LaunchTestRun

A platform that lets you submit and test code snippets online for practice.

Dependencies

LaunchTestRun depends on the following software to run:

  • Apache Tomcat 8.5.33 or higher
  • Java 1.8 or higher
  • GCC 5 or higher
  • Python 2
  • Python 3
  • Mono .NET

To install these packages on Ubuntu or Debian, please run the following commands:

To install the required toolchains, run

sudo apt-get update
sudo apt-get install default-jre default-jdk build-essential python2 python3 mono-devel

Installation

  1. If you would like to build from source, continue to step 2. Otherwise, copy the .WAR file in release/ to the webapps/ directory in your Apache Tomcat server (if you used the previous steps Tomcat should be installed in ~/LaunchTestRun), and skip to step 5.
  2. Import this as an Eclipse Dynamic Web Project.
  3. Export the project into a .WAR named LaunchTestRun.war.
  4. Move the .WAR file into your Apache Tomcat server, in the webapps/ directory.
  5. Replace bin/catalina.sh in your Apache Tomcat installation with the catalina.sh in this directory (Patches issues with Java 9 and Tomcat 8).
  6. Make the shell scripts in the bin/ directory in your Tomcat installation executable by running chmod +x *.sh in the bin/ directory of your Tomcat installation..
  7. Run bin/startup.sh in your Tomcat installation directory to start LaunchTestRun.

Securing your setup

If you would like more security on your LaunchTestRun installation (strongly recommended as others will be running code on your server!), you should create a new user that only has permissions to run and access the files within the Tomcat installation directory. To secure your setup, after running bin/startup.sh the first time after moving the .WAR file, run the following commands (replace all text in brackets with locations applicable to your specific installation) :

su root
chmod 755 [ YOUR TOMCAT DIRECTORY HERE ] -R
cd [ YOUR TOMCAT DIRECTORY HERE ]
useradd launchtestrun
mkdir work
touch webapps/LaunchTestRun/forensics.txt
chown launchtestrun:launchtestrun -R work
chown launchtestrun:launchtestrun -R logs
chown launchtestrun:launchtestrun -R webapps/LaunchTestRun
chown launchtestrun:launchtestrun -R webapps/LaunchTestRun/upload
chown launchtestrun:launchtestrun -R webapps/LaunchTestRun/forensics.txt

After setting these permissions, when starting the LaunchTestRun server, switch to the launchtestrun user before running startup.sh with the following commands:

su launchtestrun
cd [ YOUR TOMCAT DIRECTORY HERE ]/bin
./startup.sh

To view a forensic log of all the files uploaded and executed (containing IP, input, output, MD5 hash, time uploaded, etc), view webapps/LaunchTestRun/forensics.txt.

Setup

NOTE: It is recommended to initalize a git repository in webapps/LaunchTestRun/problems so that problems can be remotely uploaded, edited and reverted if needed.

  1. If you haven't installed the LaunchTestRun server before reading this step, please refer back to Running and follow the instructions.
  2. To add a custom problem, go into your Apache Tomcat server directory, and go to webapps/LaunchTestRun/problems inside your Apache Tomcat directory. Create a new directory with the following structure:
[+] Name of problem
 |- config.json
 |- judge.in
 |- judge.out
 |- sample.in
 |- sample.out

config.json should contain the following data:

{
	"cpid":"12345",
	"title":"Sample Tile 1",
	"description":"Test Problem Description",
	"pdf":"http://www.pdfsite.org/files/test.pdf",
	"setinfo":"Fall Competition 2019",
	"samplein":"sample.in",
	"sampleout":"sample.out",
	"judgein":"judge.in",
	"judgeout":"judge.out",
	"inputname":"input.txt",
	"timeout":"2000"
}

Where:

  • cpid is the ID # for the problem you want to define.
  • title is the title for the problem you want to define.
  • description is the description for the problem you want to define.
  • pdf is the URL link to the PDF file that you want to be displayed with the problem.
  • setinfo is the information about the problem set that the problem you want to define comes from.
  • samplein is the name of the sample input file. (The input given to the user-uploaded program)
  • sampleout is the name of the sample output file. (The output expected for the input)
  • judgein is the name of the judge input file. (The input given to the user-uploaded program)
  • judgeout is the name of the judge output file. (The output expected for the input)
  • inputname is the name of the input file that the user-uploaded program will read, that the sample/judge input file will be renamed to.
  • timeout is an integer defining the number of milliseconds that the program will be alloted to execute before a forced termination.
  1. To set the locations of the compilers, you can edit webapps/LaunchTestRun/settings.json, which contains the paths that LaunchTestRun will look for the compilers in.

Using

The LaunchTestRun server can be accessed by default from: http://127.0.0.1:8080/LaunchTestRun/index.html/ after it is configured with Tomcat in the previous sections. A list of problems added can be accessed by default from: http://127.0.0.1:8080/LaunchTestRun/listproblems.html/.

launchtestrun's People

Contributors

drdab avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

d-e-f-e-a-t

launchtestrun's Issues

Use HashMap for problem mapping

If a HashMap was to be used to map the problems complementing the ArrayList current used, it would be more efficient to reference problems. (Efficiency will go from O(n) worst-case to O(1) to access each problem).

Add forensic traceback

It may be a good idea to add a forensic identifier to each submission and logging to identify the source of bugs and malicious attacks on a LaunchTestRun server. This should consist of a general log containing the IP address, time uploaded, code sent, execution time and stdin/out/err output from the code and compiler. That way, the sources of issues can be pinpointed faster by the sysadmin.

Request Limiter

A good idea would be to add a subsystem that limits the number code submission requests, to prevent exhaustion of resources. This system should grab the IP of the user submitting the code, and if it hasn't seen that IP yet, then save that IP to a list that is cleared every minute. Each time that upload is done again, it should increment the count of uploads that IP has done. Once the user has attempted to submit more than 6 uploads per minute, then uploads from that IP will be temporarily blocked until the next minute. Something like that could also be used, with a JSessionID cookie instead, for a "xx users online" counter.

Add delay timer

A timer should be added to force termination of program after 2 seconds if the program does not execute, whether it has finished or not. That way, if a program is too slow or keeps waiting for standard input, it won't eat up CPU time for long.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.