* Refactor database connection to use `DriverManagerFactory`
* Add Doctrine DBAL connection to DI container
Revert "Add Doctrine DBAL connection to DI container"
This reverts commit bc2f9f4901d8baee4b12cd2795b0ef76156849cf.
Reapply "Add Doctrine DBAL connection to DI container"
This reverts commit 48debb74bbfa6c8cebf27ee20c222c911d508ccb.
* Refactor database access to use Doctrine DBAL
* Refactor DB config to use 'driver' instead of 'type'
* Refactor database connection to use `DriverManagerFactory`
* Add Doctrine DBAL connection to DI container
Revert "Add Doctrine DBAL connection to DI container"
This reverts commit bc2f9f4901d8baee4b12cd2795b0ef76156849cf.
Reapply "Add Doctrine DBAL connection to DI container"
This reverts commit 48debb74bbfa6c8cebf27ee20c222c911d508ccb.
* Refactor database access to use Doctrine DBAL
* Refactor DB config to use 'driver' instead of 'type'
* Refactor tests to use `dbal` mocks
* Replace `getQueryBuilder` with `createQueryBuilder
* Fix handling of empty query results and cleanup exception comment
* Update Composer lock file
* Refactor PDO initialization in DI container
Updated the DI definition for 'pdo' to directly use the PDO instance returned by Doctrine's DriverManagerFactory, removing unnecessary object casting. Also added missing import for DriverManagerFactory. Updated PHPStan config to remove a redundant ctype_alnum rule.
* Refactor query execution and result fetching logic
Updated database query handling in Extension and System Service classes to separate query building from execution and fetching. This improves code clarity and ensures consistent use of fetchOne for single-value results.
* Fix SQL where clause syntax in Service.php
Corrects the syntax of the where clause in several queries by changing 'where('param', ':param')' to 'where('param = :param')' for proper parameter binding and query execution.
* Refactor Stats module to use Doctrine DBAL
* Refactor Custompages Service to use dbal instead of pdo
Replaced all direct PDO usage with dbal methods for database operations in the Custompages Service. This improves consistency, leverages dbal's abstraction, and prepares the codebase for better maintainability and future enhancements.
* Refactor DBAL usage and update test mocks
Refactored DBAL service definitions and query builder usage to improve clarity and consistency. Updated tests to use anonymous classes for DBAL and query builder mocks instead of PHPUnit mock objects, simplifying test setup and improving maintainability.
Co-Authored-By: Copilot <175728472+Copilot@users.noreply.github.com>
* Refactor DB queries to use executeQuery and executeStatement
Replaced manual PDO prepare/execute calls with Doctrine DBAL's executeQuery and executeStatement methods in UpdatePatcher and ApiRequestTable. This improves code consistency and leverages DBAL features for query execution and result fetching.
* Add input validation for DB charset, table, and column names
Introduces strict validation for supported database charsets in DriverManagerFactory, allowed column names in Custompages Service, and allowed table names in Stats Service to prevent invalid or unsafe input. Also updates UpdatePatcher with default values for new config keys and adjusts a Stats Service test to use a valid table name.
* Add 'CHARSETS' to cspell custom words list
* Refactor query execution in patcher and product domain
Updated query builder usage in UpdatePatcher and ProductDomainTable to separate query building from execution, aligning with best practices. Removed unused fetchOne stubs from ServiceTest to reflect these changes.
Co-Authored-By: Copilot <175728472+Copilot@users.noreply.github.com>
* Refactor `getProductSummary` to use Doctrine DBAL
* Fix parameter binding for category and hash in UpdatePatcher
Updated the insert statement in UpdatePatcher to bind the 'category' and 'hash' parameters explicitly, ensuring correct handling of null values during database insertion.
* Update MySQL charset handling in PDO setup
Removes redundant charset initialization statements for MySQL connections, relying on DBAL to handle connection charset via DSN. Now only sets the server default charset and session timeouts.
* Set default DB driver to `pdo_mysql` in `UpdatePatcher`
---------
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Wrapped `OR` conditions in SQL `WHERE` clauses with parentheses across multiple service classes to ensure correct logical grouping and prevent operator precedence issues during search queries.
* Removed API routes that allowed activity logs to be deleted
* Dropped `updated_at` columns from activity tables
* Rename the label from "Event history" to "System activity"
* Rename the label from "Event history" to "System activity"
* Dropped `updated_at` columns from activity tables
* chore(deps): update dependency rector/rector to v2.2.8
chore(deps): update dependency pimple/pimple to v3.6.0 (#3025)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Removed API routes that allowed activity logs to be deleted
Dropped `updated_at` columns from activity tables
Rename the label from "Event history" to "System activity"
Rename the label from "Event history" to "System activity"
Merge branch 'security/activity-logs' of https://github.com/fossbilling/fossbilling into security/activity-logs
Dropped `updated_at` columns from activity tables
Merge branch 'security/activity-logs' of https://github.com/fossbilling/fossbilling into security/activity-logs
* Rename the label from "Event history" to "System activity"
# Please enter the commit message for your changes. Lines starting
# with '#' will be ignored, and an empty message aborts the commit.
#
# On branch security/activity-logs
# Your branch is behind 'origin/security/activity-logs' by 9 commits, and can be fast-forwarded.
# (use "git pull" to update your local branch)
#
# Changes to be committed:
# modified: src/install/sql/content.sql
# modified: src/install/sql/structure.sql
# modified: src/library/FOSSBilling/UpdatePatcher.php
# modified: src/modules/Activity/Api/Admin.php
# modified: src/modules/Activity/Controller/Admin.php
# modified: src/modules/Activity/Service.php
# modified: src/modules/Activity/html_admin/mod_activity_index.html.twig
# modified: src/modules/Client/Api/Admin.php
# modified: src/modules/Client/html_admin/mod_client_login_history.html.twig
# modified: src/modules/Staff/Api/Admin.php
# modified: src/modules/Staff/Service.php
# modified: src/modules/Staff/html_admin/mod_staff_login_history.html.twig
# modified: tests-legacy/modules/Activity/Api/AdminTest.php
# modified: tests-legacy/modules/Client/Api/AdminTest.php
# modified: tests-legacy/modules/Staff/Api/AdminTest.php
# modified: tests-legacy/modules/Staff/ServiceTest.php
#
* Colspan
* Fixed TomSelect. It now works with more than one instance in a page.
* Added get_pairs endpoint to the Staff module to make TomSelect work
* Implemented filters for the system activity logs
* Added date range filter and "Show all activity from this admin"
* Added filtering by priority
* Separate filtering by IP address
* Filtering options for getPairs
* Fix priority filter conflict when both exact and minimum priority are specified (#3028)
* Initial plan
* Make priority filter take precedence over min_priority to avoid conflicts
Co-authored-by: yagiz-dev <35808275+yagiz-dev@users.noreply.github.com>
---------
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: yagiz-dev <35808275+yagiz-dev@users.noreply.github.com>
* Make the "filter" button in searchbox preserve other request parameters
* Make the debug message for events more descriptive
* Show the time passed since event as a title for the element
* Fixed tests
* Disable min_priority select when exact priority is selected
* Display the client name correctly
---------
Co-authored-by: Copilot <198982749+Copilot@users.noreply.github.com>
* Refactor tests to replace depreciated functions
* Update Rector config and dependencies
* Rector: Add explicit string casting for stricter type safety
* Rector: Add return type hints to methods across codebase
* Rector: Increase dead code level and refactor invoice item logic
* Remove unnecessary `willReturn` from test mocks
Eliminate redundant `willReturn(null)` and similar calls from PHPUnit mock setups in legacy module tests, leaving only method expectations. Also update some test values to use floats for consistency.
* Refactor API controller and email adapter return values
* Update formatting and guidelines in `AGENTS.md`
* Prevent duplicate nav registration
* Fix the security module not being accessible
Corrects the security permissions accidentally being hidden and fixes flawed logic which caused hiding the permissions for a module to then report no permission being given (which is why the security module was being hidden)
* Greatly simplified some of the permissions logic
---------
Co-authored-by: Adam Daley <admdly@users.noreply.github.com>
* Introduce the new Paginator class
* Rename it back to Pagination
* Move #2756 here
* Use HttpFoundation\Request
* Restore Box_Paginator
* Tests
* Replace the deprecated methods wherever used
* No need
* Tests
* Tests again
* tests
* Tests hopefully for the last time
* Use a subquery instead
* Found a faulty query
`m.*` already includes `client_id`. was getting a duplicated column error.
* New pagination logic in Huraga & a couple of improvements
* Type safety
* Accessibility and other improvements
* Fixed tests
* Make aria tags translatable
* Update partial_pagination.html.twig
* Dot operator and little docblock improvement
---------
* Update CI for PHP 8.4
* Update composer deps for PHP 8.4
* Updates
* This is the default mode and this constant causes test failutes
* Explicily install the PDO extensions
* Temporarily downgrade the live tests to PHP 8.3
It would seem that there is some kind of problem with PHP 8.4 in regards to these tests. I believe it is outside of our control however as it installs fine for me with PHP 8.4 under DirectAdmin
* Update to address deprecations
* Make that nullable
* Fixed my typo
* Bump PHPunit to v11
* Also take care of two minor things
* Formatting fix
* Add delays to prevent email enumeration
* Wording tweak
* This should fix the tests
Also ran PHP-CS-Fixer and Rector
* Update ServiceTest.php
---------
Co-authored-by: Jaap Marcus <9754650+jaapmarcus@users.noreply.github.com>
* Bumped the Rector deadcode level
* Added the instanceof setlist
* Increasded type coverage and updated tests config too
* Bumped type coverage & ran PHP-cs-fixer
* Begin reworking permission management
* Tests
* This.. tested functionality that didn't exist in the app
* Fixes
* Added permission checks for the system module
* Implemented extension settings permission
The "extension" settings page will now check for permission before allowing a staff member to even visit the settings page for a client.
FOSSBilling will also check for permission before saving a new config so the API can't be used to bypass this limitation.
I also removed a test as it was checking a function which only ever had one possible return value, no point in updating it to work with this PR
* This should fix the test
* I got a little mixed up with that, but this should work
* Fixed the tests
* Implemented give all & revoke all buttons
* Implemented more, enhancements, & bugfix
* Rename function
* Fix tests
* Optimize, address comment
* Now let's make the tests happy again
* Deduplicate code, cleanup a bit
* Bugfix
* Added selectbox support to the front-end
* Quick bugfix
* Fix issue PHPStan detected
* Bug fix
* Improved page layout & styling
* Implemented more checks
* Fix the tests
* Update error.html.twig
* Cleanup
* Fix the tests
* Updated the design to be more space efficient
* Don't list module access when always given
* Updated the exception type
* setMethod -> onlyMethods
* I donno how that got goofed up
* Fix the test, email module should always be accessible
* Removed the broken test
It's.. not really checking anything anyways. Just that the `extension` module is in a hardcoded array.
* Began implementing Sentry.io support
* Added to the installer
* Added the ID to the bug report template and UI
* Hook it into our error handler, added the ability to filter by error code
* Attempting to add the DSN via GH actions
* Spelling and making PHPstan happy
* Skip exceptions for various incomplete configurations
Also brings in some of the category suggestions made by @Anuril in #195
* Update tests to account for changes
* Added & renamed exception classes
* Fix tests
* Change a bunch of items to be InformationExceptions
* Use a lighter HTTP client, fixed API error reporting
* I guess that's not needed now?
Arighty then
* Improvements, additional info added
* Update SentryHelper.php
* Improved error logging, added instance ID to error page
Also made it so that errors are correctly sent to Sentry rather than exclusively exceptions
* Make the tests happy
* Added the link, improved wording
Also removed the "performance" part of the reporting as it needs to be added to the front-end and I'm not currently implementing that
* Began implementing UI alerts and info
* Added the ability to toggle, fixed tests, use path constants
* Added some useful info & links to the page
* These should be InformationException
* Fix the automated Sentry DSN entry
* Fix the install number text
* Minor cleanup, converted more to InformationException
* Replaced some direct config references with constants
We have the BB_DEBUG constant to indicate if we have debug mode enabled or not, so we shouldn't be directly referencing it in the config file unless we actually need to do so.
Using the constant means there's less locations to update the reference if the config structure is changed
* Bugfix
* Consistency & fixed a PHPDoc
* Corrections
* We actually do want exceptions thrown here
* Change how we get the instance ID
* Stability improvements
Having support for translatable error pages was proving to be problematic, so I had to remove it.
I also had to update the exception class to handle cases where the trans function wasn't setup yet (needed for the /run-patcher page if an error occurs)
* Missed this change on git
* Also fix the variable names...
* Re-added new deps after rebase
* This should also accept "Error" types
* Added more info to the bug report and removed a dug line
* This wasn't supposed to get renamed
* Updated some missed references to Box_Exception
* Apply PHP Code Styling & Quality Changes
* Delete these
* Update .gitignore
* Fixes for PHPStan
* Ignore spelling in the gitnore
* Allow null for that type
Honestly doing so makes ZERO sense, but it matches the current behavior.
---------
Co-authored-by: FOSSBilling Bot <fossbilling-bot>
Co-authored-by: Belle Aerni <belleaerni@gmail.com>
* Small security fix that removes the cleartext password from log files and the "onEventAdminLoginFailed" event
* Do it better and less wrong
---------
Co-authored-by: Anuril <ta@TAPC01.localdomain>
Co-authored-by: Belle Aerni <belleaerni@gmail.com>
* Replace Box_Session and improve session handling
* Improve weights, capitalize class name correctly
* Make the tests pass, update the SQL structure
* Tweak to the fingerprint class, fix more tests
* Regenerate session IDs when logging in
* Improve readability
* Update ServiceTest.php
* Tweak weights and added Huntr badge to the readme
* Improve readability, add PHPDocs, and updated weight
* Update SECURITY.md
* Replace usage of array_get
* Fixes
* And a few more
* Remove remaining references
* Update Service.php
* Few more fixes
* Fix.. I think?
* Fix Client / Invoice updates
* Fix stats
* Fix issues noticed during code review
* More fixes
* And some more fixes :)