-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1289 from proditis/speed-programming
Speed programming module
- Loading branch information
Showing
55 changed files
with
2,705 additions
and
222 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
FROM buildpack-deps:buster-curl | ||
LABEL maintainer="echothrust solutions <[email protected]>" | ||
LABEL description="Speed Programming Validation Container" | ||
|
||
|
||
ENV DEBIAN_FRONTEND noninteractive | ||
COPY --chown=root:root scripts /usr/local/validators | ||
COPY --chown=root:root entrypoint.sh / | ||
WORKDIR /echoctf | ||
RUN set -ex \ | ||
&& apt-get update \ | ||
&& apt-get install --no-install-recommends -y default-jre default-jdk build-essential wget python3 gcc git gzip socat netcat-openbsd python2 \ | ||
&& chmod 0500 /entrypoint.sh /usr/local/validators/* | ||
|
||
|
||
ENTRYPOINT ["/entrypoint.sh"] | ||
CMD ["bash"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
# Validator image example |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#!/bin/bash | ||
if [ "$FETCH_URL"x == "x" ] || [ "$VALIDATE_LANG"x == "x" ]; then | ||
echo "Error: FETCH_URL or VALIDATE_LANG env variable not set"; | ||
exit 1 | ||
fi | ||
|
||
wget -O /echoctf/script_to_validate."${VALIDATE_LANG}" "${FETCH_URL}" | ||
|
||
|
||
if [ -x /usr/local/validators/${VALIDATE_LANG}_validator ]; then | ||
/usr/local/validators/${VALIDATE_LANG}_validator | ||
fi | ||
$@ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#!/bin/bash | ||
|
||
echo "Validating c..." | ||
gcc /echoctf/script_to_validate.c -o /echoctf/submission | ||
|
||
timeout 1 bash -c "echo \"TEST1\"|/echoctf/submission" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#!/bin/bash | ||
|
||
echo "Validating cpp..." | ||
g++ /echoctf/script_to_validate.cpp -o /echoctf/submission | ||
|
||
timeout 1 bash -c "echo \"TEST1\"|/echoctf/submission" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
#!/bin/bash | ||
|
||
echo "Validating java..." | ||
timeout 1 bash -c "echo \"TEST1\"|java /echoctf/script_to_validate.java" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#!/bin/bash | ||
|
||
echo "Validating php7..." | ||
|
||
|
||
echo "TEST1"|timeout 1 php7 /echoctf/script_to_validate.php7 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
#!/usr/bin/python2 | ||
|
||
print "Validating py2..." |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
#!/usr/bin/python3 | ||
|
||
print "Validating py3..." |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
backend/migrations-init/m241105_111349_add_speed_programming_url_routes.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<?php | ||
|
||
use yii\db\Migration; | ||
|
||
/** | ||
* Class m241105_111349_add_speed_programming_url_routes | ||
*/ | ||
class m241105_111349_add_speed_programming_url_routes extends Migration | ||
{ | ||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function safeUp() | ||
{ | ||
$this->upsert('url_route', ['source' => 'speed', 'destination' => 'speedprogramming/default/index'], true); | ||
$this->upsert('url_route', ['source' => 'speed/<id:\d+>', 'destination' => 'speedprogramming/default/view'], true); | ||
$this->upsert('url_route', ['source' => 'speed/<id:\d+>/answer', 'destination' => 'speedprogramming/default/answer'], true); | ||
$this->upsert('sysconfig', ['id' => 'module_speedprogramming_disabled', 'val' => 1], true); | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function safeDown() | ||
{ | ||
$this->delete('url_route', ['source' => 'speed',]); | ||
$this->delete('url_route', ['source' => 'speed/<id:\d+>']); | ||
$this->delete('url_route', ['source' => 'speed/<id:\d+>/answer']); | ||
} | ||
} |
37 changes: 37 additions & 0 deletions
37
backend/migrations/m241105_014128_create_speed_problem_table.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
<?php | ||
|
||
use yii\db\Migration; | ||
|
||
/** | ||
* Handles the creation of table `{{%speed_problem}}`. | ||
*/ | ||
class m241105_014128_create_speed_problem_table extends Migration | ||
{ | ||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function safeUp() | ||
{ | ||
$this->createTable('{{%speed_problem}}', [ | ||
'id' => $this->primaryKey(), | ||
'name' => $this->string(), | ||
'description' => $this->text(), | ||
'active' => $this->boolean()->notNull()->defaultValue(1), | ||
'difficulty' => $this->smallInteger()->notNull()->defaultValue(0), | ||
'category' => $this->string(64), | ||
'server' => $this->string(), | ||
'challenge_image' => $this->string(), | ||
'validator_image' => $this->string(), | ||
'created_at' => $this->datetime(), | ||
'updated_at' => $this->datetime(), | ||
]); | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function safeDown() | ||
{ | ||
$this->dropTable('{{%speed_problem}}'); | ||
} | ||
} |
106 changes: 106 additions & 0 deletions
106
backend/migrations/m241105_014129_create_speed_solution_table.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
<?php | ||
|
||
use yii\db\Migration; | ||
|
||
/** | ||
* Handles the creation of table `{{%speed_solution}}`. | ||
*/ | ||
class m241105_014129_create_speed_solution_table extends Migration | ||
{ | ||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function safeUp() | ||
{ | ||
$this->createTable('{{%speed_solution}}', [ | ||
'id' => $this->primaryKey(), | ||
'player_id' => $this->integer()->unsigned()->notNull(), | ||
'problem_id' => $this->integer()->notNull(), | ||
'language' => $this->string(), | ||
'sourcecode' => 'LONGBLOB', | ||
'status' => $this->string(), | ||
'points' => $this->integer()->defaultValue(0), | ||
'created_at' => $this->datetime(), | ||
'updated_at' => $this->datetime(), | ||
]); | ||
|
||
// creates index for column `player_id` | ||
$this->createIndex( | ||
'{{%idx-speed_solution-player_id}}', | ||
'{{%speed_solution}}', | ||
'player_id' | ||
); | ||
|
||
// add foreign key for table `{{%player}}` | ||
$this->addForeignKey( | ||
'{{%fk-speed_solution-player_id}}', | ||
'{{%speed_solution}}', | ||
'player_id', | ||
'{{%player}}', | ||
'id', | ||
'CASCADE' | ||
); | ||
|
||
// creates index for column `problem_id` | ||
$this->createIndex( | ||
'{{%idx-speed_solution-problem_id}}', | ||
'{{%speed_solution}}', | ||
'problem_id' | ||
); | ||
|
||
// add foreign key for table `{{%speed_problem}}` | ||
$this->addForeignKey( | ||
'{{%fk-speed_solution-problem_id}}', | ||
'{{%speed_solution}}', | ||
'problem_id', | ||
'{{%speed_problem}}', | ||
'id', | ||
'CASCADE' | ||
); | ||
|
||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function safeDown() | ||
{ | ||
// drops foreign key for table `{{%player}}` | ||
$this->dropForeignKey( | ||
'{{%fk-speed_solution-player_id}}', | ||
'{{%speed_solution}}' | ||
); | ||
|
||
// drops index for column `player_id` | ||
$this->dropIndex( | ||
'{{%idx-speed_solution-player_id}}', | ||
'{{%speed_solution}}' | ||
); | ||
|
||
// drops foreign key for table `{{%team}}` | ||
$this->dropForeignKey( | ||
'{{%fk-speed_solution-team_id}}', | ||
'{{%speed_solution}}' | ||
); | ||
|
||
// drops index for column `team_id` | ||
$this->dropIndex( | ||
'{{%idx-speed_solution-team_id}}', | ||
'{{%speed_solution}}' | ||
); | ||
|
||
// drops foreign key for table `{{%target}}` | ||
$this->dropForeignKey( | ||
'{{%fk-speed_solution-target_id}}', | ||
'{{%speed_solution}}' | ||
); | ||
|
||
// drops index for column `target_id` | ||
$this->dropIndex( | ||
'{{%idx-speed_solution-target_id}}', | ||
'{{%speed_solution}}' | ||
); | ||
|
||
$this->dropTable('{{%speed_solution}}'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<?php | ||
|
||
namespace app\modules\speedprogramming; | ||
|
||
/** | ||
* speedprogramming module definition class | ||
*/ | ||
class Module extends \yii\base\Module | ||
{ | ||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public $controllerNamespace='app\modules\speedprogramming\controllers'; | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function init() | ||
{ | ||
parent::init(); | ||
|
||
// custom initialization code goes here | ||
} | ||
} |
Oops, something went wrong.