Commit Graph

20 Commits

Author SHA1 Message Date
Tony Murray
e990dfcb35
Disable plugins that have errors (#14383)
* Disable plugins that have errors
Disable plugin if a hook throws an error and set a notification
Move notification code to class, so we can access it
Clear notification when plugin is attempted to be enabled again

* fix style and lint fixes

* another lint fix and handle if property is missing
2022-09-25 22:47:58 -05:00
Jellyfrog
797d73ad16
Misc errors cleanup (#14257)
* Misc errors cleanup

* Rename the variable in the loop to match

Co-authored-by: Tony Murray <murraytony@gmail.com>
2022-08-30 09:00:12 -05:00
Kevin Zink
98ed6bb9dc
New plugin system based on Laravel Package Development (#12998)
* use Blade view and Eloquent models for plugins

* move views

* fix style

* fix style

* revert mistake

* Update Plugin.php

delete test property "name"

* rename plugin function to settings

* last but not least - rename in Test.php

* Rename Test to Example

* fix typo

* fix style

* fix style

* fix style

* fix style - I hate tabs...

* Extract view calls

* fix method calls and style

* Move Models the the abstract class

* fix style

* Convert to traits

* Change the Example description

* Fix style

* Fix style

* Fix style

* Convert plugin function to Model static methods and delete .inc.php

* fix style

* fix style

* Use scope

* final methods blows up legacy code

* Config > \LibreNMS\Config

* convert the static string to a static method

* Correct placement in the page

* fix tabs

* fix style

* Rename from tait to hook

to make it easier to understand and be complient

* rename file

* Typo

* Started to change the docu

* change to a more usefully Device_Overview example

* and activate of course

* PluginManager

* fix .gitignore

* only php files in the root folder

* corrected .gitignore with all files :)

* Rename the Hooks and ExampleClass for better readability

* Fix style

* Fix style

* Exception handling (especially if DB is not present)

* Fix style and update schema

* fix indentation

* actually correct indent

* fix migration collation check include utf8mb4_bin

* stop phpstan whining

* A view lines documentation

* add typeHints

* Allow return null on handle

* lint

* fix return types

* fix logic of column collation check

* Fix MenuEntryHook

* switch to longtext instead of json type for now :D

* try phpstan on PHP 7.3

* set phpstan target version to 7.3

* all the typehints

* optional

* more

* Use namespace to prevent view collisions
disambiguate plugin and hook
no magic guessing of names in PluginManager, bad assumptions
remove unused plugins from the DB

* cleanup plugin menu

* cleanup on shutdown and ignore but log query error on cleanup

* instanceof must be called against an instance

* Allow multiple hooks per plugin

* Port plugin ui code to Laravel

* page instead of settings for v1 plugins

* actually working settings pages
a little url cleanup plugin/admin -> plugin/settings

* fix style

* Add page hook

* PHPstan

* Try to fix Illuminate\Http\RedirectResponse

* typehint

* Rewrite the doc

* Fix style

Co-authored-by: PipoCanaja <38363551+PipoCanaja@users.noreply.github.com>
Co-authored-by: Tony Murray <murraytony@gmail.com>
2021-10-19 06:53:28 -05:00
Jellyfrog
258505ed44
Apply fixes from StyleCI (#13224) 2021-09-10 20:09:53 +02:00
Jellyfrog
26b95c0ccc
Apply fixes from StyleCI (#13208) 2021-09-08 23:35:56 +02:00
Jellyfrog
edb36fd69d
More cleanups (#12715)
* PHPDoc

* Replace Auth > Illuminate\Support\Facades\Auth

* Return inside when()

* use str_replace correct

* Misc

* dead code

* use int $port

* styleci
2021-04-08 08:14:49 -05:00
Jellyfrog
20b4215204
Swich links to https (#12511)
* Switch librenms links to https

* Convert librenms links in comments

* Switch gnu.org url to https

* switch php urls to https
2021-02-09 00:29:04 +01:00
Jellyfrog
0d56bbd946
Apply fixes from StyleCI (#12123) 2020-09-21 15:51:53 +02:00
Jellyfrog
77c531527c
Apply fixes from StyleCI (#12117)
* Apply fixes from StyleCI

* Disable style check
2020-09-21 14:54:51 +02:00
Tony Murray
750b19f3e8
Fix issue when non-existent plugin is enabled (#10699) 2019-10-16 21:18:17 +00:00
Tony Murray
8cc988a162
Fix plugins menu (#10222)
* Merge pull request #54 from librenms-plugins/revert-52-PluginNamespaceCorrection

Revert "Adding namespace LibreNMS\Plugins;"
Fix plugins menu

* Only use scrollable where needed
2019-05-13 14:53:29 -05:00
Tony Murray
36431dd296
Security fix: unauthorized access (#10091)
* Security fix: unauthorized access
Affects nginx users:
Moved php files outside of public html directory (Apache was protected by .htaccess)

Affects all users:
Some files did not check for authentication and could disclose some info.
Better checks before including files from user input

* git mv html/includes/ includes/html
git mv html/pages/ includes/html/
2019-04-11 23:26:42 -05:00
Tony Murray
8bddfe7225 Fixed plugins using d_echo (#9498)
Move d_echo to helpers.php and include in autoload
Don't remove from common.php yet to be extra safe.
2018-12-08 13:16:49 +00:00
Tony Murray
483c931e3d
Fix plugin loading (#8917)
* Fix plugin loading
class_exists was loading the including the files, then we included it again.
Mostly, just include -> include_once is the fix.

* fix style

* forgot to update docblock
2018-07-17 13:55:23 -05:00
Daryl Peterson
67c585b7c0 PSR-4 Plugin Support (#8880)
Add phpdocblocks Plugins.php
Add psr-4 plugins path to composer.json

Changes to be committed:
	modified:   LibreNMS/Plugins.php
	modified:   composer.json
2018-07-17 07:46:49 -05:00
PipoCanaja
5c83d438c5 feature: Added plugin support in the Port page (#8665)
* Added new plugin menu_option in the "port" page, which contain hook calling public function port_container($device, $port) in plugins

* Cleaning after pre-commit error

* New method in Plugins.php to allow counting all plugins implementing a specific hook. This allow conditionnal display of the plugin menu_option in the port view.

* Typo after rebase

* Update plugins.inc.php

* Updating the documentation with device_overview_container and port_container hooks.
2018-05-22 08:11:27 +01:00
Tony Murray
54aa0a4df4 Ignore plugin hook calling errors (#8693)
Mostly this is because the plugin methods aren't static.
2018-05-11 15:40:45 +01:00
Tony Murray
1ad7f3138b
Add Laravel to LibreNMS (#8318)
* Add Laravel to LibreNMS.

* Try to set permissions during initial install and first composer update to Laravel.

* Fix composer.lock
Fix missing db config keys

* Start building v1 layout
Port ajax_setresolution, inject csrf into jquery ajax calls
Layout works, building menu
Partially done.

* Fix device group list
remove stupid count relationships

* Print messages for common boot errors.
Don't log to laravel.log file.
Log to error_log until booted, then librenms.log

* Fix up some issues with Config loading
Start of custom directives

* Custom blade directives: config, notconfig, admin

* Preflight checks
Only load config files once.

* Update the composer.lock for php 5.6

* Menu through routing

* Start of alert menu

* Better alert scopes

* reduce cruft in models

* Alerting menu more or less working :D

* Fix style

* Improved preflight

* Fix chicken-eggs!

* Remove examples

* Better alert_rule status queries
Debugbar

* fix app.env check

* User Menu

* Settings bar (dropped refresh)
Search JS

* Toastr messages

* Rename preflight

* Use hasAccess(User) on most models.
Add port counts

* Missed a Preflight -> Checks rename

* Fix some formatting

* Boot Eloquent outside of Laravel
Use Eloquent for Config and Plugins so we don't have to connect with dbFacile inside Laravel.
Move locate_binary() into Config class

* Config WIP

* Try to fix a lot of config loading issues.

* Improve menu for non-admins removing unneeded menus
url() for all in menu

* Only use eloquent if it exists

* Include APP_URL in initial .env settings

* Implement Legacy User Provider

* Helper class for using Eloquent outside of Laravel.
Allows access to DB style queries too and checking the connection status.

* Fix up tests

* Fix device groups query

* Checking Travis

* copy config.test.php earlier

* dbFacile check config before connecting
Don't use exception to check if eloquent is connected, it gets grabbed by the exception handler.
Ignore missing config.php error.

* Fix config load with database is not migrated yet.

* Remove Config::load() from early boot.

* Use laravel config settings to init db (this prefers .env settings)
Fix bgp vars not set in menu
add _ide_helper.php to .gitignore

* Restrict dependencies to versions that support php 5.6

* Update ConfigTest

* Fix a couple of installation issues

* Add unique NODE_ID to .env

* Correct handling of title image

* Fix database config not loading. Thanks @laf

* Don't prepend /

* add class_exists checks for development service providers

* Fix config value casting

* Don't use functions that may not exist

* Update dbFacile.php

* d_echo may not be defined when Config used called.

* Add SELinux configuration steps
More detailed permissions check.
Check all and give complete corrective commands in one step.

* Ignore node_modules directory

* Re-add accidetal removal
2018-05-09 08:05:17 -05:00
Tony Murray
122aae85bf webui: Relocate Alerts menu
Plugins menu is moved to the Overview menu (this is basically just weathermap anyway)
2016-09-11 23:41:41 -05:00
Tony Murray
b8e9b2d917 Implement an autoloader (#4140)
* Implement an autoloader

When cleaning up classes for psr2, things got a bit unwieldy, so I implemented a class autoloader.
I created a PSR-0 compliant LibreNMS directory and moved all classes there that made sense.
Implemented LibreNMS\ClassLoader which supports adding manual class mappings

This reduces the file includes needed and only loads classes when needed.

* Add teh autoloader to graph.php

* Add a small bit of docs
Fix incomplete class in includes/discovery/functions.inc.php
2016-08-21 14:07:14 +01:00