https://github.com/bitsensor/php
BitSensor Web Application Security
https://github.com/bitsensor/php
bitsensor php security
Last synced: about 1 month ago
JSON representation
BitSensor Web Application Security
- Host: GitHub
- URL: https://github.com/bitsensor/php
- Owner: bitsensor
- License: mit
- Created: 2018-10-29T12:34:22.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2019-04-19T10:20:30.000Z (over 7 years ago)
- Last Synced: 2025-12-14T09:47:24.762Z (7 months ago)
- Topics: bitsensor, php, security
- Language: PHP
- Size: 1.95 MB
- Stars: 0
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README

# BitSensor PHP Plugin
The BitSensor PHP plugin.
[BitSensor](https://bitsensor.io/)
[Documentation](https://plugins.bitsensor.io/php)
[Gitlab repo](https://git.bitsensor.io/plugins/php)
## Setup BitSensor
### Requirements
* `php >= 5.6.0`
* `composer`
* `uopz` [optional, for query tracing]
## Installation
```bash
composer require bitsensor/php
```
## Configuration
### Code
```php
| IP address manual override value. |
| ```setHostSrc()``` | hostSrc | ```Config::HOST_SERVER_NAME``` ("serverName"), ```Config::HOST_HOST_HEADER``` ("hostHeader"), ```Config::HOST_MANUAL``` ("manual") | ```Config::HOST_SERVER_NAME``` ("serverName") | Source of the hostname. |
| ```setHost()``` | host | host address override | | Hostname manual override value. |
| ```setLogLevel()``` | logLevel | ```Config::LOG_LEVEL_ALL``` ("all"), ```Config::LOG_LEVEL_NONE``` ("none") | ```Config::LOG_LEVEL_ALL``` ("all") | The logging level. |
| ```setOutputFlushing``` | outputFlushing | ```Config::OUTPUT_FLUSHING_ON``` ("on"), ```Config::OUTPUT_FLUSHING_OFF``` ("off") | ```Config::OUTPUT_FLUSHING_OFF``` ("off") | Output flushing. Turning this on allows the browser to render the page while BitSensor is still working in the background. |
| ```setUopzHook``` | uopzHook | ```Config::UOPZ_HOOK_ON``` ("on"), ```Config::UOPZ_HOOK_OFF``` ("off") | ```Config::UOPZ_HOOK_ON``` ("on") | Uopz Hooking. Turning this on enables BitSensor to hook into function calls. |
| ```setFastcgiFinishRequest``` | executeFastCgi | ```Config::EXECUTE_FASTCGI_FINISH_REQUEST_ON``` ("on"), ```Config::EXECUTE_FASTCGI_FINISH_REQUEST_OFF``` ("off") | ```Config::EXECUTE_FASTCGI_FINISH_REQUEST_OFF``` ("off")| Finish request to your FastCGI webserver, while processing BitSensor in a separate thread. |
### Connector Types
#### Api
| PHP | JSON | Value | Default | Description |
|-------------------------------|----------------|------------------------------------------------------------------------------------------------------------------------------------------------------------|---------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------|
| ```setUser()``` | user | username | | Your BitSensor username. |
| ```setApiKey()``` | apikey | api key | | Your BitSensor API key. |
| ```setHost()``` | host | hostname | {user}.bitsensor.io | Hostname of the BitSensor endpoint. |
| ```setPort()``` | port | port | 8080 | Port of the BitSensor endpoint. |
#### File
| PHP | JSON | Value | Default | Description |
|---------------------|----------|------------------|---------------------------------------|--------------|
| ```setFilename()``` | filename | File to write to | /var/log/bitsensor-datapoints-php.log | Logfile that is appended to. Make sure that the Apache or Nginx user can write to this file. Set this using `touch /var/log/bitsensor-datapoints-php.log; chown www-data /var/log/bitsensor-datapoints-php.log; chmod 200 /var/log/bitsensor-datapoints-php.log` |
### Blocking Actions
#### Blockingpage
| PHP | JSON | Value | Default | Description |
|-------------------------------|----------------|------------------------------------------------------------------------------------------------------------------------------------------------------------|---------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------|
| ```setUser()``` | user | username | | Your BitSensor username. |
| ```setHost()``` | host | hostname | {user}.bitsensor.io | Hostname of the BitSensor endpoint. |
| ```setPort()``` | port | port | 2080 | Port of the BitSensor endpoint. |
## Query tracing
To use PDO and MySQLi query tracing, the [uopz](https://github.com/krakjoe/uopz) pecl extension must be installed.
```bash
# You might have to install `pecl` and php-dev dependencies
sudo apt-get install php-pear php-dev
pecl install uopz
# You might have to add `extension=uopz.so` to your php.ini, if that does not happen automatically
echo 'extension=uopz.so' >> /etc/php/7.0/fpm/php.ini
# In case of php-fpm, reload the service
service php7.0-fpm reload
# Check successful installation, the output should be `1`
php -r 'echo extension_loaded("uopz");'
```
## Logging
### Monolog
```php
pushHandler(new PsrHandler(new PsrLogHandler()));
```
### Tags
If you are running many applications, it might be sensible to group them by a tag. You can create a tag using the following snippet:
```php