63 Commits

Author SHA1 Message Date
Jellyfrog
77fa7573cf Revert "Convert Config to a singleton (#16349)" (#16382)
This reverts commit f1e7a218f0.
2024-09-10 09:59:20 +02:00
Tony Murray
f1e7a218f0 Convert Config to a singleton (#16349)
* Convert Config to a singleton
Continuation of #14364 by @Jellyfrog
This time, make the old class a shim for the facade.  Will update references in a separate PR.

* Remove logging config call

* Apply fixes from StyleCI

* Fix bad Git constructor call

* Fail on config table does not exist instead of throw exception

* Inline LibrenmsConfig::isRegistered()

* Debug call in case there are more issues,
remove before merge.

* Fix up config tests

* Allow config cache controlled by CONFIG_CACHE_TTL (disabled by default for now)

* Enable config cache for tests

* Remove debug statement and deprecation phpdoc

* Apply fixes from StyleCI

---------

Co-authored-by: Tony Murray <murrant@users.noreply.github.com>
2024-09-09 18:48:07 +02:00
Jellyfrog
071ca9bc2a Apply fixes from StyleCI (#15698)
Co-authored-by: StyleCI Bot <bot@styleci.io>
2024-01-04 22:39:12 -06:00
Tony Murray
4211b1c46f Remove unused functions (#15371)
* Remove unused functions
inline other legacy functions

* Apply fixes from StyleCI

---------

Co-authored-by: StyleCI Bot <bot@styleci.io>
2023-10-04 10:17:34 -05:00
Tony Murray
2cd207028a Implement RBAC (only built in roles) (#15212)
* Install bouncer

* Seeder and level migration

* Display and edit roles

* remove unused deluser page

* Update Radius and SSO to assign roles

* update AlertUtil direct level check to use roles instead

* rewrite ircbot auth handling

* Remove legacy auth getUserlist and getUserlevel methods, add getRoles
Set roles in LegacyUserProvider

* Small cleanups

* centralize role sync code
show roles on user preferences page

* VueSelect component WIP and a little docs

* WIP

* SelectControllers id and text fields.

* LibrenmsSelect component extracted from SettingSelectDynamic

* Handle multiple selections

* allow type coercion

* full width settings

* final style adjustments

* Final compiled assets update

* Style fixes

* Fix SSO tests

* Lint cleanups

* small style fix

* don't use json yet

* Update baseline for usptream package issues

* Change schema, not 100% sure it is correct
not sure why xor doesn't work
2023-08-28 00:13:40 -05:00
Jellyfrog
2b3575a5e9 Laravel 10.x Shift (#14995)
* Apply code style

* Remove explicit call to register policies

* Shift core files

* Shift config files

* Default config files

In an effort to make upgrading the constantly changing config files
easier, Shift defaulted them and merged your true customizations -
where ENV variables may not be used.

* Bump Laravel dependencies

* Add type hints for Laravel 10

* Shift cleanup

* wip

* wip

* sync translation

* Sync back config

* Public Path Binding

* QueryException

* monolog

* db::raw

* monolog

* db::raw

* fix larastan collections

* fix phpstan bug looping forever

* larastan errors

* larastan: fix column type

* styleci

* initialize array

* fixes

* fixes

---------

Co-authored-by: Shift <shift@laravelshift.com>
2023-05-24 22:21:54 +02:00
Olen
7ec37561c5 Ensure irc fifo-file is shared between dispatcher and core containers (#14647)
* Ensure fifo-file is shared between dispatcher container and core container

* Fix config path
2023-04-28 09:03:24 -05:00
Jellyfrog
68e0b3df28 Apply fixes from StyleCI (#14899)
Co-authored-by: StyleCI Bot <bot@styleci.io>
2023-03-13 22:32:22 +01:00
Olen
339e3c28be Add a few breaks to avoid connection flooding for the irc-bot (#14479)
* Add a few breaks to avoid connection flooding

Adding a few sleep()s in the connection loop to avoid connection flooding on errors.

* Add lost bracket

* Add linebreaks to please StyleCi

* More Ci
2022-10-25 16:10:35 -05:00
Tony Murray
e4451714e2 version and git helper improvements (#14412)
* Fix up version and git helpers
Improve method names
Move all git calls into the git helper
Allow runtime and external cache of results where appropriate
Consolidate version headers for discovery, poller, and validate

* Style fixes

* improve consistency in git calls

* fix style

* don't send name inconsistently

* Improve database versions

* No need to cache Version it is not used more than once currently.
2022-10-02 00:41:56 -05:00
Tony Murray
014213680f Move Config loading to a service provider (#13927)
* Move Config loading to a service provider
That way other service providers can depend on it
Move various random listener registrations into the EventServiceProvider
Various startup cleanup

* Config::persist Set live variable before persisting incase db update fail

* Disable strict mode for legacy code (init.php)

* Disable debug after os test data is gathered

* remove Eloquent::boot it is never used

* remove Eloquent::version

* lint fixes

* style fixes

* there is no c_echo here
2022-04-22 19:12:07 -05:00
Jellyfrog
e873768845 Bump larastan (#13071)
* Bump larastan

* Use php7.4 for lint test
2021-07-26 09:00:34 -05:00
Tony Murray
4f7c7b3f2a PHP dependencies update (#13034)
* Removing dnoegel/php-xdg-base-dir (v0.1.1)

barryvdh/laravel-debugbar (v3.5.2 => v3.6.2)
barryvdh/laravel-ide-helper (v2.9.1 => v2.10.0)
composer/ca-bundle (1.2.9 => 1.2.10)
composer/composer (2.0.13 => 2.1.3)
composer/semver (3.2.4 => 3.2.5)
composer/xdebug-handler (1.4.6 => 2.0.1)
dapphp/radius (2.5.4 => 2.5.5)
doctrine/annotations (1.12.1 => 1.13.1)
doctrine/cache (1.10.2 => 2.0.3)
doctrine/dbal (2.13.0 => 2.13.2)
facade/flare-client-php (1.5.0 => 1.8.1)
facade/ignition (2.7.0 => 2.10.2)
fakerphp/faker (v1.14.1 => v1.15.0)
filp/whoops (2.12.0 => 2.13.0)
friendsofphp/php-cs-fixer (v2.18.4 => v2.19.0)
fruitcake/laravel-cors (v2.0.3 => v2.0.4)
guzzlehttp/psr7 (1.8.1 => 2.0.0)
laravel/dusk (v6.15.0 => v6.15.1)
laravel/framework (v8.40.0 => v8.49.2)
laravel/ui (v3.2.0 => v3.3.0)
league/commonmark (1.5.8 => 1.6.5)
league/flysystem (1.1.3 => 1.1.4)
monolog/monolog (2.2.0 => 2.3.0)
nesbot/carbon (2.46.0 => 2.50.0)
nikic/php-parser (v4.10.4 => v4.11.0)
nunomaduro/collision (v5.3.0 => v5.5.0)
nunomaduro/larastan (v0.7.4 => v0.7.10)
php-parallel-lint/php-parallel-lint (v1.2.0 => v1.3.0)
php-webdriver/webdriver (1.10.0 => 1.11.1)
phpseclib/phpseclib (3.0.7 => 3.0.9)
phpstan/phpstan (0.12.83 => 0.12.92)
phpstan/phpstan-mockery (0.12.13 => 0.12.14)
phpunit/phpunit (9.5.4 => 9.5.6)
predis/predis (v1.1.6 => v1.1.7)
psr/cache (1.0.1)
psr/http-factory (1.0.1)
psr/log (1.1.3 => 1.1.4)
psy/psysh (v0.10.7 => v0.10.8)
rmccue/requests (v1.8.0 => v1.8.1)
sebastian/global-state (5.0.2 => 5.0.3)
sebastian/type (2.3.1 => 2.3.4)
symfony/console (v5.2.6 => v5.3.2)
symfony/css-selector (v5.2.4 => v5.3.0)
symfony/debug (v4.4.20 => v4.4.25)
symfony/error-handler (v5.2.6 => v5.3.3)
symfony/event-dispatcher (v5.2.4 => v5.3.0)
symfony/filesystem (v5.2.6 => v5.3.3)
symfony/finder (v5.2.4 => v5.3.0)
symfony/http-foundation (v5.2.4 => v5.3.3)
symfony/http-kernel (v5.2.6 => v5.3.3)
symfony/mime (v5.2.6 => v5.3.2)
symfony/options-resolver (v5.2.4 => v5.3.0)
symfony/polyfill-ctype (v1.22.1 => v1.23.0)
symfony/polyfill-iconv (v1.22.1 => v1.23.0)
symfony/polyfill-intl-grapheme (v1.22.1 => v1.23.0)
symfony/polyfill-intl-idn (v1.22.1 => v1.23.0)
symfony/polyfill-intl-normalizer (v1.22.1 => v1.23.0)
symfony/polyfill-mbstring (v1.22.1 => v1.23.0)
symfony/polyfill-php72 (v1.22.1 => v1.23.0)
symfony/polyfill-php73 (v1.22.1 => v1.23.0)
symfony/polyfill-php80 (v1.22.1 => v1.23.0)
symfony/process (v5.2.4 => v5.3.2)
symfony/routing (v5.2.6 => v5.3.0)
symfony/stopwatch (v5.2.4 => v5.3.0)
symfony/string (v5.2.6 => v5.3.3)
symfony/translation (v5.2.6 => v5.3.3)
symfony/var-dumper (v5.2.6 => v5.3.3)
symfony/yaml (v4.4.21 => v4.4.26)

* add ignores
2021-07-13 17:41:04 -05:00
Jellyfrog
a8c8a9a4a2 Misc cleanup (#12758)
* Fix Docblock

* Misc

* Parameter #2 $callback of function array_filter expects (callable(mixed, mixed): bool)|null, 'strlen' given

* Parameter #2 $data of function hash_hmac expects string, int given

* Unreachable statement - code above always terminates.

* Update Device.php
2021-04-20 12:47:22 +02:00
Jellyfrog
58af994c6b Linting (#12677)
* Fix Canopsis Transport

* Lint Hipchat

* Lint IRCBot.php

* Misc

* Update Hipchat.php

* Update Notification.php
2021-03-31 17:29:22 +02:00
Jellyfrog
6c59f368b0 Linting: Fix misc problems (#12675) 2021-03-29 17:43:05 -05:00
Tony Murray
1c379dcd05 Remove legacy function calls (#12651)
* massive inlines

* fix style and wtf

* remove rrdtool.inc.php include

* fix CommonFunctions namespace issues

* looking for missing class space, fix undefined class issues

* style fixes
2021-03-29 00:25:30 +02: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
Olen
4bdcb7d88e IRC Adding floodcontrol. Better alerts (#12141)
* Adding floodcontrol. Better alerts

* Code cleanup

* Code cleanup take 2

* Deduplicate code for sending alerts

* Keeping PRs in sync

* this->sendAlert...

* Allow filtering by hostname in ".log" command

* StyleCI

* StyleCI
2020-11-23 00:35:19 -06:00
RobJE
e52531fba4 Ircbot fix (#12192)
* send alert to channel, do not send channel key

* correct indentation, use spaces not tab
2020-10-06 21:07:49 +02:00
Olen
ba636e9617 IRC Add simple tag-parsing of colors and highlights in alerts (#12138)
* Add simple tag-parsing of colors and highlights in alerts

* Fixing a few CodeClimate-issues

* Fixing a missing ;

* Fixing some more typography

* Whitespace...

* Deduplicate code

* Missing ; - too much python lately...

* Fix end of function name

* Simplifying sendAlert a bit

* Keeping up with PR#12141

* ; again...

* this->sendAlert...
2020-10-02 07:54:12 -05:00
Olen
a8ca361acd Add missing setting of channels to join (#12160) 2020-09-29 23:12:09 -05:00
Olen
aada69cd64 IRC Add more logging and debug info (#12140)
* Add more logging and debug info

* Code cleanup

* Code cleanup take two
2020-09-23 13:38:42 +02:00
Olen
0f272e342e IRC: Don't set nick on each tick (#12139)
* Trying harder to regain nick

* Code cleanup

* remove extra nickchange
2020-09-22 19:29:54 +02:00
Jellyfrog
41729d72eb Apply fixes from StyleCI (#12142) 2020-09-22 14:48:51 +02:00
Olen
944d7c9ef9 List external commands in help. Allow reload of external commands (#12137) 2020-09-22 14:34:01 +02:00
Olen
4023baf899 Increase the read-buffer as 64 bytes can be a little small (#12136) 2020-09-22 14:32:08 +02:00
Olen
9abec91cfd Remove unused "irc_chan". Renamed to "irc_alert_chan" (#12135) 2020-09-22 14:31:39 +02:00
Olen
19aaf43605 Add some variables to the init of the class (#12134) 2020-09-22 14:30:54 +02:00
Jellyfrog
29f45ca352 Apply fixes from StyleCI (#12124) 2020-09-21 15:59:34 +02:00
Jellyfrog
77c531527c Apply fixes from StyleCI (#12117)
* Apply fixes from StyleCI

* Disable style check
2020-09-21 14:54:51 +02:00
SourceDoctor
b89eb22cd5 Enumerate AlertState (#11665)
* Enumerate AlertState

* fix typo

* add missing use's

* .

* .
2020-05-23 21:14:36 -05:00
Jellyfrog
b361710148 Device group based access (#10568)
* Device group based access

* Use Permissions class to resolve permissions

Also give port access based on device access

* Convert more pages to use Permissions class

* shorten config setting name
use Eloquent relationships in several places
alphabetize config_definitions.json

* Change Models and Permissions

* Clean up ajax_search LIMIT sql

* Convert more pages to use Permissions class

Co-authored-by: Tony Murray <murraytony@gmail.com>
2019-12-30 12:11:26 +01:00
Tony Murray
699aa8a042 Consolidate configuration settings and implement dynamic webui settings (#9809)
* initial db/defaults dump

* numeric values

* Remove $config['time']

* Use config_definitions.json

* try setting definition as a complete array

* a little more

* fix format

* WIP converting dynamic setting pages

* rewriting the webui

* remove legacy and add translations

* finish email section

* improve navigation
update js a bit

* Import the remaining existing settings

* Update backend still some wip
migration

* fix config loading (db not overriding defaults)

* some cleanup

* more array collapsing

* update settings

* Settings search

* add purge settings to ui, order groups and sections

* collapse more arrays

* Auth definitions WIP

* remove needless slash escapes

* add warning to json

* moving settings from defaults.inc

* remove slow_statistics

* Move rrdtool settings to the poller section

* Use translations more consistently

* removing more settings from defaults.inc.php

* show setting name in tooltip

* allow help text to be shown on mobile

* disable settings that are set in config.php

* Implement undo and reset to default.

* Vue.js functional

* Vue.js WIP

* Implement tabs component

* accordion WIP

* lodash ver update

* two items

* Accordion somewhat working

* hash navigation

* Refine Accordion

* Fix up tab styling a bit

* Cleaner tab selected property
Hide html while loading

* spinner?

* Icon support
property for accordion to active

* WIP

* Tabs/Sections from ajax

* Setting Component skeletons

* Dynamic Component resolution

* Basic functionality

* toggle class

* Refactor components

* translate tabs and accordions

* simple array attempt

* improve readonly tooltip

* array styling

* array value editing

* organize snmp info

* Handle initial tab/section in url

* Use Laravel to parse tab/section, dump old

* Draggable array entries

* v-tooltip, for clickable (and touch) help tooltips
disable draggable

* Navigation WIP

* Navigation WIP

* groups computed

* filter settings

* fix event reference

* vue.js i18n initial

* missing description = just setting name

* en fallback

* tidy up the language support and js generation

* persist value to db

* fix issue with 0

* Delete settings from DB instead of setting them to default

* ldap-groups
fixup style

* Default dashboard selection

* fix array of options instead of object

* allow custom validation for settings

* translate options in SettingSelect

* SNMP v3 WIP

* fix setting arrays

* Split persist out of set

* Hook up events for SNMP v3 Auth
correct Config::persist behaviour with arrays

* dependent settings (primitive for now)
actually update the settings values in the LibrenmsSettings component

* more complex "when" behaviour

* remove un-needed seeder

* add poller_modules.cisco-qfp

* remove en.json (disable warning)

* don't set default for log_dir or log_file, otherwise it won't be processed correctly

* Fix module order
add some missing settings

* more config corrections

* correct graphs
correct loading values set to null (although it should have no difference)
remove project_name_version

* Add nfsen settings.  Docs are very confusing, so might have flubbed something
remove option for array definition of select option as numeric indexes messes it up

* Correct more upstream config differences

* Config cleanup after a bunch of merges.

* Fixes

* add version tags to js/css files
remove old js

* Print out full settings list read-only

* Add http_proxy setting
fix indents in config_definitions.json

* repeaters default is 0 (aka 20)

* cleanups

* rewrite the dynamic config docs

* add language docs

* Don't show snmp v3 auth add/remove if disabled by config.php
2019-10-16 21:22:05 +00:00
Tony Murray
63442e8b4a Refactor tests (#10625)
* Refactor tests
Boot Laravel for all tests.
Config use private static property for storage instead of global

* Backup/restore modules

* disable snmpsim log

* Fixing DBTestCase

* Fix macros loading to the wrong place

* trap and other tests should check if db is available

* don't include snmp.inc.php if mock.snmp.inc.php is already included...

* fix migration

* if we don't reset the db, run migrations at least.

* set vars for migrate too

* Fix style

* ignore issues with undefined indexes in legacy code
2019-10-13 13:40:38 +00:00
Tony Murray
f3ba8947f7 Use Config helper (#10339)
remove usage of global variable
2019-06-23 00:29:12 -05:00
Tony Murray
8ce81f2423 Update database schema display (#9708)
* Update database schema display

* handle missing migrations table
2019-01-22 06:47:07 -06:00
Tony Murray
daffa7e274 Eventlog updates (#9633)
* Eventlog updates
remove host from eventlog table, retain in api
allow most fields nullable

* updated schema

* revert auth for legacy log_event function
safer check in the model

* add function modifiers
2019-01-10 00:52:00 -06:00
Tony Murray
32a7c50189 Use Laravel authentication (#8702)
* Use Laravel for authentication
Support legacy auth methods
Always create DB entry for users (segregate by auth method)

Port api auth to Laravel

restrict poller errors to devices the user has access to

Run checks on every page load.  But set a 5 minute (configurable) timer.
Only run some checks if the user is an admin

Move toastr down a few pixels so it isn't as annoying.

Fix menu not loaded on laravel pages when twofactor is enabled for the system, but disabled for the user.
Add two missing menu entries in the laravel menu

Rewrite 2FA code
Simplify some and verify code before applying

Get http-auth working
Handle legacy $_SESSION differently.  Allows Auth::once(), etc to work.

* Fix tests and mysqli extension check

* remove duplicate Toastr messages

* Fix new items

* Rename 266.sql to 267.sql
2018-09-11 07:51:35 -05:00
Tony Murray
a2e33efba8 Use PDO for MySQL queries (#8935)
Gut dbFacile
mres() now does nothing... could have some vulnerable queries, but most are ok

TODO
- [x] IRC client broke
- [x] Install broke

DO NOT DELETE THIS TEXT

#### Please note

> Please read this information carefully. You can run `./scripts/pre-commit.php` to check your code before submitting.

- [x] Have you followed our [code guidelines?](http://docs.librenms.org/Developing/Code-Guidelines/)

#### Testers

If you would like to test this pull request then please run: `./scripts/github-apply <pr_id>`, i.e `./scripts/github-apply 5926`
2018-08-17 21:29:20 +01:00
Tony Murray
d841625f12 refactor: Refactor database and config init (#8527)
* Refactor database and config init
Connect to the database without loading full config
Load config completely so post-processing is always done consistently.
Erase existing $config when loading, fixes issues in case we load the config twice.
If the database is not connected, don't try to load database settings. (Fixes some db errors on install)
Attempt to remove $config access/modification before init.php
Remove usage of db_name, that might not match the connected database.
Centralize db config loading, so we consistently apply db_test database settings.
Many of these changes are influenced by Laravel port.

* Some safety so we don't assign strings to numeric port field
Smooth out phpunit bootstrap

* Fix a couple of scrutinizer warnings.
2018-04-11 16:15:13 +01:00
Arzhel Younsi
7eda8d9989 feature: Added a irc_alert_short option to only send the alert title (#8312)
* Add a irc_alert_short option to only send the alert title

* Add doc for 'irc_alert_short'
2018-03-02 17:52:47 +00:00
Tony Murray
cdf5b05934 Replace usages of array_combine() that match array_by_column() (#7863)
Also, fix up some usages where just array_column() will do.
2017-12-06 08:19:29 +00:00
mcq8
c9728a1f71 refactor: Refactored authorizers to classes (#7497)
* Refactored authorizers to classes

* Merge changes for #7335

* ! fix php 5.3 incompatibility

* Update ADAuthorizationAuthorizer.php

* Fix get_user -> getUser

* Rename AuthorizerFactory to Auth, fix interface missing functions

* Add phpdocs to all interface methods and normalize the names a bit.

* Re-work auth_test.php AD bind tests to work properly with the new class.
Reflection is not the nicest tool, but I think it is appropriate here.
Handle exceptions more nicely in auth_test.php

* Restore AD getUseList fix

Not sure how it got removed

* fix auth_test.php style
2017-11-18 10:33:03 +00:00
Tony Murray
44cb59d54e refactor: Rewrite a bit of the irc bot (#7667)
also, use the appropriate dbFetchCell()
2017-11-07 20:30:59 +00:00
zapotah
fcbd3a0dff Fix ".status services" to show properly possible status codes (#7663)
* Fix ".status services" to show properly possible status codes

Nagios plugins return 0-3 as the status-code for a check. This adds "warning" and "unknown" to the output as well as hierarchical color for the total.

* Fix ".status services" to show properly possible status codes

Nagios plugins return 0-3 as the status-code for a check. This adds "warning" and "unknown" to the output as well as hierarchical color for the total.
2017-11-07 09:19:18 -06:00
zapotah
ad739252a2 fix: Fixed status services up/down inverse values for IRC Bot (#7657) 2017-11-06 22:11:36 +00:00
Tony Murray
51ba934e11 feature: Added web validation (#7474)
* refactor: convert validations to modules to prep for gui integration

* accidentally dropped, schema update

* fix accidental output to webui

* mention discovery-wrapper.py and re-arrange.

* refine some fix statements

* rename the Config validation group to Configuration.

* fix some scrutinizer issues
remove as many local functions from validator.php as possible
move extensions from pre-check
remove duplicate timezone check
looks like there is some db schema differences between mariadb 10.1 and 10.2, investigating

* mariadb version diff take2

* Check schema version first for database.
Remove stop to go back to command line for install docs.
Add helpful link when there is no devices added to /addhost

* fix incorrect validation for empty string defaults

* Fix style

* Add additional file permissions checks

* catch exception and fail for invalid timezone
Change visuals a bit.

* add php version warning

* fix space
2017-10-26 07:56:09 +01:00
Olen
3dd6628101 alerts: Updated Irc transport to use templates (#6758)
* Use templates also for irc-alerts

* Remove old code

* Make messages to admins (nicks) use the templates as well

* Added a "strip_tags" to remove html-tags from the irc-messages
2017-06-08 19:26:24 +01:00
Olen
4b15713f69 fix: a few issues with colors (take two) (#6787) 2017-06-06 06:42:49 -05:00