Skip to content

v0.2

Choose a tag to compare

@bangetto bangetto released this 21 Aug 19:32
· 30 commits to master since this release
b7cfab0

This is a big update with a major security improvement and many breaking changes.

Breaking changes

  • Now Docker, Podman or an another container provider is required to run the API
  • The compilers and necessary libs are no longer required on the host machine, instead each language has one specialized and optimized OS defined with DockerFiles.
  • Breaking changes in config and in the response of /list

New config

  • First of all the version in the config now should be 0.2
  • The layout of how languages are defined had changed
    • The language field had moved out of the object to be the key used in instructions
    • The ability to add certain macros into the instructions had been removed
Old New
"instructions": [
        {
            "language": "cpp",
            "compileCodeCommand": "g++",
            "compilationArgs": [
                "${CODES_DIR}/${jobID}.cpp",
                "-o",
                "${OUTPUTS_DIR}/${jobID}.out"
            ],
            "executeCodeCommand": "${OUTPUTS_DIR}/${jobID}.out",
            "outputExt": "out",
            "compilerInfoCommand": "g++ --version"
        }
    ]
"instructions": {
        "cpp": {
            "preWarmCount": 3,
            "compileCodeCommand": "g++",
            "compilationArgs": [
                "main.cpp",
                "-o",
                "main.exe",
                "-O2"
            ],
            "executeCodeCommand": "./main.exe",
            "compilerInfoCommand": "g++ --version"
        }
    }

New /list format

  • This endpoint has been changed to use a similar structure as the updated config
"supportedLanguages": {
  "cpp": {
    "info": "<insert compiler info here>"
  }
}

Sandboxing

This is the main feature of this release, now instead of running the code on the host machine, exposing it to malicious code in the process, it will run it's own separated OS making it much harder to for users to infect the host machine.

Container Images

  • They should be located in CodeXX/sandboxes/<language>/DockerFile
  • They should be Linux based and should contain everything needed to compile and run a given language.
  • They should contain no CMD going on as that would shut down the container immediately after the execution of that command
  • They should include these:
    RUN mkdir /code
    WORKDIR /code
  • The containers needs to be built to an image using <docker/podman> build <language>-compile-run <path to directory the file is in>

New Config Options

  • Each language now has an optional preWarmedCount field
    • This field should be a positive number
    • It specifies the number of containers that should be already running (warmed up) for use by a request
    • Having this field can improve response times, but setting it too high will cause performance issues
  • The containerProvider field has been added which should be the name of your container provider used in the CLI (like docker or podman)
  • The containerProviderStartupCommand which should be the command that should be used if the container provider wasn't started

Code running flow

  1. Check if there's a pre-warmed container to use
  2. If no start a new one
  3. Copy the code file's folder to the container
  4. Compile the code (if needed)
  5. Run the code

This new structure makes adding side-files, memory limits much more feasible and are features that will definitely come in the future. 😉

Non-breaking internal changes

  • I/O operations has been made to not block incoming requests
  • One request would receive it's own temporary folder instead of just 1 input and 1 output file
  • More robust startup and shutdown actions
  • When running the tests the passed field will no longer compare the overly normalized versions of outputs

Full Changelog: v0.1.1...v0.2