-
-
Notifications
You must be signed in to change notification settings - Fork 155
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
remove sql inject pattern (--) to ignore match single --, due misjudg…
…ing jwt (#85)
- Loading branch information
Showing
2 changed files
with
28 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
core/src/test/java/com/usthe/sureness/security/XssSqlUtilTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package com.usthe.sureness.security; | ||
|
||
import org.junit.jupiter.api.Test; | ||
|
||
import static org.junit.jupiter.api.Assertions.*; | ||
|
||
/** | ||
* @author tomsun28 | ||
* @date 2021/4/2 21:38 | ||
*/ | ||
class XssSqlUtilTest { | ||
|
||
@Test | ||
void stripXss() { | ||
String xssTmp = "cc<script>is a book</script>BB"; | ||
assertEquals("ccBB", XssSqlUtil.stripXss(xssTmp)); | ||
} | ||
|
||
@Test | ||
void stripSqlInjection() { | ||
String jwtTmp = "good is girl--boy"; | ||
assertEquals(jwtTmp, XssSqlUtil.stripSqlInjection(jwtTmp)); | ||
String sqlInject = "select * from tableDb where d = 'sds' -- update"; | ||
assertNotEquals(sqlInject, XssSqlUtil.stripSqlInjection(sqlInject)); | ||
assertEquals("select * from tableDb where d = update", XssSqlUtil.stripSqlInjection(sqlInject)); | ||
} | ||
} |