feat: auto escape in robustness results

This commit is contained in:
Zhang Minghan 2024-01-03 23:02:49 +08:00
parent 24b86e3b4d
commit cf4f3ae823
10 changed files with 117 additions and 53 deletions

View File

@ -36,7 +36,6 @@ config
README.md
.gitignore
qodana.yaml
screenshot
LICENSE

View File

@ -167,13 +167,7 @@ func getRobustnessResult(chunk string) string {
matches := compile.FindStringSubmatch(chunk)
if len(matches) > 1 {
partial := matches[1]
// if the unicode character is in the string, like `hi\\u2019s`, we need to convert it to `hi's`
if utils.ContainUnicode(partial) {
partial = utils.DecodeUnicode(partial)
}
return partial
return utils.ProcessRobustnessChar(matches[1])
} else {
return ""
}

View File

@ -167,13 +167,7 @@ func getRobustnessResult(chunk string) string {
matches := compile.FindStringSubmatch(chunk)
if len(matches) > 1 {
partial := matches[1]
// if the unicode character is in the string, like `hi\\u2019s`, we need to convert it to `hi's`
if utils.ContainUnicode(partial) {
partial = utils.DecodeUnicode(partial)
}
return partial
return utils.ProcessRobustnessChar(matches[1])
} else {
return ""
}

View File

@ -90,13 +90,7 @@ func getRobustnessResult(chunk string) string {
matches := compile.FindStringSubmatch(chunk)
if len(matches) > 1 {
partial := matches[1]
// if the unicode character is in the string, like `hi\\u2019s`, we need to convert it to `hi's`
if utils.ContainUnicode(partial) {
partial = utils.DecodeUnicode(partial)
}
return partial
return utils.ProcessRobustnessChar(matches[1])
} else {
return ""
}

View File

@ -127,6 +127,6 @@ func UpdateRootPassword(db *sql.DB, cache *redis.Client, password string) error
}
cache.Del(context.Background(), fmt.Sprint("nio:user:root"))
return nil
}

View File

@ -41,6 +41,7 @@
"lucide-react": "^0.289.0",
"match-sorter": "^6.3.1",
"react": "^18.2.0",
"react-beautiful-dnd": "^13.1.1",
"react-chartjs-2": "^5.2.0",
"react-dom": "^18.2.0",
"react-i18next": "^13.2.2",

83
app/pnpm-lock.yaml generated
View File

@ -92,6 +92,9 @@ dependencies:
react:
specifier: ^18.2.0
version: 18.2.0
react-beautiful-dnd:
specifier: ^13.1.1
version: 13.1.1(react-dom@18.2.0)(react@18.2.0)
react-chartjs-2:
specifier: ^5.2.0
version: 5.2.0(chart.js@4.4.0)(react@18.2.0)
@ -2054,6 +2057,15 @@ packages:
dependencies:
'@types/react': 18.2.33
/@types/react-redux@7.1.33:
resolution: {integrity: sha512-NF8m5AjWCkert+fosDsN3hAlHzpjSiXlVy9EgQEmLoBhaNXbmyeGs/aj5dQzKuF+/q+S7JQagorGDW8pJ28Hmg==}
dependencies:
'@types/hoist-non-react-statics': 3.3.4
'@types/react': 18.2.33
hoist-non-react-statics: 3.3.2
redux: 4.2.1
dev: false
/@types/react-syntax-highlighter@15.5.9:
resolution: {integrity: sha512-ven8zRSVMNkqt8ySJ2eEW5ugbfl/V/Z9S1c9UNhGqwkwVZNV5akk10rYDALxgwS25cLmN+/Q5UxlGj9CJmZ6Ew==}
dependencies:
@ -2697,6 +2709,12 @@ packages:
which: 2.0.2
dev: true
/css-box-model@1.2.1:
resolution: {integrity: sha512-a7Vr4Q/kd/aw96bnJG332W9V9LkJO69JRcaCYDUqjp6/z0w6VcZjgAcTbgFxEPfBgdnAwlh3iwu+hLopa+flJw==}
dependencies:
tiny-invariant: 1.3.1
dev: false
/css-select@4.3.0:
resolution: {integrity: sha512-wPpOYtnsVontu2mODhA19JrqWxNsfdatRKd64kmpRbQgh1KtItko5sTnEpPdpSaJszTOhEMlF/RPz28qj4HqhQ==}
dependencies:
@ -3893,6 +3911,10 @@ packages:
'@types/mdast': 3.0.14
dev: false
/memoize-one@5.2.1:
resolution: {integrity: sha512-zYiwtZUcYyXKo/np96AGZAckk+FWWsUdJ3cHGGmld7+AhvcWmQyGCYUh1hc4Q/pkOhb65dQR/pqCyK0cOaHz4Q==}
dev: false
/merge-stream@2.0.0:
resolution: {integrity: sha512-abv/qOcuPfk3URPfDzmZU1LKmuw8kT+0nIHvKrKgFrwifol/doWcdA4ZqsWQ8ENrFKkd67Mfpo/LovbIUsbt3w==}
dev: true
@ -4533,12 +4555,35 @@ packages:
/queue-microtask@1.2.3:
resolution: {integrity: sha512-NuaNSa6flKT5JaSYQzJok04JzTL1CA6aGhv5rfLW3PgqA+M2ChpZQnAC8h8i4ZFkBS8X5RqkDBHA7r4hej3K9A==}
/raf-schd@4.0.3:
resolution: {integrity: sha512-tQkJl2GRWh83ui2DiPTJz9wEiMN20syf+5oKfB03yYP7ioZcJwsIK8FjrtLwH1m7C7e+Tt2yYBlrOpdT+dyeIQ==}
dev: false
/randombytes@2.1.0:
resolution: {integrity: sha512-vYl3iOX+4CKUWuxGi9Ukhie6fsqXqS9FE2Zaic4tNFD2N2QQaXOMFbuKK4QmDHC0JO6B1Zp41J0LpT0oR68amQ==}
dependencies:
safe-buffer: 5.2.1
dev: true
/react-beautiful-dnd@13.1.1(react-dom@18.2.0)(react@18.2.0):
resolution: {integrity: sha512-0Lvs4tq2VcrEjEgDXHjT98r+63drkKEgqyxdA7qD3mvKwga6a5SscbdLPO2IExotU1jW8L0Ksdl0Cj2AF67nPQ==}
peerDependencies:
react: ^16.8.5 || ^17.0.0 || ^18.0.0
react-dom: ^16.8.5 || ^17.0.0 || ^18.0.0
dependencies:
'@babel/runtime': 7.23.2
css-box-model: 1.2.1
memoize-one: 5.2.1
raf-schd: 4.0.3
react: 18.2.0
react-dom: 18.2.0(react@18.2.0)
react-redux: 7.2.9(react-dom@18.2.0)(react@18.2.0)
redux: 4.2.1
use-memo-one: 1.1.3(react@18.2.0)
transitivePeerDependencies:
- react-native
dev: false
/react-chartjs-2@5.2.0(chart.js@4.4.0)(react@18.2.0):
resolution: {integrity: sha512-98iN5aguJyVSxp5U3CblRLH67J8gkfyGNbiK3c+l1QI/G4irHMPQw44aEPmjVag+YKTyQ260NcF82GTQ3bdscA==}
peerDependencies:
@ -4583,6 +4628,10 @@ packages:
resolution: {integrity: sha512-24e6ynE2H+OKt4kqsOvNd8kBpV65zoxbA4BVsEOB3ARVWQki/DHzaUoC5KuON/BiccDaCCTZBuOcfZs70kR8bQ==}
dev: false
/react-is@17.0.2:
resolution: {integrity: sha512-w2GsyukL62IJnlaff/nRegPQR94C/XXamvMWmSHRJ4y7Ts/4ocGRmTHvOs8PSE6pB3dWOrD/nueuU5sduBsQ4w==}
dev: false
/react-is@18.2.0:
resolution: {integrity: sha512-xWGDIW6x921xtzPkhiULtthJHoJvBbF3q26fzloPCK0hsvxtPVelvftw3zjbHWSkR2km9Z+4uxbDDK/6Zw9B8w==}
dev: false
@ -4614,6 +4663,28 @@ packages:
- supports-color
dev: false
/react-redux@7.2.9(react-dom@18.2.0)(react@18.2.0):
resolution: {integrity: sha512-Gx4L3uM182jEEayZfRbI/G11ZpYdNAnBs70lFVMNdHJI76XYtR+7m0MN+eAs7UHBPhWXcnFPaS+9owSCJQHNpQ==}
peerDependencies:
react: ^16.8.3 || ^17 || ^18
react-dom: '*'
react-native: '*'
peerDependenciesMeta:
react-dom:
optional: true
react-native:
optional: true
dependencies:
'@babel/runtime': 7.23.2
'@types/react-redux': 7.1.33
hoist-non-react-statics: 3.3.2
loose-envify: 1.4.0
prop-types: 15.8.1
react: 18.2.0
react-dom: 18.2.0(react@18.2.0)
react-is: 17.0.2
dev: false
/react-redux@8.1.3(@types/react-dom@18.2.14)(@types/react@18.2.33)(react-dom@18.2.0)(react@18.2.0)(redux@4.2.1):
resolution: {integrity: sha512-n0ZrutD7DaX/j9VscF+uTALI3oUPa/pO4Z3soOBIjuRn/FzVu6aehhysxZCLi6y7duMf52WNZGMl7CtuK5EnRw==}
peerDependencies:
@ -5170,6 +5241,10 @@ packages:
dependencies:
any-promise: 1.3.0
/tiny-invariant@1.3.1:
resolution: {integrity: sha512-AD5ih2NlSssTCwsMznbvwMZpJ1cbhkGd2uueNxzv2jDlEeZdU04JQfRnggJQ8DrcVBGjAsCKwFBbDlVNtEMlzw==}
dev: false
/to-regex-range@5.0.1:
resolution: {integrity: sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==}
engines: {node: '>=8.0'}
@ -5352,6 +5427,14 @@ packages:
tslib: 2.6.2
dev: false
/use-memo-one@1.1.3(react@18.2.0):
resolution: {integrity: sha512-g66/K7ZQGYrI6dy8GLpVcMsBp4s17xNkYJVSMvTEevGy3nDxHOfE6z8BVE22+5G5x7t3+bhzrlTDB7ObrEE0cQ==}
peerDependencies:
react: ^16.8.0 || ^17.0.0 || ^18.0.0
dependencies:
react: 18.2.0
dev: false
/use-sidecar@1.1.2(@types/react@18.2.33)(react@18.2.0):
resolution: {integrity: sha512-epTbsLuzZ7lPClpz2TyryBfztm7m+28DlEv2ZCQ3MDr5ssiwyOwGH/e5F9CkfWjJ1t4clvI58yF822/GUkjjhw==}
engines: {node: '>=10'}

View File

@ -88,7 +88,7 @@
border: 1px solid hsl(var(--border-hover));
border-radius: var(--radius);
transition: 0.25s;
cursor: pointer;
cursor: grab;
animation: fadein 0.25s forwards ease-in-out;
opacity: 0;
width: 100%;

View File

@ -1,29 +0,0 @@
#-------------------------------------------------------------------------------#
# Qodana analysis is configured by qodana.yaml file #
# https://www.jetbrains.com/help/qodana/qodana-yaml.html #
#-------------------------------------------------------------------------------#
version: "1.0"
#Specify inspection profile for code analysis
profile:
name: qodana.starter
#Enable inspections
#include:
# - name: <SomeEnabledInspectionId>
#Disable inspections
#exclude:
# - name: <SomeDisabledInspectionId>
# paths:
# - <path/where/not/run/inspection>
#Execute shell command before Qodana execution (Applied in CI/CD pipeline)
#bootstrap: sh ./prepare-qodana.sh
#Install IDE plugins before Qodana execution (Applied in CI/CD pipeline)
#plugins:
# - id: <plugin.id> #(plugin id can be found at https://plugins.jetbrains.com)
#Specify Qodana linter for analysis (Applied in CI/CD pipeline)
linter: jetbrains/qodana-go:latest

View File

@ -190,6 +190,34 @@ func DecodeUnicode(data string) string {
})
}
func EscapeChar(data string) string {
// like `\\n` => `\n`, `\\t` => `\t` and so on
re := regexp.MustCompile(`\\([nrtvfb])`)
mapper := map[string]string{
"n": "\n",
"r": "\r",
"t": "\t",
"v": "\v",
"f": "\f",
"b": "\b",
}
return re.ReplaceAllStringFunc(data, func(s string) string {
return mapper[s[1:]]
})
}
func ProcessRobustnessChar(data string) string {
// like `hi\\u2019s` => `hi's`
if ContainUnicode(data) {
data = DecodeUnicode(data)
}
// like `\\n` => `\n`, `\\t` => `\t` and so on
return EscapeChar(data)
}
func SortString(arr []string) []string {
// sort string array by first char
// e.g. ["a", "b", "c", "ab", "ac", "bc"] => ["a", "ab", "ac", "b", "bc", "c"]