Skip to content

Commit eb21be5

Browse files
committed
update readme
1 parent 74f05d2 commit eb21be5

File tree

1 file changed

+89
-7
lines changed

1 file changed

+89
-7
lines changed

README.md

Lines changed: 89 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,32 @@
55
[![GitHub Code Style Action Status](https://img.shields.io/github/actions/workflow/status/medilies/xssless/fix-php-code-style-issues.yml?branch=main&label=code%20style&style=flat-square)](https://github.com/medilies/xssless/actions?query=workflow%3A"Fix+PHP+code+style+issues"+branch%3Amain)
66
[![Total Downloads](https://img.shields.io/packagist/dt/medilies/xssless.svg?style=flat-square)](https://packagist.org/packages/medilies/xssless)
77

8-
...
9-
- https://cheatsheetseries.owasp.org/cheatsheets/Cross_Site_Scripting_Prevention_Cheat_Sheet.html#html-sanitization
8+
Use what is recommended by [OWASP](https://cheatsheetseries.owasp.org/cheatsheets/Cross_Site_Scripting_Prevention_Cheat_Sheet.html#html-sanitization):
9+
10+
> HTML Sanitization will strip dangerous HTML from a variable and return a safe string of HTML. OWASP recommends DOMPurify for HTML Sanitization.
11+
12+
Note that the library is still in its alfa-phase. The methods exposed in this doc will most likely not change, but the configs and the internals may change a lot incase you decide to extend the package or create your own driver.
1013

1114
## Installation
1215

13-
You can install the package via composer:
16+
Install the package via composer:
1417

1518
```bash
1619
composer require medilies/xssless
1720
```
1821

22+
For non Laravel projects pick a config and run the following code:
23+
24+
```php
25+
$config = new Medilies\Xssless\Dompurify\DompurifyCliConfig('node', 'npm');
26+
27+
(new Medilies\Xssless\Xssless)
28+
->using($config)
29+
->setup($html);
30+
```
31+
32+
### Laravel setup
33+
1934
You can publish the config file with:
2035

2136
```bash
@@ -26,19 +41,74 @@ This is the contents of the published config file:
2641

2742
```php
2843
return [
44+
'default' => 'dompurify-cli',
45+
46+
'cleaners' => [
47+
'dompurify-cli' => new DompurifyCliConfig(
48+
env('NODE_PATH', 'node'),
49+
env('NPM_PATH', 'npm'),
50+
),
51+
'dompurify-service' => new DompurifyServiceConfig(
52+
env('NODE_PATH', 'node'),
53+
env('NPM_PATH', 'npm'),
54+
'127.0.0.1',
55+
63000,
56+
),
57+
],
2958
];
3059
```
3160

61+
Run the following command after picking your `xssless.default` config:
62+
63+
```shell
64+
php artisan xssless:setup
65+
```
66+
3267
## Usage
3368

69+
Using `Medilies\Xssless\Dompurify\DompurifyCliConfig`:
70+
3471
```php
35-
$xssless = new Medilies\Xssless();
72+
$config = new Medilies\Xssless\Dompurify\DompurifyCliConfig('node', 'npm');
73+
74+
(new Medilies\Xssless\Xssless)
75+
->using($config)
76+
->clean($html);
3677
```
3778

38-
## Testing
79+
Using `Medilies\Xssless\Dompurify\DompurifyServiceConfig`:
3980

40-
```bash
41-
./vendor/bin/pest
81+
```php
82+
$config = new Medilies\Xssless\Dompurify\DompurifyServiceConfig('node', 'npm', '127.0.0.1', 63000);
83+
84+
$xssless = (new Medilies\Xssless\Xssless)
85+
->using($config);
86+
87+
/**
88+
* It is better to have this part in a separate script that runs continuously
89+
* and independently from your app that manages the HTTP requests or CLI input
90+
*/
91+
$xssless->start();
92+
93+
$xssless->clean($html);
94+
```
95+
96+
### Laravel usage
97+
98+
Using `Medilies\Xssless\Dompurify\DompurifyCliConfig`:
99+
100+
```php
101+
Medilies\Xssless\Laravel\Facades\Xssless::clean($html);
102+
```
103+
104+
Using `Medilies\Xssless\Dompurify\DompurifyServiceConfig`:
105+
106+
```shell
107+
php artisan xssless:start
108+
```
109+
110+
```php
111+
Medilies\Xssless\Laravel\Facades\Xssless::clean($html);
42112
```
43113

44114
## Changelog
@@ -49,6 +119,18 @@ Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed re
49119

50120
Please see [CONTRIBUTING](CONTRIBUTING.md) for details.
51121

122+
### Testing
123+
124+
```bash
125+
./vendor/bin/pest
126+
```
127+
128+
### Formatting
129+
130+
```bash
131+
./vendor/bin/pint
132+
```
133+
52134
## Security Vulnerabilities
53135

54136
Please review [our security policy](../../security/policy) on how to report security vulnerabilities.

0 commit comments

Comments
 (0)