mirror of
https://gitee.com/huoyo/ko-time.git
synced 2025-12-06 16:58:26 +08:00
optimize jackson's threats
This commit is contained in:
parent
e20812f17a
commit
b4957441a8
2
pom.xml
2
pom.xml
@ -26,7 +26,7 @@
|
||||
<dependency>
|
||||
<groupId>com.auth0</groupId>
|
||||
<artifactId>java-jwt</artifactId>
|
||||
<version>3.16.0</version>
|
||||
<version>4.0.0-beta.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework</groupId>
|
||||
|
||||
@ -28,7 +28,7 @@ import java.util.logging.Logger;
|
||||
@ComponentScan("cn.langpy.kotime")
|
||||
@Configuration
|
||||
public class LoadConfig {
|
||||
public static Logger log = Logger.getLogger(LoadConfig.class.toString());
|
||||
private static Logger log = Logger.getLogger(LoadConfig.class.toString());
|
||||
|
||||
@Value("${koTime.enable:true}")
|
||||
private Boolean kotimeEnable;
|
||||
|
||||
@ -34,7 +34,7 @@ public class KoTimeController {
|
||||
@Value("${ko-time.password:}")
|
||||
private String password;
|
||||
|
||||
public static Logger log = Logger.getLogger(KoTimeController.class.toString());
|
||||
private static Logger log = Logger.getLogger(KoTimeController.class.toString());
|
||||
|
||||
@PostMapping("/login")
|
||||
@ResponseBody
|
||||
@ -65,14 +65,18 @@ public class KoTimeController {
|
||||
|
||||
|
||||
@GetMapping
|
||||
public void index(String test, HttpServletResponse response, HttpServletRequest request) throws Exception {
|
||||
public void index(String test, HttpServletResponse response, HttpServletRequest request) {
|
||||
if (null != test) {
|
||||
return;
|
||||
}
|
||||
response.setContentType("text/html;charset=utf-8");
|
||||
ClassPathResource classPathResource = new ClassPathResource(KoConstant.kotimeViewer);
|
||||
BufferedReader reader = new BufferedReader(new InputStreamReader(classPathResource.getInputStream(), "utf-8"));
|
||||
PrintWriter out = response.getWriter();
|
||||
try (
|
||||
InputStream inputStream = classPathResource.getInputStream();
|
||||
InputStreamReader streamReader = new InputStreamReader(inputStream, "utf-8");
|
||||
BufferedReader reader = new BufferedReader(streamReader);
|
||||
PrintWriter out = response.getWriter()) {
|
||||
|
||||
String context = request.getContextPath();
|
||||
if (StringUtils.hasText(Context.getConfig().getContextPath())) {
|
||||
context = Context.getConfig().getContextPath();
|
||||
@ -99,7 +103,10 @@ public class KoTimeController {
|
||||
}
|
||||
line = stringBuilder.toString();
|
||||
out.write(line);
|
||||
out.close();
|
||||
out.flush();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -15,7 +15,6 @@ import java.sql.Connection;
|
||||
import java.sql.SQLException;
|
||||
import java.util.*;
|
||||
import java.util.logging.Logger;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static java.util.stream.Collectors.toList;
|
||||
|
||||
@ -25,7 +24,7 @@ import static java.util.stream.Collectors.toList;
|
||||
@Component("database")
|
||||
@Lazy
|
||||
public class DataBase implements GraphService {
|
||||
public static Logger log = Logger.getLogger(DataBase.class.toString());
|
||||
private static Logger log = Logger.getLogger(DataBase.class.toString());
|
||||
|
||||
private Connection readConnection;
|
||||
private Connection writeConnection;
|
||||
|
||||
@ -25,7 +25,7 @@ import java.util.logging.Logger;
|
||||
@Aspect
|
||||
@Component
|
||||
public class AuthHandler {
|
||||
public static Logger log = Logger.getLogger(AuthHandler.class.toString());
|
||||
private static Logger log = Logger.getLogger(AuthHandler.class.toString());
|
||||
|
||||
@Pointcut(KoConstant.authRange)
|
||||
public void preProcess() {
|
||||
|
||||
@ -16,7 +16,7 @@ import java.util.logging.Logger;
|
||||
@Aspect
|
||||
@Component
|
||||
public class ComputeTimeHandler {
|
||||
public static Logger log = Logger.getLogger(ComputeTimeHandler.class.toString());
|
||||
private static Logger log = Logger.getLogger(ComputeTimeHandler.class.toString());
|
||||
|
||||
@Pointcut(KoConstant.comMethodRange)
|
||||
public void preProcess() {
|
||||
|
||||
@ -8,7 +8,7 @@ import java.util.concurrent.ConcurrentLinkedQueue;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
public class InvokedQueue {
|
||||
public static Logger log = Logger.getLogger(InvokedQueue.class.toString());
|
||||
private static Logger log = Logger.getLogger(InvokedQueue.class.toString());
|
||||
|
||||
private volatile static ConcurrentLinkedQueue<InvokedInfo> queue = new ConcurrentLinkedQueue();
|
||||
|
||||
|
||||
@ -12,7 +12,7 @@ import java.util.logging.Logger;
|
||||
|
||||
@KoListener
|
||||
public final class KoInvokedHandler implements InvokedHandler {
|
||||
public static Logger log = Logger.getLogger(KoInvokedHandler.class.toString());
|
||||
private static Logger log = Logger.getLogger(KoInvokedHandler.class.toString());
|
||||
|
||||
|
||||
@Override
|
||||
|
||||
@ -14,7 +14,7 @@ import java.util.logging.Logger;
|
||||
* zhangchang
|
||||
*/
|
||||
public class MethodNodeService {
|
||||
public static Logger log = Logger.getLogger(MethodNodeService.class.toString());
|
||||
private static Logger log = Logger.getLogger(MethodNodeService.class.toString());
|
||||
|
||||
public static MethodNode getParentMethodNode() {
|
||||
Stack<String> stack = MethodStack.get();
|
||||
|
||||
@ -24,7 +24,7 @@ import java.util.logging.Logger;
|
||||
* zhangchang
|
||||
*/
|
||||
public class Common {
|
||||
public static Logger log = Logger.getLogger(Common.class.toString());
|
||||
private static Logger log = Logger.getLogger(Common.class.toString());
|
||||
|
||||
final static List<Class<?>> baseTypes = Arrays.asList(Integer.class, Double.class, Float.class, String.class, Boolean.class, MultipartFile.class);
|
||||
|
||||
|
||||
@ -7,7 +7,6 @@ import cn.langpy.kotime.service.GraphService;
|
||||
import javax.sql.DataSource;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.ThreadPoolExecutor;
|
||||
|
||||
/**
|
||||
* zhangchang
|
||||
|
||||
@ -14,7 +14,7 @@ import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
public class DataBaseUtil {
|
||||
public static Logger log = Logger.getLogger(DataBaseUtil.class.toString());
|
||||
private static Logger log = Logger.getLogger(DataBaseUtil.class.toString());
|
||||
|
||||
static Map<String, ColumnInfo> tableInfoMap = new ConcurrentHashMap<>();
|
||||
|
||||
@ -82,13 +82,14 @@ public class DataBaseUtil {
|
||||
public static List<Map<String, Object>> query(Connection connection, String sql, Object[] values) {
|
||||
List<Map<String, Object>> list = new ArrayList<>();
|
||||
PreparedStatement statement = null;
|
||||
ResultSet resultSet = null;
|
||||
try {
|
||||
statement = connection.prepareStatement(sql);
|
||||
if (null != values) {
|
||||
statement = setParams(statement, values);
|
||||
}
|
||||
final ResultSetMetaData metaData = statement.getMetaData();
|
||||
ResultSet resultSet = statement.executeQuery();
|
||||
resultSet = statement.executeQuery();
|
||||
List<ColumnInfo> columns = getColumns(metaData);
|
||||
while (resultSet.next()) {
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
@ -107,16 +108,24 @@ public class DataBaseUtil {
|
||||
throwables.printStackTrace();
|
||||
}
|
||||
}
|
||||
if (null != resultSet) {
|
||||
try {
|
||||
resultSet.close();
|
||||
} catch (SQLException throwables) {
|
||||
throwables.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
public static boolean existsById(Connection connection, String sql, Object id) {
|
||||
PreparedStatement statement = null;
|
||||
ResultSet resultSet = null;
|
||||
try {
|
||||
statement = connection.prepareStatement(sql);
|
||||
statement = setParams(statement, id);
|
||||
ResultSet resultSet = statement.executeQuery();
|
||||
resultSet = statement.executeQuery();
|
||||
if (resultSet.next()) {
|
||||
return true;
|
||||
}
|
||||
@ -130,6 +139,13 @@ public class DataBaseUtil {
|
||||
throwables.printStackTrace();
|
||||
}
|
||||
}
|
||||
if (null != resultSet) {
|
||||
try {
|
||||
resultSet.close();
|
||||
} catch (SQLException throwables) {
|
||||
throwables.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@ -137,13 +153,14 @@ public class DataBaseUtil {
|
||||
public static <T> List<T> query(Connection connection, String sql, Object[] values, Class<T> c) {
|
||||
List<T> list = new ArrayList<>();
|
||||
PreparedStatement statement = null;
|
||||
ResultSet resultSet = null;
|
||||
try {
|
||||
statement = connection.prepareStatement(sql);
|
||||
if (null != values) {
|
||||
statement = setParams(statement, values);
|
||||
}
|
||||
final ResultSetMetaData metaData = statement.getMetaData();
|
||||
ResultSet resultSet = statement.executeQuery();
|
||||
resultSet = statement.executeQuery();
|
||||
List<ColumnInfo> columns = getColumns(metaData);
|
||||
Field[] fields = null;
|
||||
while (resultSet.next()) {
|
||||
@ -173,6 +190,7 @@ public class DataBaseUtil {
|
||||
} else {
|
||||
field.set(object, columnValue);
|
||||
}
|
||||
field.setAccessible(false);
|
||||
}
|
||||
list.add(object);
|
||||
}
|
||||
@ -190,6 +208,14 @@ public class DataBaseUtil {
|
||||
throwables.printStackTrace();
|
||||
}
|
||||
}
|
||||
if (null != resultSet) {
|
||||
try {
|
||||
resultSet.close();
|
||||
} catch (SQLException throwables) {
|
||||
throwables.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user