ZsgsDesign /
NOJ
This project does not seem to handle request data directly as such no vulnerable execution paths were found.
include, or for example
via PHP's auto-loading mechanism.
| 1 | <?php |
||||
| 2 | |||||
| 3 | namespace App\Admin\Controllers; |
||||
| 4 | |||||
| 5 | use App\Http\Controllers\Controller; |
||||
| 6 | use Encore\Admin\Layout\Content; |
||||
| 7 | use App\Models\Eloquent\OJ; |
||||
| 8 | use App\Models\Eloquent\Problem; |
||||
| 9 | use App\Models\Eloquent\Compiler; |
||||
| 10 | use Encore\Admin\Widgets\Form; |
||||
| 11 | use Encore\Admin\Widgets\Box; |
||||
| 12 | use Encore\Admin\Widgets\Table; |
||||
| 13 | use App\Babel\Babel; |
||||
| 14 | use Arr; |
||||
| 15 | |||||
| 16 | class CodeTesterController extends Controller |
||||
| 17 | { |
||||
| 18 | /** |
||||
| 19 | * Show the Testing Page. |
||||
| 20 | * |
||||
| 21 | * @return Response |
||||
|
0 ignored issues
–
show
Bug
introduced
by
Loading history...
|
|||||
| 22 | */ |
||||
| 23 | public function tester(Content $content) |
||||
| 24 | { |
||||
| 25 | $content=$content->header(__('admin.tester.tester.header')); |
||||
|
0 ignored issues
–
show
It seems like
__('admin.tester.tester.header') can also be of type array and array; however, parameter $header of Encore\Admin\Layout\Content::header() does only seem to accept string, maybe add an additional type check?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||
| 26 | $content=$content->description(__('admin.tester.tester.description')); |
||||
|
0 ignored issues
–
show
It seems like
__('admin.tester.tester.description') can also be of type array and array; however, parameter $description of Encore\Admin\Layout\Content::description() does only seem to accept string, maybe add an additional type check?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||
| 27 | if (request()->isMethod('post')) { |
||||
| 28 | $content=$content->body($this->run()); |
||||
| 29 | } |
||||
| 30 | return $content->body($this->form()); |
||||
|
0 ignored issues
–
show
|
|||||
| 31 | } |
||||
| 32 | |||||
| 33 | /** |
||||
| 34 | * Make a form builder. |
||||
| 35 | * |
||||
| 36 | * @return Form |
||||
| 37 | */ |
||||
| 38 | protected function form() |
||||
| 39 | { |
||||
| 40 | $OJ=OJ::where(["ocode"=>"noj"])->get(); |
||||
| 41 | $box=new Box(__('admin.tester.tester.title')); |
||||
|
0 ignored issues
–
show
It seems like
__('admin.tester.tester.title') can also be of type array and array; however, parameter $title of Encore\Admin\Widgets\Box::__construct() does only seem to accept string, maybe add an additional type check?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||
| 42 | if (blank($OJ)) { |
||||
| 43 | $box->style('danger'); |
||||
| 44 | $box->content(__('admin.tester.help.installfirst')); |
||||
|
0 ignored issues
–
show
It seems like
__('admin.tester.help.installfirst') can also be of type array and array; however, parameter $content of Encore\Admin\Widgets\Box::content() does only seem to accept string, maybe add an additional type check?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||
| 45 | return $box; |
||||
|
0 ignored issues
–
show
|
|||||
| 46 | } |
||||
| 47 | $oid=$OJ->first()->oid; |
||||
| 48 | $box->style('success'); |
||||
| 49 | $form=new Form(); |
||||
| 50 | $form->select('oid', __('admin.tester.oj'))->options($OJ->pluck('name', 'oid'))->help(__('admin.tester.help.onlinejudge'))->rules('required'); |
||||
|
0 ignored issues
–
show
It seems like
__('admin.tester.help.onlinejudge') can also be of type array and array; however, parameter $text of Encore\Admin\Form\Field::help() does only seem to accept string, maybe add an additional type check?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||
| 51 | $form->select('pid', __('admin.tester.pid'))->options(Problem::where(["OJ"=>$oid])->get()->sortBy('readable_name')->pluck('readable_name', 'pid'))->rules('required'); |
||||
| 52 | $form->select('coid', __('admin.tester.coid'))->options(Compiler::where(["oid"=>$oid])->get()->pluck('display_name', 'coid'))->rules('required'); |
||||
| 53 | $form->textarea('solution', __('admin.tester.solution'))->rows(20)->rules('required'); |
||||
| 54 | $form->action(route('admin.codetester.tester')); |
||||
| 55 | $form->fill([ |
||||
| 56 | 'oid'=>request()->oid, |
||||
| 57 | 'pid'=>request()->pid, |
||||
| 58 | 'coid'=>request()->coid, |
||||
| 59 | 'solution'=>request()->solution, |
||||
| 60 | ]); |
||||
| 61 | $form->method('POST'); |
||||
| 62 | $box->content($form); |
||||
|
0 ignored issues
–
show
$form of type Encore\Admin\Widgets\Form is incompatible with the type string expected by parameter $content of Encore\Admin\Widgets\Box::content().
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||
| 63 | return $box; |
||||
|
0 ignored issues
–
show
|
|||||
| 64 | } |
||||
| 65 | |||||
| 66 | /** |
||||
| 67 | * Running Test. |
||||
| 68 | * |
||||
| 69 | * @return Response |
||||
| 70 | */ |
||||
| 71 | protected function run() |
||||
| 72 | { |
||||
| 73 | $babel=new Babel(); |
||||
| 74 | request()->validate([ |
||||
| 75 | 'oid' => 'required|integer', |
||||
| 76 | 'pid' => 'required|integer', |
||||
| 77 | 'coid' => 'required|integer', |
||||
| 78 | 'solution' => 'required', |
||||
| 79 | ]); |
||||
| 80 | $runner=$babel->testrun([ |
||||
| 81 | 'name' => 'noj', |
||||
| 82 | 'pid' => request()->pid, |
||||
| 83 | 'coid' => request()->coid, |
||||
| 84 | 'solution' => request()->solution, |
||||
| 85 | ]); |
||||
| 86 | $verdict=$runner->verdict; |
||||
| 87 | $boxRun=new Box(__('admin.tester.tester.run')); |
||||
|
0 ignored issues
–
show
It seems like
__('admin.tester.tester.run') can also be of type array and array; however, parameter $title of Encore\Admin\Widgets\Box::__construct() does only seem to accept string, maybe add an additional type check?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||
| 88 | $boxRun->style('info'); |
||||
| 89 | $verdictData=[]; |
||||
| 90 | foreach ($verdict['data'] as $v) { |
||||
| 91 | $verdictData[]=[ |
||||
| 92 | $v["test_case"], |
||||
| 93 | $v["cpu_time"], |
||||
| 94 | $v["real_time"], |
||||
| 95 | $v["memory"], |
||||
| 96 | $v["signal"], |
||||
| 97 | $v["exit_code"], |
||||
| 98 | $v["error"], |
||||
| 99 | $v["result"], |
||||
| 100 | ]; |
||||
| 101 | } |
||||
| 102 | $table=new Table(['Test Case', 'CPU Time(ms)', 'Real Time(ms)', 'Memory(byte)', 'Signal', 'Exit Code', 'Error', 'Result'], $verdictData); |
||||
| 103 | $output="<p>Verdict: {$verdict['verdict']}</p>"; |
||||
| 104 | if (!blank($verdict['compile_info'])) { |
||||
| 105 | $output.="<p>Compiler Info:</p><pre>".htmlspecialchars($verdict['compile_info'])."</pre>"; |
||||
| 106 | } |
||||
| 107 | $output.=$table->render(); |
||||
| 108 | $boxRun->content($output); |
||||
| 109 | return $boxRun; |
||||
|
0 ignored issues
–
show
|
|||||
| 110 | } |
||||
| 111 | } |
||||
| 112 |