librenms /
librenmsv2
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.
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
| 1 | <?php |
||
| 2 | /* |
||
| 3 | * Copyright (C) 2016 Tony Murray <[email protected]> |
||
| 4 | * This program is free software: you can redistribute it and/or modify |
||
| 5 | * it under the terms of the GNU General Public License as published by |
||
| 6 | * the Free Software Foundation, either version 3 of the License, or |
||
| 7 | * (at your option) any later version. |
||
| 8 | * |
||
| 9 | * This program is distributed in the hope that it will be useful, |
||
| 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
||
| 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the |
||
| 12 | * GNU General Public License for more details. |
||
| 13 | * |
||
| 14 | * You should have received a copy of the GNU General Public License |
||
| 15 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
||
| 16 | */ |
||
| 17 | /** |
||
| 18 | * SettingsController.php |
||
| 19 | * |
||
| 20 | * @package LibreNMS |
||
| 21 | * @author Tony Murray <[email protected]> |
||
| 22 | * @copyright 2016 Tony Murray |
||
| 23 | * @license @license http://opensource.org/licenses/GPL-3.0 GNU Public License v3 or later |
||
| 24 | */ |
||
| 25 | |||
| 26 | namespace App\Http\Controllers; |
||
| 27 | |||
| 28 | use Illuminate\Http\Request; |
||
| 29 | use Input; |
||
| 30 | use Settings; |
||
| 31 | |||
| 32 | class SettingsController extends Controller |
||
| 33 | { |
||
| 34 | /** |
||
| 35 | * Display a listing of the resource. |
||
| 36 | * |
||
| 37 | * @return \Illuminate\Http\Response |
||
|
0 ignored issues
–
show
|
|||
| 38 | */ |
||
| 39 | public function index() |
||
| 40 | { |
||
| 41 | return view('settings.list'); |
||
| 42 | } |
||
| 43 | |||
| 44 | /** |
||
| 45 | * Show the form for creating a new resource. |
||
| 46 | * |
||
| 47 | * @return \Illuminate\Http\Response |
||
|
0 ignored issues
–
show
|
|||
| 48 | */ |
||
| 49 | public function create() |
||
| 50 | { |
||
| 51 | // |
||
| 52 | } |
||
| 53 | |||
| 54 | /** |
||
| 55 | * Store a newly created resource in storage. |
||
| 56 | * |
||
| 57 | * @param \Illuminate\Http\Request $request |
||
| 58 | * @return \Illuminate\Http\Response |
||
| 59 | */ |
||
| 60 | public function store(Request $request) |
||
| 61 | { |
||
| 62 | $key = Input::get('key'); |
||
| 63 | if (Settings::isReadOnly($key)) { |
||
| 64 | return response('Read only setting', 422); |
||
| 65 | } |
||
| 66 | |||
| 67 | $type = Input::get('type'); |
||
| 68 | $value = Input::get('value'); |
||
| 69 | |||
| 70 | if ($type == 'settings-value') { |
||
| 71 | Settings::set($key, $value); |
||
| 72 | return response('OK', 200); |
||
| 73 | } elseif ($type == 'settings-array') { |
||
| 74 | $current = Settings::get($key); |
||
| 75 | |||
| 76 | // remove entries with missing indexes |
||
| 77 | $delete = array_diff_key($current, $value); |
||
| 78 | foreach (array_keys($delete) as $index) { |
||
| 79 | Settings::forget($key.'.'.$index); |
||
| 80 | } |
||
| 81 | |||
| 82 | Settings::set($key, $value); |
||
| 83 | return response('OK', 200); |
||
| 84 | } |
||
| 85 | |||
| 86 | return response('Invalid Data', 422); |
||
| 87 | } |
||
| 88 | |||
| 89 | /** |
||
| 90 | * Display the specified resource. |
||
| 91 | * |
||
| 92 | * @param int $id |
||
| 93 | * @return \Illuminate\Http\Response |
||
|
0 ignored issues
–
show
|
|||
| 94 | */ |
||
| 95 | public function show($id) |
||
| 96 | { |
||
| 97 | return view('settings.list', ['section' => $id]); |
||
| 98 | } |
||
| 99 | |||
| 100 | /** |
||
| 101 | * Show the form for editing the specified resource. |
||
| 102 | * |
||
| 103 | * @param int $id |
||
| 104 | * @return \Illuminate\Http\Response |
||
|
0 ignored issues
–
show
|
|||
| 105 | */ |
||
| 106 | public function edit($id) |
||
| 107 | { |
||
| 108 | return view('settings.list', ['section' => $id]); |
||
| 109 | } |
||
| 110 | |||
| 111 | /** |
||
| 112 | * Update the specified resource in storage. |
||
| 113 | * |
||
| 114 | * @param \Illuminate\Http\Request $request |
||
| 115 | * @param int $id |
||
| 116 | * @return \Illuminate\Http\Response |
||
|
0 ignored issues
–
show
|
|||
| 117 | */ |
||
| 118 | public function update(Request $request, $id) |
||
| 119 | { |
||
| 120 | // |
||
| 121 | } |
||
| 122 | |||
| 123 | /** |
||
| 124 | * Remove the specified resource from storage. |
||
| 125 | * |
||
| 126 | * @param int $id |
||
| 127 | * @return \Illuminate\Http\Response |
||
|
0 ignored issues
–
show
|
|||
| 128 | */ |
||
| 129 | public function destroy($id) |
||
| 130 | { |
||
| 131 | Settings::forget($id); |
||
| 132 | } |
||
| 133 | } |
||
| 134 |
This check compares the return type specified in the
@returnannotation of a function or method doc comment with the types returned by the function and raises an issue if they mismatch.