Issues (563)

Security Analysis    not enabled

This project does not seem to handle request data directly as such no vulnerable execution paths were found.

  File Inclusion
File Inclusion enables an attacker to inject custom files into PHP's file loading mechanism, either explicitly passed to include, or for example via PHP's auto-loading mechanism.
  Regex Injection
Regex Injection enables an attacker to execute arbitrary code in your PHP process.
  SQL Injection
SQL Injection enables an attacker to execute arbitrary SQL code on your database server gaining access to user data, or manipulating user data.
  Response Splitting
Response Splitting can be used to send arbitrary responses.
  File Manipulation
File Manipulation enables an attacker to write custom data to files. This potentially leads to injection of arbitrary code on the server.
  Object Injection
Object Injection enables an attacker to inject an object into PHP code, and can lead to arbitrary code execution, file exposure, or file manipulation attacks.
  File Exposure
File Exposure allows an attacker to gain access to local files that he should not be able to access. These files can for example include database credentials, or other configuration files.
  XML Injection
XML Injection enables an attacker to read files on your local filesystem including configuration files, or can be abused to freeze your web-server process.
  Code Injection
Code Injection enables an attacker to execute arbitrary code on the server.
  Variable Injection
Variable Injection enables an attacker to overwrite program variables with custom data, and can lead to further vulnerabilities.
  XPath Injection
XPath Injection enables an attacker to modify the parts of XML document that are read. If that XML document is for example used for authentication, this can lead to further vulnerabilities similar to SQL Injection.
  Other Vulnerability
This category comprises other attack vectors such as manipulating the PHP runtime, loading custom extensions, freezing the runtime, or similar.
  Command Injection
Command Injection enables an attacker to inject a shell command that is execute with the privileges of the web-server. This can be used to expose sensitive data, or gain access of your server.
  LDAP Injection
LDAP Injection enables an attacker to inject LDAP statements potentially granting permission to run unauthorized queries, or modify content inside the LDAP tree.
  Cross-Site Scripting
Cross-Site Scripting enables an attacker to inject code into the response of a web-request that is viewed by other users. It can for example be used to bypass access controls, or even to take over other users' accounts.
  Header Injection
Unfortunately, the security analysis is currently not available for your project. If you are a non-commercial open-source project, please contact support to gain access.

app/Admin/Controllers/CodeTesterController.php (12 issues)

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
The type App\Admin\Controllers\Response was not found. Did you mean Response? If so, make sure to prefix the type with \.
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 ignore-type  annotation

25
        $content=$content->header(/** @scrutinizer ignore-type */ __('admin.tester.tester.header'));
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 ignore-type  annotation

26
        $content=$content->description(/** @scrutinizer ignore-type */ __('admin.tester.tester.description'));
Loading history...
27
        if (request()->isMethod('post')) {
28
            $content=$content->body($this->run());
29
        }
30
        return $content->body($this->form());
0 ignored issues
show
Bug Best Practice introduced by
The expression return $content->body($this->form()) returns the type Encore\Admin\Layout\Content which is incompatible with the documented return type App\Admin\Controllers\Response.
Loading history...
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 ignore-type  annotation

41
        $box=new Box(/** @scrutinizer ignore-type */ __('admin.tester.tester.title'));
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 ignore-type  annotation

44
            $box->content(/** @scrutinizer ignore-type */ __('admin.tester.help.installfirst'));
Loading history...
45
            return $box;
0 ignored issues
show
Bug Best Practice introduced by
The expression return $box returns the type Encore\Admin\Widgets\Box which is incompatible with the documented return type Encore\Admin\Widgets\Form.
Loading history...
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 ignore-type  annotation

50
        $form->select('oid', __('admin.tester.oj'))->options($OJ->pluck('name', 'oid'))->help(/** @scrutinizer ignore-type */ __('admin.tester.help.onlinejudge'))->rules('required');
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 ignore-type  annotation

62
        $box->content(/** @scrutinizer ignore-type */ $form);
Loading history...
63
        return $box;
0 ignored issues
show
Bug Best Practice introduced by
The expression return $box returns the type Encore\Admin\Widgets\Box which is incompatible with the documented return type Encore\Admin\Widgets\Form.
Loading history...
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 ignore-type  annotation

87
        $boxRun=new Box(/** @scrutinizer ignore-type */ __('admin.tester.tester.run'));
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
Bug Best Practice introduced by
The expression return $boxRun returns the type Encore\Admin\Widgets\Box which is incompatible with the documented return type App\Admin\Controllers\Response.
Loading history...
110
    }
111
}
112