mirror of
https://github.com/metrico/qryn.git
synced 2025-03-14 10:07:18 +00:00
fix security alerts
This commit is contained in:
@ -2,6 +2,6 @@ const path = require('path')
|
|||||||
module.exports = {
|
module.exports = {
|
||||||
setupFilesAfterEnv: [path.join(__dirname, '/test/jest.setup.js')],
|
setupFilesAfterEnv: [path.join(__dirname, '/test/jest.setup.js')],
|
||||||
moduleNameMapper: {
|
moduleNameMapper: {
|
||||||
'^axios$': 'axios/dist/node/axios.cjs'
|
'^axios$': require.resolve('axios'),//'axios/dist/node/axios.cjs'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -79,21 +79,35 @@ compiler._ParseScript = compiler.ParseScript
|
|||||||
compiler.ParseScript = function (script) {
|
compiler.ParseScript = function (script) {
|
||||||
const qLiterals = []
|
const qLiterals = []
|
||||||
const aqLiterals = []
|
const aqLiterals = []
|
||||||
const quotedStrings = script.replaceAll(/"([^"\\]|\\.)*"/g, (str) => {
|
let _script = script
|
||||||
if (str.length < 512) {
|
let res = ''
|
||||||
return str
|
let qsMatch = _script.match(/^([^"]*)("([^"\\]|\\.)*")?/)
|
||||||
|
while (qsMatch && qsMatch[0]) {
|
||||||
|
let repl = qsMatch[2] || ''
|
||||||
|
if (repl.length > 512) {
|
||||||
|
qLiterals.push(repl)
|
||||||
|
repl = `"QL_${qLiterals.length - 1}"`
|
||||||
}
|
}
|
||||||
qLiterals.push(str)
|
res = res + qsMatch[1] + repl
|
||||||
return `"QL_${qLiterals.length - 1}"`
|
_script = _script.slice(qsMatch[0].length)
|
||||||
})
|
qsMatch = _script.match(/^([^"]*)("([^"\\]|\\.)*")?/)
|
||||||
const aQuotedStrings = quotedStrings.replaceAll(/`([^`\\]|\\.)*`/g, (str) => {
|
}
|
||||||
if (str.length < 512) {
|
|
||||||
return str
|
_script = res
|
||||||
|
res = ''
|
||||||
|
qsMatch = _script.match(/^([^`]*)(`([^`\\]|\\.)*`)?/)
|
||||||
|
while (qsMatch && qsMatch[0]) {
|
||||||
|
let repl = qsMatch[2] || ''
|
||||||
|
if (repl.length > 512) {
|
||||||
|
aqLiterals.push(repl)
|
||||||
|
repl = `\`AL_${qLiterals.length - 1}\``
|
||||||
}
|
}
|
||||||
aqLiterals.push(str)
|
res = res + qsMatch[1] + repl
|
||||||
return `\`AL_${aqLiterals.length - 1}\``
|
_script = _script.slice(qsMatch[0].length)
|
||||||
})
|
qsMatch = _script.match(/^([^`]*)(`([^`\\]|\\.)*`)?/)
|
||||||
const parsedScript = this._ParseScript(aQuotedStrings)
|
}
|
||||||
|
|
||||||
|
const parsedScript = this._ParseScript(res)
|
||||||
if (!parsedScript) {
|
if (!parsedScript) {
|
||||||
return parsedScript
|
return parsedScript
|
||||||
}
|
}
|
||||||
|
@ -124,7 +124,7 @@ let fastify = require('fastify')({
|
|||||||
done()
|
done()
|
||||||
}))
|
}))
|
||||||
await fastify.register(require('@fastify/compress'), {
|
await fastify.register(require('@fastify/compress'), {
|
||||||
encodings: ['gzip'],
|
encodings: ['gzip']/*,
|
||||||
zlib: {
|
zlib: {
|
||||||
createGzip: () => {
|
createGzip: () => {
|
||||||
const deflator = new pako.Deflate({ gzip: true })
|
const deflator = new pako.Deflate({ gzip: true })
|
||||||
@ -152,7 +152,7 @@ let fastify = require('fastify')({
|
|||||||
}
|
}
|
||||||
return res
|
return res
|
||||||
}
|
}
|
||||||
}
|
}*/
|
||||||
})
|
})
|
||||||
await fastify.register(require('@fastify/url-data'))
|
await fastify.register(require('@fastify/url-data'))
|
||||||
await fastify.register(require('@fastify/websocket'))
|
await fastify.register(require('@fastify/websocket'))
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||||
|
|
||||||
exports[`should compile regex 1`] = `
|
exports[`should compile regex 1`] = `
|
||||||
"SCRIPT: abcd\\\\(
|
"SCRIPT: abcd\\(
|
||||||
SYNTAX: abcd\\\\(
|
SYNTAX: abcd\\(
|
||||||
literal: a
|
literal: a
|
||||||
letter: a
|
letter: a
|
||||||
literal: b
|
literal: b
|
||||||
@ -11,20 +11,20 @@ exports[`should compile regex 1`] = `
|
|||||||
letter: c
|
letter: c
|
||||||
literal: d
|
literal: d
|
||||||
letter: d
|
letter: d
|
||||||
literal: \\\\(
|
literal: \\(
|
||||||
quoted_brack: \\\\(
|
quoted_brack: \\(
|
||||||
"
|
"
|
||||||
`;
|
`;
|
||||||
|
|
||||||
exports[`should compile regex 2`] = `
|
exports[`should compile regex 2`] = `
|
||||||
"SCRIPT: (a\\\\(bc)
|
"SCRIPT: (a\\(bc)
|
||||||
SYNTAX: (a\\\\(bc)
|
SYNTAX: (a\\(bc)
|
||||||
any_group: (a\\\\(bc)
|
any_group: (a\\(bc)
|
||||||
group_tail: a\\\\(bc
|
group_tail: a\\(bc
|
||||||
literal: a
|
literal: a
|
||||||
letter: a
|
letter: a
|
||||||
literal: \\\\(
|
literal: \\(
|
||||||
quoted_brack: \\\\(
|
quoted_brack: \\(
|
||||||
literal: b
|
literal: b
|
||||||
letter: b
|
letter: b
|
||||||
literal: c
|
literal: c
|
||||||
@ -33,26 +33,26 @@ exports[`should compile regex 2`] = `
|
|||||||
`;
|
`;
|
||||||
|
|
||||||
exports[`should compile regex 3`] = `
|
exports[`should compile regex 3`] = `
|
||||||
"SCRIPT: (?<label1>a[^\\\\[\\\\(\\\\)]bc)
|
"SCRIPT: (?<label1>a[^\\[\\(\\)]bc)
|
||||||
SYNTAX: (?<label1>a[^\\\\[\\\\(\\\\)]bc)
|
SYNTAX: (?<label1>a[^\\[\\(\\)]bc)
|
||||||
any_group: (?<label1>a[^\\\\[\\\\(\\\\)]bc)
|
any_group: (?<label1>a[^\\[\\(\\)]bc)
|
||||||
group_name: ?<label1>
|
group_name: ?<label1>
|
||||||
label: label1
|
label: label1
|
||||||
group_tail: a[^\\\\[\\\\(\\\\)]bc
|
group_tail: a[^\\[\\(\\)]bc
|
||||||
literal: a
|
literal: a
|
||||||
letter: a
|
letter: a
|
||||||
literal: [
|
literal: [
|
||||||
letter: [
|
letter: [
|
||||||
literal: ^
|
literal: ^
|
||||||
letter: ^
|
letter: ^
|
||||||
literal: \\\\
|
literal: \\
|
||||||
letter: \\\\
|
letter: \\
|
||||||
literal: [
|
literal: [
|
||||||
letter: [
|
letter: [
|
||||||
literal: \\\\(
|
literal: \\(
|
||||||
quoted_brack: \\\\(
|
quoted_brack: \\(
|
||||||
literal: \\\\)
|
literal: \\)
|
||||||
quoted_brack: \\\\)
|
quoted_brack: \\)
|
||||||
literal: ]
|
literal: ]
|
||||||
letter: ]
|
letter: ]
|
||||||
literal: b
|
literal: b
|
||||||
@ -63,28 +63,28 @@ exports[`should compile regex 3`] = `
|
|||||||
`;
|
`;
|
||||||
|
|
||||||
exports[`should compile regex 4`] = `
|
exports[`should compile regex 4`] = `
|
||||||
"SCRIPT: (a(?<label1>[^\\\\[\\\\(\\\\)]bc))
|
"SCRIPT: (a(?<label1>[^\\[\\(\\)]bc))
|
||||||
SYNTAX: (a(?<label1>[^\\\\[\\\\(\\\\)]bc))
|
SYNTAX: (a(?<label1>[^\\[\\(\\)]bc))
|
||||||
any_group: (a(?<label1>[^\\\\[\\\\(\\\\)]bc))
|
any_group: (a(?<label1>[^\\[\\(\\)]bc))
|
||||||
group_tail: a(?<label1>[^\\\\[\\\\(\\\\)]bc)
|
group_tail: a(?<label1>[^\\[\\(\\)]bc)
|
||||||
literal: a
|
literal: a
|
||||||
letter: a
|
letter: a
|
||||||
any_group: (?<label1>[^\\\\[\\\\(\\\\)]bc)
|
any_group: (?<label1>[^\\[\\(\\)]bc)
|
||||||
group_name: ?<label1>
|
group_name: ?<label1>
|
||||||
label: label1
|
label: label1
|
||||||
group_tail: [^\\\\[\\\\(\\\\)]bc
|
group_tail: [^\\[\\(\\)]bc
|
||||||
literal: [
|
literal: [
|
||||||
letter: [
|
letter: [
|
||||||
literal: ^
|
literal: ^
|
||||||
letter: ^
|
letter: ^
|
||||||
literal: \\\\
|
literal: \\
|
||||||
letter: \\\\
|
letter: \\
|
||||||
literal: [
|
literal: [
|
||||||
letter: [
|
letter: [
|
||||||
literal: \\\\(
|
literal: \\(
|
||||||
quoted_brack: \\\\(
|
quoted_brack: \\(
|
||||||
literal: \\\\)
|
literal: \\)
|
||||||
quoted_brack: \\\\)
|
quoted_brack: \\)
|
||||||
literal: ]
|
literal: ]
|
||||||
letter: ]
|
letter: ]
|
||||||
literal: b
|
literal: b
|
||||||
@ -95,18 +95,18 @@ exports[`should compile regex 4`] = `
|
|||||||
`;
|
`;
|
||||||
|
|
||||||
exports[`should compile regex 5`] = `
|
exports[`should compile regex 5`] = `
|
||||||
"SCRIPT: (a[\\\\(\\\\)]+(?<l2>b)(?<label1>[^\\\\[\\\\(\\\\)]bc))
|
"SCRIPT: (a[\\(\\)]+(?<l2>b)(?<label1>[^\\[\\(\\)]bc))
|
||||||
SYNTAX: (a[\\\\(\\\\)]+(?<l2>b)(?<label1>[^\\\\[\\\\(\\\\)]bc))
|
SYNTAX: (a[\\(\\)]+(?<l2>b)(?<label1>[^\\[\\(\\)]bc))
|
||||||
any_group: (a[\\\\(\\\\)]+(?<l2>b)(?<label1>[^\\\\[\\\\(\\\\)]bc))
|
any_group: (a[\\(\\)]+(?<l2>b)(?<label1>[^\\[\\(\\)]bc))
|
||||||
group_tail: a[\\\\(\\\\)]+(?<l2>b)(?<label1>[^\\\\[\\\\(\\\\)]bc)
|
group_tail: a[\\(\\)]+(?<l2>b)(?<label1>[^\\[\\(\\)]bc)
|
||||||
literal: a
|
literal: a
|
||||||
letter: a
|
letter: a
|
||||||
literal: [
|
literal: [
|
||||||
letter: [
|
letter: [
|
||||||
literal: \\\\(
|
literal: \\(
|
||||||
quoted_brack: \\\\(
|
quoted_brack: \\(
|
||||||
literal: \\\\)
|
literal: \\)
|
||||||
quoted_brack: \\\\)
|
quoted_brack: \\)
|
||||||
literal: ]
|
literal: ]
|
||||||
letter: ]
|
letter: ]
|
||||||
literal: +
|
literal: +
|
||||||
@ -117,22 +117,22 @@ exports[`should compile regex 5`] = `
|
|||||||
group_tail: b
|
group_tail: b
|
||||||
literal: b
|
literal: b
|
||||||
letter: b
|
letter: b
|
||||||
any_group: (?<label1>[^\\\\[\\\\(\\\\)]bc)
|
any_group: (?<label1>[^\\[\\(\\)]bc)
|
||||||
group_name: ?<label1>
|
group_name: ?<label1>
|
||||||
label: label1
|
label: label1
|
||||||
group_tail: [^\\\\[\\\\(\\\\)]bc
|
group_tail: [^\\[\\(\\)]bc
|
||||||
literal: [
|
literal: [
|
||||||
letter: [
|
letter: [
|
||||||
literal: ^
|
literal: ^
|
||||||
letter: ^
|
letter: ^
|
||||||
literal: \\\\
|
literal: \\
|
||||||
letter: \\\\
|
letter: \\
|
||||||
literal: [
|
literal: [
|
||||||
letter: [
|
letter: [
|
||||||
literal: \\\\(
|
literal: \\(
|
||||||
quoted_brack: \\\\(
|
quoted_brack: \\(
|
||||||
literal: \\\\)
|
literal: \\)
|
||||||
quoted_brack: \\\\)
|
quoted_brack: \\)
|
||||||
literal: ]
|
literal: ]
|
||||||
letter: ]
|
letter: ]
|
||||||
literal: b
|
literal: b
|
||||||
@ -142,71 +142,71 @@ exports[`should compile regex 5`] = `
|
|||||||
"
|
"
|
||||||
`;
|
`;
|
||||||
|
|
||||||
exports[`should erase names 1`] = `"abcd\\\\("`;
|
exports[`should erase names 1`] = `"abcd\\("`;
|
||||||
|
|
||||||
exports[`should erase names 2`] = `"(a\\\\(bc)"`;
|
exports[`should erase names 2`] = `"(a\\(bc)"`;
|
||||||
|
|
||||||
exports[`should erase names 3`] = `"(a[^\\\\[\\\\(\\\\)]bc)"`;
|
exports[`should erase names 3`] = `"(a[^\\[\\(\\)]bc)"`;
|
||||||
|
|
||||||
exports[`should erase names 4`] = `"(a([^\\\\[\\\\(\\\\)]bc))"`;
|
exports[`should erase names 4`] = `"(a([^\\[\\(\\)]bc))"`;
|
||||||
|
|
||||||
exports[`should erase names 5`] = `"(a[\\\\(\\\\)]+(b)([^\\\\[\\\\(\\\\)]bc))"`;
|
exports[`should erase names 5`] = `"(a[\\(\\)]+(b)([^\\[\\(\\)]bc))"`;
|
||||||
|
|
||||||
exports[`should get named groups 1`] = `Array []`;
|
exports[`should get named groups 1`] = `[]`;
|
||||||
|
|
||||||
exports[`should get named groups 2`] = `
|
exports[`should get named groups 2`] = `
|
||||||
Array [
|
[
|
||||||
Object {
|
{
|
||||||
"val": "a\\\\(bc",
|
"val": "a\\(bc",
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
`;
|
`;
|
||||||
|
|
||||||
exports[`should get named groups 3`] = `
|
exports[`should get named groups 3`] = `
|
||||||
Array [
|
[
|
||||||
Object {
|
{
|
||||||
"name": "label1",
|
"name": "label1",
|
||||||
"val": "a[^\\\\[\\\\(\\\\)]bc",
|
"val": "a[^\\[\\(\\)]bc",
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
`;
|
`;
|
||||||
|
|
||||||
exports[`should get named groups 4`] = `
|
exports[`should get named groups 4`] = `
|
||||||
Array [
|
[
|
||||||
Object {
|
{
|
||||||
"val": "a(?<label1>[^\\\\[\\\\(\\\\)]bc)",
|
"val": "a(?<label1>[^\\[\\(\\)]bc)",
|
||||||
},
|
},
|
||||||
Object {
|
{
|
||||||
"name": "label1",
|
"name": "label1",
|
||||||
"val": "[^\\\\[\\\\(\\\\)]bc",
|
"val": "[^\\[\\(\\)]bc",
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
`;
|
`;
|
||||||
|
|
||||||
exports[`should get named groups 5`] = `
|
exports[`should get named groups 5`] = `
|
||||||
Array [
|
[
|
||||||
Object {
|
{
|
||||||
"val": "a[\\\\(\\\\)]+(?<l2>b)(?<label1>[^\\\\[\\\\(\\\\)]bc)",
|
"val": "a[\\(\\)]+(?<l2>b)(?<label1>[^\\[\\(\\)]bc)",
|
||||||
},
|
},
|
||||||
Object {
|
{
|
||||||
"name": "l2",
|
"name": "l2",
|
||||||
"val": "b",
|
"val": "b",
|
||||||
},
|
},
|
||||||
Object {
|
{
|
||||||
"name": "label1",
|
"name": "label1",
|
||||||
"val": "[^\\\\[\\\\(\\\\)]bc",
|
"val": "[^\\[\\(\\)]bc",
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
`;
|
`;
|
||||||
|
|
||||||
exports[`should process regex 1`] = `
|
exports[`should process regex 1`] = `
|
||||||
Object {
|
{
|
||||||
"labels": Array [
|
"labels": [
|
||||||
Object {
|
{
|
||||||
"name": "helper",
|
"name": "helper",
|
||||||
"val": "[a-zA-Z0-9]+",
|
"val": "[a-zA-Z0-9]+",
|
||||||
},
|
},
|
||||||
Object {
|
{
|
||||||
"name": "token",
|
"name": "token",
|
||||||
"val": "[a-zA-Z]+",
|
"val": "[a-zA-Z]+",
|
||||||
},
|
},
|
||||||
|
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user