@opengis/fastify-table 1.1.42 → 1.1.43

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.
Files changed (48) hide show
  1. package/Changelog.md +5 -0
  2. package/README.md +26 -26
  3. package/config.js +10 -10
  4. package/cron/controllers/cronApi.js +22 -22
  5. package/cron/controllers/utils/cronList.js +1 -1
  6. package/cron/funcs/addCron.js +4 -3
  7. package/cron/index.js +10 -10
  8. package/crud/controllers/deleteCrud.js +15 -7
  9. package/crud/controllers/insert.js +29 -21
  10. package/crud/controllers/update.js +32 -21
  11. package/crud/controllers/utils/checkXSS.js +45 -45
  12. package/crud/controllers/utils/xssInjection.js +72 -72
  13. package/crud/funcs/getToken.js +27 -27
  14. package/crud/funcs/isFileExists.js +13 -13
  15. package/crud/funcs/setToken.js +53 -53
  16. package/crud/index.js +3 -3
  17. package/notification/controllers/testEmail.js +3 -2
  18. package/notification/funcs/addNotification.js +4 -2
  19. package/notification/funcs/sendNotification.js +5 -4
  20. package/notification/funcs/utils/sendEmail.js +39 -39
  21. package/package.json +5 -5
  22. package/pg/funcs/getPG.js +1 -1
  23. package/redis/funcs/getRedis.js +23 -23
  24. package/server/migrations/log.sql +80 -80
  25. package/table/controllers/card.js +44 -44
  26. package/table/controllers/data.js +17 -13
  27. package/table/controllers/form.js +18 -4
  28. package/table/controllers/table.js +21 -15
  29. package/table/controllers/utils/gisIRColumn.js +2 -3
  30. package/table/index.js +1 -1
  31. package/test/api/applyHook.test.js +4 -5
  32. package/test/api/crud.xss.test.js +4 -4
  33. package/test/config.example +18 -18
  34. package/test/funcs/pg.test.js +34 -34
  35. package/test/funcs/redis.test.js +19 -19
  36. package/test/helper/formatDate.test.js +62 -0
  37. package/test/templates/cls/test.json +9 -9
  38. package/test/templates/form/cp_building.form.json +32 -32
  39. package/test/templates/select/account_id.json +3 -3
  40. package/test/templates/select/storage.data.json +2 -2
  41. package/test/templates/table/gis.dataset.table.json +20 -20
  42. package/util/controllers/next.id.js +4 -4
  43. package/util/controllers/properties.add.js +6 -3
  44. package/util/controllers/properties.get.js +19 -19
  45. package/util/index.js +23 -23
  46. package/utils.js +5 -3
  47. package/widget/controllers/widget.set.js +3 -1
  48. package/notification/hook/onWidgetSet.js +0 -63
package/Changelog.md CHANGED
@@ -1,5 +1,10 @@
1
1
  # fastify-table
2
2
 
3
+ ## 1.1.43 - 21.10.2024
4
+
5
+ - addHook params refactor
6
+ - add handlebars to utils
7
+
3
8
  ## 1.1.40 - 18.10.2024
4
9
 
5
10
  - fix migrations
package/README.md CHANGED
@@ -1,26 +1,26 @@
1
- # fastify-table
2
-
3
- [![NPM version](https://img.shields.io/npm/v/@opengis/fastify-table)](https://www.npmjs.com/package/@opengis/fastify-table)
4
- [![js-standard-style](https://img.shields.io/badge/code%20style-standard-brightgreen.svg?style=flat)](http://standardjs.com/)
5
-
6
- It standardizes the entire form building process, while taking care of everything from rendering to validation and processing:
7
-
8
- - pg
9
- - redis
10
- - crud
11
-
12
- ## Install
13
-
14
- ```bash
15
- npm i @opengis/fastify-table
16
- ```
17
-
18
- ## Usage
19
-
20
- ```js
21
- fastify.register(import('@opengis/fastify-table'), config);
22
- ```
23
-
24
- ## Documenation
25
-
26
- For a detailed understanding fastify-table, its features, and how to use them, refer to our [Documentation](https://apidocs.softpro.ua/gis.storage/).
1
+ # fastify-table
2
+
3
+ [![NPM version](https://img.shields.io/npm/v/@opengis/fastify-table)](https://www.npmjs.com/package/@opengis/fastify-table)
4
+ [![js-standard-style](https://img.shields.io/badge/code%20style-standard-brightgreen.svg?style=flat)](http://standardjs.com/)
5
+
6
+ It standardizes the entire form building process, while taking care of everything from rendering to validation and processing:
7
+
8
+ - pg
9
+ - redis
10
+ - crud
11
+
12
+ ## Install
13
+
14
+ ```bash
15
+ npm i @opengis/fastify-table
16
+ ```
17
+
18
+ ## Usage
19
+
20
+ ```js
21
+ fastify.register(import('@opengis/fastify-table'), config);
22
+ ```
23
+
24
+ ## Documenation
25
+
26
+ For a detailed understanding fastify-table, its features, and how to use them, refer to our [Documentation](https://apidocs.softpro.ua/gis.storage/).
package/config.js CHANGED
@@ -1,10 +1,10 @@
1
- import fs from 'fs';
2
-
3
- const fileName = ['config.json', '/data/local/config.json'].find(el => (fs.existsSync(el) ? el : null));
4
- const config = fileName ? JSON.parse(fs.readFileSync(fileName)) : {};
5
-
6
- Object.assign(config, {
7
- allTemplates: config?.allTemplates || {},
8
- });
9
-
10
- export default config;
1
+ import fs from 'fs';
2
+
3
+ const fileName = ['config.json', '/data/local/config.json'].find(el => (fs.existsSync(el) ? el : null));
4
+ const config = fileName ? JSON.parse(fs.readFileSync(fileName)) : {};
5
+
6
+ Object.assign(config, {
7
+ allTemplates: config?.allTemplates || {},
8
+ });
9
+
10
+ export default config;
@@ -1,22 +1,22 @@
1
- import cronList from './utils/cronList.js';
2
-
3
- export default async function cronApi(req) {
4
- const {
5
- params = {}, user = {}, hostname,
6
- } = req;
7
-
8
- if ((!user.uid || !user.user_type?.includes('admin')) && !hostname?.includes('localhost')) {
9
- return { message: 'access restricted', status: 403 };
10
- }
11
-
12
- if (params.name === 'list') {
13
- return { data: Object.keys(cronList || {}) };
14
- }
15
-
16
- if (!cronList[params.name]) {
17
- return { message: `cron not found: ${params.name}`, status: 404 };
18
- }
19
-
20
- const result = await cronList[params.name](req);
21
- return result;
22
- }
1
+ import cronList from './utils/cronList.js';
2
+
3
+ export default async function cronApi(req) {
4
+ const {
5
+ params = {}, user = {}, hostname,
6
+ } = req;
7
+
8
+ if ((!user.uid || !user.user_type?.includes('admin')) && !hostname?.includes('localhost')) {
9
+ return { message: 'access restricted', status: 403 };
10
+ }
11
+
12
+ if (params.name === 'list') {
13
+ return { data: Object.keys(cronList || {}) };
14
+ }
15
+
16
+ if (!cronList[params.name]) {
17
+ return { message: `cron not found: ${params.name}`, status: 404 };
18
+ }
19
+
20
+ const result = await cronList[params.name](req);
21
+ return result;
22
+ }
@@ -1 +1 @@
1
- export default {};
1
+ export default {};
@@ -3,10 +3,11 @@ import { createHash } from 'crypto';
3
3
  import cronList from '../controllers/utils/cronList.js';
4
4
  import getRedis from '../../redis/funcs/getRedis.js';
5
5
  import getPG from '../../pg/funcs/getPG.js';
6
+ import config from '../../config.js';
6
7
 
7
8
  const md5 = (string) => createHash('md5').update(string).digest('hex');
8
9
 
9
- async function verifyUnique(name, config, rclient) {
10
+ async function verifyUnique(name, rclient) {
10
11
  const cronId = config.port || 3000 + md5(name);
11
12
  // one per node check
12
13
  const key = `cron:unique:${cronId}`;
@@ -59,7 +60,7 @@ const interval2ms = {
59
60
  async function runCron({
60
61
  pg, funcs, func, name, rclient, log,
61
62
  }) {
62
- const unique = await verifyUnique(name, funcs.config, rclient);
63
+ const unique = await verifyUnique(name, rclient);
63
64
 
64
65
  if (!unique) return;
65
66
  const db = pg.options.database;
@@ -92,7 +93,7 @@ export default async function addCron(func, interval, fastify) {
92
93
  throw new Error('not enough params: fastify');
93
94
  }
94
95
 
95
- const { config = {}, log } = fastify;
96
+ const { log } = fastify;
96
97
  const { time = {}, disabled = [] } = config.cron || {};
97
98
  const pg = getPG();
98
99
  const rclient = getRedis();
package/cron/index.js CHANGED
@@ -1,10 +1,10 @@
1
- import cronApi from './controllers/cronApi.js';
2
- import addCron from './funcs/addCron.js';
3
-
4
- async function plugin(fastify, config = {}) {
5
- const prefix = config.prefix || '/api';
6
- fastify.decorate('addCron', addCron);
7
- fastify.get(`${prefix}/cron/:name`, {}, cronApi);
8
- }
9
-
10
- export default plugin;
1
+ import cronApi from './controllers/cronApi.js';
2
+ import addCron from './funcs/addCron.js';
3
+
4
+ async function plugin(fastify, config = {}) {
5
+ const prefix = config.prefix || '/api';
6
+ fastify.decorate('addCron', addCron);
7
+ fastify.get(`${prefix}/cron/:name`, {}, cronApi);
8
+ }
9
+
10
+ export default plugin;
@@ -1,19 +1,27 @@
1
1
  import dataDelete from '../funcs/dataDelete.js';
2
- import getTemplate from '../../table/controllers/utils/getTemplate.js';
3
- import getAccess from '../funcs/getAccess.js';
2
+ import { getTemplate, getAccess, applyHook } from '../../utils.js';
4
3
 
5
4
  export default async function deleteCrud(req) {
6
- const { actions = [], scope, my } = await getAccess(req, req.params.table, req.params.id) || {};
5
+ const { user, params = {} } = req || {};
6
+ const hookData = await applyHook('preDelete', {
7
+ table: params?.table, id: params?.id, user,
8
+ });
9
+ if (hookData?.message && hookData?.status) {
10
+ return { message: hookData?.message, status: hookData?.status };
11
+ }
12
+
13
+ const { table: del, id } = hookData || req.params || {};
14
+ const { actions = [], scope, my } = await getAccess(req, del, id) || {};
15
+
7
16
  if (!actions.includes('del') || (scope === 'my' && !my)) {
8
17
  return { message: 'access restricted', status: 403 };
9
18
  }
10
- const loadTemplate = await getTemplate('table', req.opt?.table || req.params.table);
11
- const { table } = loadTemplate || req.opt || req.params || {};
12
- const { id } = req.opt || req.params || {};
19
+ const loadTemplate = await getTemplate('table', del);
20
+ const { table } = loadTemplate || hookData || req.params || {};
13
21
 
14
22
  if (!table) return { status: 404, message: 'table is required' };
23
+ if (!id) return { status: 404, message: 'id is required' };
15
24
 
16
- const { user = {} } = req;
17
25
  const data = await dataDelete({
18
26
  table, id, uid: user?.uid,
19
27
  });
@@ -1,54 +1,62 @@
1
1
  import {
2
- applyHook, getAccess, getTemplate, checkXSS, getToken, dataInsert,
2
+ applyHook, getAccess, getTemplate, checkXSS, dataInsert,
3
3
  } from '../../utils.js';
4
4
 
5
5
  export default async function insert(req) {
6
- const { actions = [] } = await getAccess(req, req.params.table) || {};
6
+ const {
7
+ pg, user, params = {}, body = {},
8
+ } = req || {};
9
+ const hookData = await applyHook('preInsert', { table: params?.table, user });
10
+ if (hookData?.message && hookData?.status) {
11
+ return { message: hookData?.message, status: hookData?.status };
12
+ }
13
+
14
+ const { form, table: add } = hookData || req.params || {};
15
+
16
+ const { actions = [] } = await getAccess(req, add) || {};
17
+
7
18
  if (!actions.includes('edit')) {
8
19
  return { message: 'access restricted', status: 403 };
9
20
  }
10
- if (!req.params?.table) {
21
+
22
+ if (!add) {
11
23
  return { message: 'table is required', status: 400 };
12
24
  }
13
- const loadTemplate = await getTemplate('table', req.params.table);
14
- const { table, public: ispublic } = loadTemplate || req.params || {};
25
+
26
+ const loadTemplate = await getTemplate('table', add);
27
+ const { table, public: ispublic } = loadTemplate || hookData || req.params || {};
15
28
  if (!table) {
16
29
  return { message: 'table not found', status: 404 };
17
30
  }
18
31
 
19
- const { funcs = {}, user = {}, params = {} } = req;
20
- const tokenDataString = await getToken({
21
- funcs, uid: user.uid, token: params.table, mode: 'a', json: 0,
22
- });
23
-
24
- const { form, add } = JSON.parse(tokenDataString || '{}');
25
-
26
32
  const formData = form || loadTemplate?.form ? (await getTemplate('form', form || loadTemplate?.form) || {}) : {};
27
33
 
28
- const xssCheck = checkXSS({ body: req.body, schema: formData?.schema });
34
+ const xssCheck = checkXSS({ body, schema: formData?.schema || formData });
29
35
 
30
36
  if (xssCheck.error && formData?.xssCheck !== false) {
31
37
  req.log.warn({ name: 'injection/xss', msg: xssCheck.error, table }, req);
32
38
  return { message: 'Дані містять заборонені символи. Приберіть їх та спробуйте ще раз', status: 409 };
33
39
  }
34
40
 
35
- const { uid } = funcs.config?.auth?.disable || ispublic ? { uid: '1' } : user || {};
36
- if (add || table !== 'admin.users') {
37
- Object.assign(req.body, { uid, editor_id: uid });
41
+ const uid = ispublic ? (user?.uid || '1') : user?.uid;
42
+ if ((add || table) !== 'admin.users') {
43
+ Object.assign(body, { uid, editor_id: uid });
38
44
  }
39
45
  const res = await dataInsert({
40
- table: add || table, data: req.body, uid,
46
+ table: loadTemplate?.table, data: body, uid,
41
47
  });
42
48
 
43
49
  // admin.custom_column
44
- await applyHook('afterInsert', { req, res });
50
+ await applyHook('afterInsert', {
51
+ table, body, payload: res, user,
52
+ });
45
53
  // form DataTable
46
- const extraKeys = Object.keys(formData)?.filter((key) => formData?.[key]?.type === 'DataTable' && formData?.[key]?.table && formData?.[key]?.parent_id && req.body[key].length);
54
+ const extraKeys = Object.keys(formData)?.filter((key) => formData?.[key]?.type === 'DataTable' && formData?.[key]?.table && formData?.[key]?.parent_id && body[key].length);
47
55
  if (extraKeys?.length) {
48
56
  res.extra = {};
49
57
  await Promise.all(extraKeys?.map(async (key) => {
50
- const objId = req.body[formData[key].parent_id] || req.body?.id;
51
- const extraRows = await Promise.all(req.body[key].map(async (row) => {
58
+ const objId = body[formData[key].parent_id] || req.body?.id;
59
+ const extraRows = await Promise.all(body[key].map(async (row) => {
52
60
  const extraRes = await dataInsert({
53
61
  table: formData[key].table, data: { ...row, [formData[key].parent_id]: objId }, uid,
54
62
  });
@@ -1,33 +1,42 @@
1
1
  import {
2
- pgClients, applyHook, getAccess, getTemplate, checkXSS, getToken, dataInsert, dataUpdate,
2
+ pgClients, applyHook, getAccess, getTemplate, checkXSS, dataInsert, dataUpdate,
3
3
  } from '../../utils.js';
4
4
 
5
5
  export default async function update(req) {
6
- const { actions = [], scope, my } = await getAccess(req, req.params.table, req.params.id) || {};
6
+ const {
7
+ pg, user, params = {}, body = {},
8
+ } = req || {};
9
+ const hookData = await applyHook('preUpdate', {
10
+ table: params?.table, id: params?.id, user,
11
+ });
12
+ if (hookData?.message && hookData?.status) {
13
+ return { message: hookData?.message, status: hookData?.status };
14
+ }
15
+
16
+ const { form, table: edit, id } = hookData || req.params;
17
+
18
+ const { actions = [], scope, my } = await getAccess(req, edit, id) || {};
19
+
7
20
  if (!actions.includes('edit') || (scope === 'my' && !my)) {
8
21
  return { message: 'access restricted', status: 403 };
9
22
  }
10
- if (!req.params?.table) {
23
+
24
+ if (!edit) {
11
25
  return { message: 'table is required', status: 400 };
12
26
  }
13
- if (!req.params?.id) {
27
+
28
+ if (!id) {
14
29
  return { message: 'id is required', status: 404 };
15
30
  }
16
- const loadTemplate = await getTemplate('table', req.params.table);
17
- const { table, public: ispublic } = loadTemplate || req.params || {};
18
- const { id } = req.params || {};
19
-
20
- const { funcs = {}, user = {}, params = {} } = req;
21
- const uid = funcs.config?.auth?.disable || ispublic ? '1' : user.uid;
22
- const tokenDataString = await getToken({
23
- funcs, uid, token: params.table, mode: 'w', json: 0,
24
- });
25
31
 
26
- const tokenData = JSON.parse(tokenDataString || '{}');
32
+ const loadTemplate = await getTemplate('table', edit);
33
+ const { table, public: ispublic } = loadTemplate || hookData || req.params || {};
27
34
 
28
- const formData = tokenData?.form || loadTemplate?.form ? await getTemplate('form', tokenData.form || loadTemplate?.form) : {};
35
+ const uid = ispublic ? (user?.uid || '1') : user?.uid;
29
36
 
30
- const xssCheck = checkXSS({ body: req.body, schema: formData?.schema });
37
+ const formData = form || loadTemplate?.form ? await getTemplate('form', form || loadTemplate?.form) : {};
38
+
39
+ const xssCheck = checkXSS({ body, schema: formData?.schema || formData });
31
40
 
32
41
  if (xssCheck.error && formData?.xssCheck !== false) {
33
42
  req.log.warn({ name: 'injection/xss', msg: xssCheck.error, table }, req);
@@ -35,22 +44,24 @@ export default async function update(req) {
35
44
  }
36
45
 
37
46
  const res = await dataUpdate({
38
- table: tokenData?.table || table, id: tokenData?.id || id, data: req.body, uid,
47
+ table: loadTemplate?.table || table, id, data: body, uid,
39
48
  });
40
49
 
41
50
  // admin.custom_column
42
- await applyHook('afterUpdate', { req, res });
51
+ await applyHook('afterUpdate', {
52
+ table: params?.table, body, payload: res, user,
53
+ });
43
54
 
44
55
  // form DataTable
45
- const extraKeys = Object.keys(formData)?.filter((key) => formData?.[key]?.type === 'DataTable' && formData?.[key]?.table && formData?.[key]?.parent_id && req.body[key].length);
56
+ const extraKeys = Object.keys(formData)?.filter((key) => formData?.[key]?.type === 'DataTable' && formData?.[key]?.table && formData?.[key]?.parent_id && body[key].length);
46
57
  if (extraKeys?.length) {
47
58
  res.extra = {};
48
59
  await Promise.all(extraKeys?.map(async (key) => {
49
- const objId = req.body[formData[key].parent_id] || req.body?.id;
60
+ const objId = body[formData[key].parent_id] || body?.id;
50
61
  // delete old extra data
51
62
  await pgClients.client.query(`delete from ${formData[key].table} where ${formData[key].parent_id}=$1`, [objId]); // rewrite?
52
63
  // insert new extra data
53
- const extraRows = await Promise.all(req.body[key].map(async (row) => {
64
+ const extraRows = await Promise.all(body[key].map(async (row) => {
54
65
  const extraRes = await dataInsert({ table: formData[key].table, data: { ...row, [formData[key].parent_id]: objId }, uid });
55
66
  return extraRes?.rows?.[0];
56
67
  }));
@@ -1,45 +1,45 @@
1
- /* import sqlInjection from '../../../policy/funcs/sqlInjection.js'; */
2
- import xssInjection from './xssInjection.js';
3
-
4
- /* const checkList = xssInjection.concat(sqlInjection); */
5
-
6
- // RTE - rich text editor
7
-
8
- function checkXSS({ body, schema = {} }) {
9
- const data = typeof body === 'string' ? body : JSON.stringify(body);
10
- const stopWords = xssInjection.filter((el) => data.toLowerCase().includes(el));
11
-
12
- // check sql injection
13
- const stopSpecialSymbols = data.match(/\p{S}OR\p{S}|\p{P}OR\p{P}| OR |\+OR\+/gi);
14
- if (stopSpecialSymbols?.length) stopSpecialSymbols?.forEach((el) => stopWords.push(el));
15
-
16
- // escape arrows on non-RTE
17
- Object.keys(body)
18
- .filter((key) => ['<', '>'].find((el) => body[key]?.includes?.(el))
19
- && !['Summernote', 'Tiny', 'Ace'].includes(schema[key]?.type))
20
- ?.forEach((key) => {
21
- Object.assign(body, { [key]: body[key].replace(/</g, '&lt;').replace(/>/g, '&gt;') });
22
- });
23
- // try { } catch (err) { return { error: err.toString() }; }
24
-
25
- if (!stopWords.length) return { body };
26
-
27
- const disabledCheckFields = Object.keys(schema)?.filter((el) => schema[el]?.xssCheck === false); // exclude specific columns
28
-
29
- // check RTE
30
- /* const richTextFields = Object.keys(schema).filter((el) => ['Summernote', 'Tiny', 'Ace'].includes(schema[el]?.type));
31
- richTextFields.filter((key) => !checkList.find((el) => body[key].includes(el)))?.forEach((key) => {
32
- disabledCheckFields.push(key);
33
- }); */
34
-
35
- const field = Object.keys(body)
36
- ?.find((key) => body[key]
37
- && !disabledCheckFields.includes(key)
38
- && body[key].toLowerCase().includes(stopWords[0]));
39
- if (field) {
40
- return { error: `rule: ${stopWords[0]} | attr: ${field} | val: ${body[field]}`, body };
41
- }
42
- return { body };
43
- }
44
-
45
- export default checkXSS;
1
+ /* import sqlInjection from '../../../policy/funcs/sqlInjection.js'; */
2
+ import xssInjection from './xssInjection.js';
3
+
4
+ /* const checkList = xssInjection.concat(sqlInjection); */
5
+
6
+ // RTE - rich text editor
7
+
8
+ function checkXSS({ body, schema = {} }) {
9
+ const data = typeof body === 'string' ? body : JSON.stringify(body);
10
+ const stopWords = xssInjection.filter((el) => data.toLowerCase().includes(el));
11
+
12
+ // check sql injection
13
+ const stopSpecialSymbols = data.match(/\p{S}OR\p{S}|\p{P}OR\p{P}| OR |\+OR\+/gi);
14
+ if (stopSpecialSymbols?.length) stopSpecialSymbols?.forEach((el) => stopWords.push(el));
15
+
16
+ // escape arrows on non-RTE
17
+ Object.keys(body)
18
+ .filter((key) => ['<', '>'].find((el) => body[key]?.includes?.(el))
19
+ && !['Summernote', 'Tiny', 'Ace'].includes(schema[key]?.type))
20
+ ?.forEach((key) => {
21
+ Object.assign(body, { [key]: body[key].replace(/</g, '&lt;').replace(/>/g, '&gt;') });
22
+ });
23
+ // try { } catch (err) { return { error: err.toString() }; }
24
+
25
+ if (!stopWords.length) return { body };
26
+
27
+ const disabledCheckFields = Object.keys(schema)?.filter((el) => schema[el]?.xssCheck === false); // exclude specific columns
28
+
29
+ // check RTE
30
+ /* const richTextFields = Object.keys(schema).filter((el) => ['Summernote', 'Tiny', 'Ace'].includes(schema[el]?.type));
31
+ richTextFields.filter((key) => !checkList.find((el) => body[key].includes(el)))?.forEach((key) => {
32
+ disabledCheckFields.push(key);
33
+ }); */
34
+
35
+ const field = Object.keys(body)
36
+ ?.find((key) => body[key]
37
+ && !disabledCheckFields.includes(key)
38
+ && body[key].toLowerCase().includes(stopWords[0]));
39
+ if (field) {
40
+ return { error: `rule: ${stopWords[0]} | attr: ${field} | val: ${body[field]}`, body };
41
+ }
42
+ return { body };
43
+ }
44
+
45
+ export default checkXSS;
@@ -1,72 +1,72 @@
1
- const xssInjection = [
2
- 'onkeypress=',
3
- 'onkeyup=',
4
- 'ondblclick=',
5
- 'onerror=',
6
- 'onmouseover=',
7
- '<meta',
8
- '<script',
9
- 'vascript:',
10
- 'onkeydown=',
11
- 'onmousedown=',
12
- 'onmouseenter=',
13
- 'onmouseleave=',
14
- 'onmousemove=',
15
- 'onmouseout=',
16
- 'onmouseup=',
17
- 'onmousewheel=',
18
- 'onpaste=',
19
- 'onscroll=',
20
- 'onwheel=',
21
- 'javascript:',
22
- '\\x',
23
- 'eval(',
24
- 'onmouseover=',
25
- 'action=',
26
- 'xlink:',
27
- 'allowscriptaccess',
28
- 'href=',
29
- 'behavior:',
30
- 'onreadystatechange=',
31
- 'onstart=',
32
- 'offline=',
33
- 'onabort=',
34
- 'onafterprint=',
35
- 'onbeforeonload=',
36
- 'onbeforeprint=',
37
- 'onblur=',
38
- 'oncanplay=',
39
- 'oncanplaythrough=',
40
- 'onchange=',
41
- 'onclick=',
42
- 'oncontextmenu=',
43
- 'ondblclick=',
44
- 'ondrag=',
45
- 'ondragend=',
46
- 'ondragenter=',
47
- 'ondragleave=',
48
- 'ondragover=',
49
- 'ondragstart=',
50
- 'ondrop=',
51
- 'ondurationchange=',
52
- 'onemptied=',
53
- 'onended=',
54
- 'onerror=',
55
- 'onfocus=',
56
- 'onformchange=',
57
- 'onforminput=',
58
- 'onhaschange=',
59
- 'oninput=',
60
- 'oninvalid=',
61
- 'onkeydown=',
62
- 'onkeypress=',
63
- 'onkeyup=',
64
- 'onload=',
65
- 'onloadeddata=',
66
- 'onloadedmetadata=',
67
- 'onloadstart=',
68
- 'alert(',
69
- 'script:',
70
- ];
71
-
72
- export default xssInjection;
1
+ const xssInjection = [
2
+ 'onkeypress=',
3
+ 'onkeyup=',
4
+ 'ondblclick=',
5
+ 'onerror=',
6
+ 'onmouseover=',
7
+ '<meta',
8
+ '<script',
9
+ 'vascript:',
10
+ 'onkeydown=',
11
+ 'onmousedown=',
12
+ 'onmouseenter=',
13
+ 'onmouseleave=',
14
+ 'onmousemove=',
15
+ 'onmouseout=',
16
+ 'onmouseup=',
17
+ 'onmousewheel=',
18
+ 'onpaste=',
19
+ 'onscroll=',
20
+ 'onwheel=',
21
+ 'javascript:',
22
+ '\\x',
23
+ 'eval(',
24
+ 'onmouseover=',
25
+ 'action=',
26
+ 'xlink:',
27
+ 'allowscriptaccess',
28
+ 'href=',
29
+ 'behavior:',
30
+ 'onreadystatechange=',
31
+ 'onstart=',
32
+ 'offline=',
33
+ 'onabort=',
34
+ 'onafterprint=',
35
+ 'onbeforeonload=',
36
+ 'onbeforeprint=',
37
+ 'onblur=',
38
+ 'oncanplay=',
39
+ 'oncanplaythrough=',
40
+ 'onchange=',
41
+ 'onclick=',
42
+ 'oncontextmenu=',
43
+ 'ondblclick=',
44
+ 'ondrag=',
45
+ 'ondragend=',
46
+ 'ondragenter=',
47
+ 'ondragleave=',
48
+ 'ondragover=',
49
+ 'ondragstart=',
50
+ 'ondrop=',
51
+ 'ondurationchange=',
52
+ 'onemptied=',
53
+ 'onended=',
54
+ 'onerror=',
55
+ 'onfocus=',
56
+ 'onformchange=',
57
+ 'onforminput=',
58
+ 'onhaschange=',
59
+ 'oninput=',
60
+ 'oninvalid=',
61
+ 'onkeydown=',
62
+ 'onkeypress=',
63
+ 'onkeyup=',
64
+ 'onload=',
65
+ 'onloadeddata=',
66
+ 'onloadedmetadata=',
67
+ 'onloadstart=',
68
+ 'alert(',
69
+ 'script:',
70
+ ];
71
+
72
+ export default xssInjection;