rootaccessxvv-bbmarker 0.0.1-security → 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of rootaccessxvv-bbmarker might be problematic. Click here for more details.

Files changed (39) hide show
  1. package/README.md +13 -3
  2. package/index.js +1 -0
  3. package/package.json +18 -6
  4. package/sim/node_modules/.bin/xss +16 -0
  5. package/sim/node_modules/.bin/xss.cmd +17 -0
  6. package/sim/node_modules/.bin/xss.ps1 +28 -0
  7. package/sim/node_modules/.package-lock.json +36 -0
  8. package/sim/node_modules/commander/CHANGELOG.md +419 -0
  9. package/sim/node_modules/commander/LICENSE +22 -0
  10. package/sim/node_modules/commander/Readme.md +428 -0
  11. package/sim/node_modules/commander/index.js +1224 -0
  12. package/sim/node_modules/commander/package.json +38 -0
  13. package/sim/node_modules/commander/typings/index.d.ts +310 -0
  14. package/sim/node_modules/cssfilter/LICENSE +22 -0
  15. package/sim/node_modules/cssfilter/README.md +86 -0
  16. package/sim/node_modules/cssfilter/lib/css.js +110 -0
  17. package/sim/node_modules/cssfilter/lib/default.js +398 -0
  18. package/sim/node_modules/cssfilter/lib/index.js +32 -0
  19. package/sim/node_modules/cssfilter/lib/parser.js +74 -0
  20. package/sim/node_modules/cssfilter/lib/util.js +35 -0
  21. package/sim/node_modules/cssfilter/package.json +49 -0
  22. package/sim/node_modules/xss/CHANGELOG.md +24 -0
  23. package/sim/node_modules/xss/LICENSE +23 -0
  24. package/sim/node_modules/xss/README.md +505 -0
  25. package/sim/node_modules/xss/README.zh.md +491 -0
  26. package/sim/node_modules/xss/bin/xss +67 -0
  27. package/sim/node_modules/xss/dist/test.html +15 -0
  28. package/sim/node_modules/xss/dist/xss.js +1665 -0
  29. package/sim/node_modules/xss/dist/xss.min.js +1 -0
  30. package/sim/node_modules/xss/lib/cli.js +45 -0
  31. package/sim/node_modules/xss/lib/default.js +459 -0
  32. package/sim/node_modules/xss/lib/index.js +44 -0
  33. package/sim/node_modules/xss/lib/parser.js +247 -0
  34. package/sim/node_modules/xss/lib/util.js +34 -0
  35. package/sim/node_modules/xss/lib/xss.js +211 -0
  36. package/sim/node_modules/xss/package.json +63 -0
  37. package/sim/node_modules/xss/typings/xss.d.ts +202 -0
  38. package/sim/package-lock.json +44 -0
  39. package/sim/package.json +16 -0
@@ -0,0 +1,505 @@
1
+ [![NPM version][npm-image]][npm-url]
2
+ [![Node.js CI](https://github.com/leizongmin/js-xss/actions/workflows/nodejs.yml/badge.svg)](https://github.com/leizongmin/js-xss/actions/workflows/nodejs.yml)
3
+ [![Test coverage][coveralls-image]][coveralls-url]
4
+ [![David deps][david-image]][david-url]
5
+ [![node version][node-image]][node-url]
6
+ [![npm download][download-image]][download-url]
7
+ [![npm license][license-image]][download-url]
8
+
9
+ [npm-image]: https://img.shields.io/npm/v/xss.svg?style=flat-square
10
+ [npm-url]: https://npmjs.org/package/xss
11
+ [coveralls-image]: https://img.shields.io/coveralls/leizongmin/js-xss.svg?style=flat-square
12
+ [coveralls-url]: https://coveralls.io/r/leizongmin/js-xss?branch=master
13
+ [david-image]: https://img.shields.io/david/leizongmin/js-xss.svg?style=flat-square
14
+ [david-url]: https://david-dm.org/leizongmin/js-xss
15
+ [node-image]: https://img.shields.io/badge/node.js-%3E=_0.10-green.svg?style=flat-square
16
+ [node-url]: http://nodejs.org/download/
17
+ [download-image]: https://img.shields.io/npm/dm/xss.svg?style=flat-square
18
+ [download-url]: https://npmjs.org/package/xss
19
+ [license-image]: https://img.shields.io/npm/l/xss.svg
20
+
21
+ # Sanitize untrusted HTML (to prevent XSS) with a configuration specified by a Whitelist.
22
+
23
+ [![Greenkeeper badge](https://badges.greenkeeper.io/leizongmin/js-xss.svg)](https://greenkeeper.io/)
24
+
25
+ ![xss](https://nodei.co/npm/xss.png?downloads=true&stars=true)
26
+
27
+ ---
28
+
29
+ `xss` is a module used to filter input from users to prevent XSS attacks.
30
+ ([What is XSS attack?](http://en.wikipedia.org/wiki/Cross-site_scripting))
31
+
32
+ **Project Homepage:** http://jsxss.com
33
+
34
+ **Try Online:** http://jsxss.com/en/try.html
35
+
36
+ **[中文版文档](https://github.com/leizongmin/js-xss/blob/master/README.zh.md)**
37
+
38
+ ---
39
+
40
+ ## Features
41
+
42
+ - Specifies HTML tags and their attributes allowed with whitelist
43
+ - Handle any tags or attributes using custom function.
44
+
45
+ ## Reference
46
+
47
+ - [XSS Filter Evasion Cheat Sheet](https://www.owasp.org/index.php/XSS_Filter_Evasion_Cheat_Sheet)
48
+ - [Data URI scheme](http://en.wikipedia.org/wiki/Data_URI_scheme)
49
+ - [XSS with Data URI Scheme](http://hi.baidu.com/badzzzz/item/bdbafe83144619c199255f7b)
50
+
51
+ ## Benchmark (for references only)
52
+
53
+ - the xss module: 22.53 MB/s
54
+ - `xss()` function from module `validator@0.3.7`: 6.9 MB/s
55
+
56
+ For test code please refer to `benchmark` directory.
57
+
58
+ ## They are using xss module
59
+
60
+ - **nodeclub** - A Node.js bbs using MongoDB - https://github.com/cnodejs/nodeclub
61
+ - **cnpmjs.org** - Private npm registry and web for Enterprise - https://github.com/cnpm/cnpmjs.org
62
+
63
+ ## Install
64
+
65
+ ### NPM
66
+
67
+ ```bash
68
+ npm install xss
69
+ ```
70
+
71
+ ### Bower
72
+
73
+ ```bash
74
+ bower install xss
75
+ ```
76
+
77
+ Or
78
+
79
+ ```bash
80
+ bower install https://github.com/leizongmin/js-xss.git
81
+ ```
82
+
83
+ ## Usages
84
+
85
+ ### On Node.js
86
+
87
+ ```javascript
88
+ var xss = require("xss");
89
+ var html = xss('<script>alert("xss");</script>');
90
+ console.log(html);
91
+ ```
92
+
93
+ ### On Browser
94
+
95
+ Shim mode (reference file `test/test.html`):
96
+
97
+ ```html
98
+ <script src="https://rawgit.com/leizongmin/js-xss/master/dist/xss.js"></script>
99
+ <script>
100
+ // apply function filterXSS in the same way
101
+ var html = filterXSS('<script>alert("xss");</scr' + "ipt>");
102
+ alert(html);
103
+ </script>
104
+ ```
105
+
106
+ AMD mode - shim:
107
+
108
+ ```html
109
+ <script>
110
+ require.config({
111
+ baseUrl: "./",
112
+ paths: {
113
+ xss: "https://rawgit.com/leizongmin/js-xss/master/dist/xss.js",
114
+ },
115
+ shim: {
116
+ xss: { exports: "filterXSS" },
117
+ },
118
+ });
119
+ require(["xss"], function (xss) {
120
+ var html = xss('<script>alert("xss");</scr' + "ipt>");
121
+ alert(html);
122
+ });
123
+ </script>
124
+ ```
125
+
126
+ **Notes: please don't use the URL https://rawgit.com/leizongmin/js-xss/master/dist/xss.js in production environment.**
127
+
128
+ ## Command Line Tool
129
+
130
+ ### Process File
131
+
132
+ You can use the xss command line tool to process a file. Usage:
133
+
134
+ ```bash
135
+ xss -i <input_file> -o <output_file>
136
+ ```
137
+
138
+ Example:
139
+
140
+ ```bash
141
+ xss -i origin.html -o target.html
142
+ ```
143
+
144
+ ### Active Test
145
+
146
+ Run the following command, them you can type HTML
147
+ code in the command-line, and check the filtered output:
148
+
149
+ ```bash
150
+ xss -t
151
+ ```
152
+
153
+ For more details, please run `$ xss -h` to see it.
154
+
155
+ ## Custom filter rules
156
+
157
+ When using the `xss()` function, the second parameter could be used to specify
158
+ custom rules:
159
+
160
+ ```javascript
161
+ options = {}; // Custom rules
162
+ html = xss('<script>alert("xss");</script>', options);
163
+ ```
164
+
165
+ To avoid passing `options` every time, you can also do it in a faster way by
166
+ creating a `FilterXSS` instance:
167
+
168
+ ```javascript
169
+ options = {}; // Custom rules
170
+ myxss = new xss.FilterXSS(options);
171
+ // then apply myxss.process()
172
+ html = myxss.process('<script>alert("xss");</script>');
173
+ ```
174
+
175
+ Details of parameters in `options` would be described below.
176
+
177
+ ### Whitelist
178
+
179
+ By specifying a `whiteList`, e.g. `{ 'tagName': [ 'attr-1', 'attr-2' ] }`. Tags
180
+ and attributes not in the whitelist would be filter out. For example:
181
+
182
+ ```javascript
183
+ // only tag a and its attributes href, title, target are allowed
184
+ var options = {
185
+ whiteList: {
186
+ a: ["href", "title", "target"],
187
+ },
188
+ };
189
+ // With the configuration specified above, the following HTML:
190
+ // <a href="#" onclick="hello()"><i>Hello</i></a>
191
+ // would become:
192
+ // <a href="#">&lt;i&gt;Hello&lt;/i&gt;</a>
193
+ ```
194
+
195
+ For the default whitelist, please refer `xss.whiteList`.
196
+
197
+ ### Customize the handler function for matched tags
198
+
199
+ By specifying the handler function with `onTag`:
200
+
201
+ ```javascript
202
+ function onTag(tag, html, options) {
203
+ // tag is the name of current tag, e.g. 'a' for tag <a>
204
+ // html is the HTML of this tag, e.g. '<a>' for tag <a>
205
+ // options is some addition informations:
206
+ // isWhite boolean, whether the tag is in whitelist
207
+ // isClosing boolean, whether the tag is a closing tag, e.g. true for </a>
208
+ // position integer, the position of the tag in output result
209
+ // sourcePosition integer, the position of the tag in input HTML source
210
+ // If a string is returned, the current tag would be replaced with the string
211
+ // If return nothing, the default measure would be taken:
212
+ // If in whitelist: filter attributes using onTagAttr, as described below
213
+ // If not in whitelist: handle by onIgnoreTag, as described below
214
+ }
215
+ ```
216
+
217
+ ### Customize the handler function for attributes of matched tags
218
+
219
+ By specifying the handler function with `onTagAttr`:
220
+
221
+ ```javascript
222
+ function onTagAttr(tag, name, value, isWhiteAttr) {
223
+ // tag is the name of current tag, e.g. 'a' for tag <a>
224
+ // name is the name of current attribute, e.g. 'href' for href="#"
225
+ // isWhiteAttr whether the attribute is in whitelist
226
+ // If a string is returned, the attribute would be replaced with the string
227
+ // If return nothing, the default measure would be taken:
228
+ // If in whitelist: filter the value using safeAttrValue as described below
229
+ // If not in whitelist: handle by onIgnoreTagAttr, as described below
230
+ }
231
+ ```
232
+
233
+ ### Customize the handler function for tags not in the whitelist
234
+
235
+ By specifying the handler function with `onIgnoreTag`:
236
+
237
+ ```javascript
238
+ function onIgnoreTag(tag, html, options) {
239
+ // Parameters are the same with onTag
240
+ // If a string is returned, the tag would be replaced with the string
241
+ // If return nothing, the default measure would be taken (specifies using
242
+ // escape, as described below)
243
+ }
244
+ ```
245
+
246
+ ### Customize the handler function for attributes not in the whitelist
247
+
248
+ By specifying the handler function with `onIgnoreTagAttr`:
249
+
250
+ ```javascript
251
+ function onIgnoreTagAttr(tag, name, value, isWhiteAttr) {
252
+ // Parameters are the same with onTagAttr
253
+ // If a string is returned, the value would be replaced with this string
254
+ // If return nothing, then keep default (remove the attribute)
255
+ }
256
+ ```
257
+
258
+ ### Customize escaping function for HTML
259
+
260
+ By specifying the handler function with `escapeHtml`. Following is the default
261
+ function **(Modification is not recommended)**:
262
+
263
+ ```javascript
264
+ function escapeHtml(html) {
265
+ return html.replace(/</g, "&lt;").replace(/>/g, "&gt;");
266
+ }
267
+ ```
268
+
269
+ ### Customize escaping function for value of attributes
270
+
271
+ By specifying the handler function with `safeAttrValue`:
272
+
273
+ ```javascript
274
+ function safeAttrValue(tag, name, value) {
275
+ // Parameters are the same with onTagAttr (without options)
276
+ // Return the value as a string
277
+ }
278
+ ```
279
+
280
+ ### Customize CSS filter
281
+
282
+ If you allow the attribute `style`, the value will be processed by [cssfilter](https://github.com/leizongmin/js-css-filter) module. The cssfilter module includes a default css whitelist. You can specify the options for cssfilter module like this:
283
+
284
+ ```javascript
285
+ myxss = new xss.FilterXSS({
286
+ css: {
287
+ whiteList: {
288
+ position: /^fixed|relative$/,
289
+ top: true,
290
+ left: true,
291
+ },
292
+ },
293
+ });
294
+ html = myxss.process('<script>alert("xss");</script>');
295
+ ```
296
+
297
+ If you don't want to filter out the `style` content, just specify `false` to the `css` option:
298
+
299
+ ```javascript
300
+ myxss = new xss.FilterXSS({
301
+ css: false,
302
+ });
303
+ ```
304
+
305
+ For more help, please see https://github.com/leizongmin/js-css-filter
306
+
307
+ ### Quick Start
308
+
309
+ #### Filter out tags not in the whitelist
310
+
311
+ By using `stripIgnoreTag` parameter:
312
+
313
+ - `true` filter out tags not in the whitelist
314
+ - `false`: by default: escape the tag using configured `escape` function
315
+
316
+ Example:
317
+
318
+ If `stripIgnoreTag = true` is set, the following code:
319
+
320
+ ```html
321
+ code:
322
+ <script>
323
+ alert(/xss/);
324
+ </script>
325
+ ```
326
+
327
+ would output filtered:
328
+
329
+ ```html
330
+ code:alert(/xss/);
331
+ ```
332
+
333
+ #### Filter out tags and tag bodies not in the whitelist
334
+
335
+ By using `stripIgnoreTagBody` parameter:
336
+
337
+ - `false|null|undefined` by default: do nothing
338
+ - `'*'|true`: filter out all tags not in the whitelist
339
+ - `['tag1', 'tag2']`: filter out only specified tags not in the whitelist
340
+
341
+ Example:
342
+
343
+ If `stripIgnoreTagBody = ['script']` is set, the following code:
344
+
345
+ ```html
346
+ code:
347
+ <script>
348
+ alert(/xss/);
349
+ </script>
350
+ ```
351
+
352
+ would output filtered:
353
+
354
+ ```html
355
+ code:
356
+ ```
357
+
358
+ #### Filter out HTML comments
359
+
360
+ By using `allowCommentTag` parameter:
361
+
362
+ - `true`: do nothing
363
+ - `false` by default: filter out HTML comments
364
+
365
+ Example:
366
+
367
+ If `allowCommentTag = false` is set, the following code:
368
+
369
+ ```html
370
+ code:<!-- something -->
371
+ END
372
+ ```
373
+
374
+ would output filtered:
375
+
376
+ ```html
377
+ code: END
378
+ ```
379
+
380
+ ## Examples
381
+
382
+ ### Allow attributes of whitelist tags start with `data-`
383
+
384
+ ```javascript
385
+ var source = '<div a="1" b="2" data-a="3" data-b="4">hello</div>';
386
+ var html = xss(source, {
387
+ onIgnoreTagAttr: function (tag, name, value, isWhiteAttr) {
388
+ if (name.substr(0, 5) === "data-") {
389
+ // escape its value using built-in escapeAttrValue function
390
+ return name + '="' + xss.escapeAttrValue(value) + '"';
391
+ }
392
+ },
393
+ });
394
+
395
+ console.log("%s\nconvert to:\n%s", source, html);
396
+ ```
397
+
398
+ Result:
399
+
400
+ ```html
401
+ <div a="1" b="2" data-a="3" data-b="4">hello</div>
402
+ convert to:
403
+ <div data-a="3" data-b="4">hello</div>
404
+ ```
405
+
406
+ ### Allow tags start with `x-`
407
+
408
+ ```javascript
409
+ var source = "<x><x-1>he<x-2 checked></x-2>wwww</x-1><a>";
410
+ var html = xss(source, {
411
+ onIgnoreTag: function (tag, html, options) {
412
+ if (tag.substr(0, 2) === "x-") {
413
+ // do not filter its attributes
414
+ return html;
415
+ }
416
+ },
417
+ });
418
+
419
+ console.log("%s\nconvert to:\n%s", source, html);
420
+ ```
421
+
422
+ Result:
423
+
424
+ ```html
425
+ <x
426
+ ><x-1>he<x-2 checked></x-2>wwww</x-1
427
+ ><a>
428
+ convert to: &lt;x&gt;<x-1>he<x-2 checked></x-2>wwww</x-1><a></a></a
429
+ ></x>
430
+ ```
431
+
432
+ ### Parse images in HTML
433
+
434
+ ```javascript
435
+ var source =
436
+ '<img src="img1">a<img src="img2">b<img src="img3">c<img src="img4">d';
437
+ var list = [];
438
+ var html = xss(source, {
439
+ onTagAttr: function (tag, name, value, isWhiteAttr) {
440
+ if (tag === "img" && name === "src") {
441
+ // Use the built-in friendlyAttrValue function to escape attribute
442
+ // values. It supports converting entity tags such as &lt; to printable
443
+ // characters such as <
444
+ list.push(xss.friendlyAttrValue(value));
445
+ }
446
+ // Return nothing, means keep the default handling measure
447
+ },
448
+ });
449
+
450
+ console.log("image list:\n%s", list.join(", "));
451
+ ```
452
+
453
+ Result:
454
+
455
+ ```html
456
+ image list: img1, img2, img3, img4
457
+ ```
458
+
459
+ ### Filter out HTML tags (keeps only plain text)
460
+
461
+ ```javascript
462
+ var source = "<strong>hello</strong><script>alert(/xss/);</script>end";
463
+ var html = xss(source, {
464
+ whiteList: {}, // empty, means filter out all tags
465
+ stripIgnoreTag: true, // filter out all HTML not in the whitelist
466
+ stripIgnoreTagBody: ["script"], // the script tag is a special case, we need
467
+ // to filter out its content
468
+ });
469
+
470
+ console.log("text: %s", html);
471
+ ```
472
+
473
+ Result:
474
+
475
+ ```html
476
+ text: helloend
477
+ ```
478
+
479
+ ## License
480
+
481
+ ```text
482
+ Copyright (c) 2012-2018 Zongmin Lei(雷宗民) <leizongmin@gmail.com>
483
+ http://ucdok.com
484
+
485
+ The MIT License
486
+
487
+ Permission is hereby granted, free of charge, to any person obtaining
488
+ a copy of this software and associated documentation files (the
489
+ "Software"), to deal in the Software without restriction, including
490
+ without limitation the rights to use, copy, modify, merge, publish,
491
+ distribute, sublicense, and/or sell copies of the Software, and to
492
+ permit persons to whom the Software is furnished to do so, subject to
493
+ the following conditions:
494
+
495
+ The above copyright notice and this permission notice shall be
496
+ included in all copies or substantial portions of the Software.
497
+
498
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
499
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
500
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
501
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
502
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
503
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
504
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
505
+ ```