Commit f2e7f330 authored by zhangsen's avatar zhangsen

漏洞文件bug修改

parent dcef3c7c
package com.yeejoin.amos.fas.core.common.request; package com.yeejoin.amos.fas.core.common.request;
import java.security.SecureRandom;
import java.text.DateFormat; import java.text.DateFormat;
import java.text.ParseException; import java.text.ParseException;
import java.text.ParsePosition; import java.text.ParsePosition;
...@@ -1071,8 +1072,10 @@ public class DateUtil { ...@@ -1071,8 +1072,10 @@ public class DateUtil {
{ {
; ;
} }
long day = (date.getTime() - mydate.getTime()) / (24 * 60 * 60 * 1000); if (null != date && null != mydate) {
return day; return (date.getTime() - mydate.getTime()) / (24 * 60 * 60 * 1000);
}
return 0;
} }
/** /**
...@@ -1115,7 +1118,7 @@ public class DateUtil { ...@@ -1115,7 +1118,7 @@ public class DateUtil {
*/ */
private static String getRandom(int i) private static String getRandom(int i)
{ {
Random jjj = new Random(); SecureRandom jjj = new SecureRandom();
// int suiJiShu = jjj.nextInt(9); // int suiJiShu = jjj.nextInt(9);
if (i == 0) return ""; if (i == 0) return "";
String jj = ""; String jj = "";
......
...@@ -117,9 +117,17 @@ public class FileController extends BaseController { ...@@ -117,9 +117,17 @@ public class FileController extends BaseController {
ResponseUtils.renderText(response, "File not exists!"); ResponseUtils.renderText(response, "File not exists!");
return; return;
} }
FileInputStream fis = new FileInputStream(file); FileInputStream fis = null;
ResponseUtils.downFileByInputStream(file.getName(), fis, response, open); try {
IOUtils.closeQuietly(fis); fis = new FileInputStream(file);
ResponseUtils.downFileByInputStream(file.getName(), fis, response, open);
} catch (IOException e) {
} finally {
if (null != fis) {
fis.close();
}
}
} }
@Permission @Permission
......
...@@ -69,6 +69,8 @@ public class PlanVisual3dController extends BaseController { ...@@ -69,6 +69,8 @@ public class PlanVisual3dController extends BaseController {
if (testPlan != null) { if (testPlan != null) {
String path = testPlan.getFilePath(); String path = testPlan.getFilePath();
if (path != null && !"".equals(path)) { if (path != null && !"".equals(path)) {
FileInputStream inputStream = null;
InputStream fis = null;
try { try {
// path是指欲下载的文件的路径。 // path是指欲下载的文件的路径。
File file = new File(fileUploadDir + path); File file = new File(fileUploadDir + path);
...@@ -79,26 +81,40 @@ public class PlanVisual3dController extends BaseController { ...@@ -79,26 +81,40 @@ public class PlanVisual3dController extends BaseController {
String ext = filename.substring(filename.lastIndexOf(".") + 1).toUpperCase(); String ext = filename.substring(filename.lastIndexOf(".") + 1).toUpperCase();
// 以流的形式下载文件。 // 以流的形式下载文件。
InputStream fis = new BufferedInputStream(new FileInputStream(fileUploadDir + path)); inputStream = new FileInputStream(fileUploadDir + path);
byte[] buffer = new byte[fis.available()]; if (null != inputStream) {
fis.read(buffer); fis = new BufferedInputStream(inputStream);
fis.close();
// 清空response byte[] buffer = new byte[fis.available()];
fis.read(buffer);
// 清空response
// response.reset(); // response.reset();
// 设置response的Header // 设置response的Header
response.addHeader("Content-Disposition", "attachment;filename=" + new String(filename.getBytes())); response.addHeader("Content-Disposition", "attachment;filename=" + new String(filename.getBytes()));
response.addHeader("Content-Length", "" + file.length()); response.addHeader("Content-Length", "" + file.length());
response.setContentType("application/x-download"); response.setContentType("application/x-download");
OutputStream toClient = new BufferedOutputStream(response.getOutputStream()); OutputStream toClient = new BufferedOutputStream(response.getOutputStream());
response.setContentType("application/octet-stream"); response.setContentType("application/octet-stream");
toClient.write(buffer); toClient.write(buffer);
toClient.flush(); toClient.flush();
toClient.close(); toClient.close();
}
} else { } else {
response.setStatus(404); response.setStatus(404);
} }
} catch (IOException ex) { } catch (IOException ex) {
ex.printStackTrace(); ex.printStackTrace();
} finally {
try {
if (null != inputStream) {
inputStream.close();
}
if (null != fis) {
fis.close();
}
} catch (IOException e) {
e.printStackTrace();
}
} }
} }
} else { } else {
......
...@@ -35,6 +35,8 @@ public class WeatherController extends BaseController { ...@@ -35,6 +35,8 @@ public class WeatherController extends BaseController {
String result = ""; String result = "";
BufferedReader in = null; BufferedReader in = null;
BufferedReader responseReader = null;
InputStreamReader res = null;
try { try {
String urlNameString = weatherUrl + address; String urlNameString = weatherUrl + address;
URL realUrl = new URL(urlNameString); URL realUrl = new URL(urlNameString);
...@@ -55,12 +57,13 @@ public class WeatherController extends BaseController { ...@@ -55,12 +57,13 @@ public class WeatherController extends BaseController {
StringBuffer sb = new StringBuffer(); StringBuffer sb = new StringBuffer();
String readLine = new String(); String readLine = new String();
GZIPInputStream gZipS=new GZIPInputStream(connection.getInputStream()); GZIPInputStream gZipS=new GZIPInputStream(connection.getInputStream());
InputStreamReader res = new InputStreamReader(gZipS,"UTF-8"); res = new InputStreamReader(gZipS,"UTF-8");
BufferedReader responseReader = new BufferedReader(res); responseReader = new BufferedReader(res);
while ((readLine = responseReader.readLine()) != null) { while ((readLine = responseReader.readLine()) != null) {
sb.append(readLine); sb.append(readLine);
} }
responseReader.close();
result = sb.toString(); result = sb.toString();
System.out.println(result); System.out.println(result);
...@@ -75,6 +78,12 @@ public class WeatherController extends BaseController { ...@@ -75,6 +78,12 @@ public class WeatherController extends BaseController {
if (in != null) { if (in != null) {
in.close(); in.close();
} }
if (null != responseReader) {
responseReader.close();
}
if (null != res) {
res.close();
}
} catch (Exception e2) { } catch (Exception e2) {
e2.printStackTrace(); e2.printStackTrace();
} }
......
...@@ -161,9 +161,9 @@ public class EquipmentFireEquipmentServiceImpl implements IEquipmentFireEquipmen ...@@ -161,9 +161,9 @@ public class EquipmentFireEquipmentServiceImpl implements IEquipmentFireEquipmen
} }
} }
} }
if (!CollectionUtils.isEmpty(map)) { if (null != map &&!CollectionUtils.isEmpty(map)) {
Integer total = Integer.parseInt(map.get("total").toString()); Integer total = Integer.parseInt(map.getOrDefault("total", 0).toString());
Integer count = Integer.parseInt(map.get("count").toString()); Integer count = Integer.parseInt(map.getOrDefault("count", 0).toString());
if (SqlKeyWordEnum.AND.getKey().equalsIgnoreCase(type)) { if (SqlKeyWordEnum.AND.getKey().equalsIgnoreCase(type)) {
return total.equals(count); return total.equals(count);
} else if (SqlKeyWordEnum.OR.getKey().equalsIgnoreCase(type)) { } else if (SqlKeyWordEnum.OR.getKey().equalsIgnoreCase(type)) {
......
...@@ -325,7 +325,7 @@ public class EquipmentServiceImpl implements IEquipmentService { ...@@ -325,7 +325,7 @@ public class EquipmentServiceImpl implements IEquipmentService {
if(date.isPresent()){ if(date.isPresent()){
equipment2=date.get(); equipment2=date.get();
} }
equipment.setCreateDate(equipment2.getCreateDate()); equipment.setCreateDate(null != equipment2 ? equipment2.getCreateDate() : new Date());
} }
preplanPictureDao.saveAndFlush(pp); preplanPictureDao.saveAndFlush(pp);
...@@ -369,8 +369,7 @@ public class EquipmentServiceImpl implements IEquipmentService { ...@@ -369,8 +369,7 @@ public class EquipmentServiceImpl implements IEquipmentService {
if(date.isPresent()){ if(date.isPresent()){
equipment2=date.get(); equipment2=date.get();
} }
equipment.setCreateDate(null != equipment2 && null != equipment2.getCreateDate() ? equipment2.getCreateDate() : new Date());
equipment.setCreateDate(equipment2.getCreateDate() == null ? new Date() : equipment2.getCreateDate());
} }
} else { } else {
equipment = save(equipment); equipment = save(equipment);
...@@ -382,7 +381,7 @@ public class EquipmentServiceImpl implements IEquipmentService { ...@@ -382,7 +381,7 @@ public class EquipmentServiceImpl implements IEquipmentService {
equipment2=date.get(); equipment2=date.get();
} }
equipment.setCreateDate(equipment2.getCreateDate() == null ? new Date() : equipment2.getCreateDate()); equipment.setCreateDate(null != equipment2 && null != equipment2.getCreateDate() ? equipment2.getCreateDate() : new Date());
} }
Long equipmentId = Long.valueOf(equipment.getId()); Long equipmentId = Long.valueOf(equipment.getId());
for (int i = 0; i < imgs.length; i++) { for (int i = 0; i < imgs.length; i++) {
......
...@@ -210,13 +210,15 @@ public class RiskSourceServiceImpl implements IRiskSourceService { ...@@ -210,13 +210,15 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
riskSource.setStatus(FasConstant.RISK_SOURCE_STATUS_NORMAL); riskSource.setStatus(FasConstant.RISK_SOURCE_STATUS_NORMAL);
riskSource.setCreateDate(new Date()); riskSource.setCreateDate(new Date());
} else {// 更新 } else {// 更新
riskSource.setCreateDate(oldRiskSource.getCreateDate()); if (null != oldRiskSource) {
riskSource.setFmeaList(oldRiskSource.getFmeaList()); riskSource.setCreateDate(oldRiskSource.getCreateDate());
riskSource.setIncrement(oldRiskSource.getIncrement()); riskSource.setFmeaList(oldRiskSource.getFmeaList());
riskSource.setRpn(oldRiskSource.getRpn()); riskSource.setIncrement(oldRiskSource.getIncrement());
riskSource.setRpnChangeLogList(oldRiskSource.getRpnChangeLogList()); riskSource.setRpn(oldRiskSource.getRpn());
riskSource.setRpni(oldRiskSource.getRpni()); riskSource.setRpnChangeLogList(oldRiskSource.getRpnChangeLogList());
riskSource.setStatus(oldRiskSource.getStatus()); riskSource.setRpni(oldRiskSource.getRpni());
riskSource.setStatus(oldRiskSource.getStatus());
}
} }
iRiskSourceDao.saveAndFlush(riskSource); iRiskSourceDao.saveAndFlush(riskSource);
return riskSource; return riskSource;
......
...@@ -97,14 +97,20 @@ public class DesUtil { ...@@ -97,14 +97,20 @@ public class DesUtil {
int[] tempBt; int[] tempBt;
int x, y, z; int x, y, z;
tempBt = bt; tempBt = bt;
for (x = 0; x < firstLength; x++) { if (null != firstKeyBt) {
tempBt = enc(tempBt, (int[]) firstKeyBt.get(x)); for (x = 0; x < firstLength; x++) {
tempBt = enc(tempBt, (int[]) firstKeyBt.get(x));
}
} }
for (y = 0; y < secondLength; y++) { if (null != secondKeyBt) {
tempBt = enc(tempBt, (int[]) secondKeyBt.get(y)); for (y = 0; y < secondLength; y++) {
tempBt = enc(tempBt, (int[]) secondKeyBt.get(y));
}
} }
for (z = 0; z < thirdLength; z++) { if (null != thirdKeyBt) {
tempBt = enc(tempBt, (int[]) thirdKeyBt.get(z)); for (z = 0; z < thirdLength; z++) {
tempBt = enc(tempBt, (int[]) thirdKeyBt.get(z));
}
} }
encByte = tempBt; encByte = tempBt;
} else { } else {
...@@ -112,11 +118,15 @@ public class DesUtil { ...@@ -112,11 +118,15 @@ public class DesUtil {
int[] tempBt; int[] tempBt;
int x, y; int x, y;
tempBt = bt; tempBt = bt;
for (x = 0; x < firstLength; x++) { if (null != firstKeyBt) {
tempBt = enc(tempBt, (int[]) firstKeyBt.get(x)); for (x = 0; x < firstLength; x++) {
tempBt = enc(tempBt, (int[]) firstKeyBt.get(x));
}
} }
for (y = 0; y < secondLength; y++) { if (null != secondKeyBt) {
tempBt = enc(tempBt, (int[]) secondKeyBt.get(y)); for (y = 0; y < secondLength; y++) {
tempBt = enc(tempBt, (int[]) secondKeyBt.get(y));
}
} }
encByte = tempBt; encByte = tempBt;
} else { } else {
...@@ -124,8 +134,10 @@ public class DesUtil { ...@@ -124,8 +134,10 @@ public class DesUtil {
int[] tempBt; int[] tempBt;
int x = 0; int x = 0;
tempBt = bt; tempBt = bt;
for (x = 0; x < firstLength; x++) { if (null != firstKeyBt) {
tempBt = enc(tempBt, (int[]) firstKeyBt.get(x)); for (x = 0; x < firstLength; x++) {
tempBt = enc(tempBt, (int[]) firstKeyBt.get(x));
}
} }
encByte = tempBt; encByte = tempBt;
} }
...@@ -144,14 +156,20 @@ public class DesUtil { ...@@ -144,14 +156,20 @@ public class DesUtil {
int[] tempBt; int[] tempBt;
int x, y, z; int x, y, z;
tempBt = tempByte; tempBt = tempByte;
for (x = 0; x < firstLength; x++) { if (null != firstKeyBt) {
tempBt = enc(tempBt, (int[]) firstKeyBt.get(x)); for (x = 0; x < firstLength; x++) {
tempBt = enc(tempBt, (int[]) firstKeyBt.get(x));
}
} }
for (y = 0; y < secondLength; y++) { if (null != secondKeyBt) {
tempBt = enc(tempBt, (int[]) secondKeyBt.get(y)); for (y = 0; y < secondLength; y++) {
tempBt = enc(tempBt, (int[]) secondKeyBt.get(y));
}
} }
for (z = 0; z < thirdLength; z++) { if (null != thirdKeyBt) {
tempBt = enc(tempBt, (int[]) thirdKeyBt.get(z)); for (z = 0; z < thirdLength; z++) {
tempBt = enc(tempBt, (int[]) thirdKeyBt.get(z));
}
} }
encByte = tempBt; encByte = tempBt;
} else { } else {
...@@ -159,11 +177,15 @@ public class DesUtil { ...@@ -159,11 +177,15 @@ public class DesUtil {
int[] tempBt; int[] tempBt;
int x, y; int x, y;
tempBt = tempByte; tempBt = tempByte;
for (x = 0; x < firstLength; x++) { if (null != firstKeyBt) {
tempBt = enc(tempBt, (int[]) firstKeyBt.get(x)); for (x = 0; x < firstLength; x++) {
tempBt = enc(tempBt, (int[]) firstKeyBt.get(x));
}
} }
for (y = 0; y < secondLength; y++) { if (null != secondKeyBt) {
tempBt = enc(tempBt, (int[]) secondKeyBt.get(y)); for (y = 0; y < secondLength; y++) {
tempBt = enc(tempBt, (int[]) secondKeyBt.get(y));
}
} }
encByte = tempBt; encByte = tempBt;
} else { } else {
...@@ -171,8 +193,10 @@ public class DesUtil { ...@@ -171,8 +193,10 @@ public class DesUtil {
int[] tempBt; int[] tempBt;
int x; int x;
tempBt = tempByte; tempBt = tempByte;
for (x = 0; x < firstLength; x++) { if (null != firstKeyBt) {
tempBt = enc(tempBt, (int[]) firstKeyBt.get(x)); for (x = 0; x < firstLength; x++) {
tempBt = enc(tempBt, (int[]) firstKeyBt.get(x));
}
} }
encByte = tempBt; encByte = tempBt;
} }
...@@ -188,14 +212,20 @@ public class DesUtil { ...@@ -188,14 +212,20 @@ public class DesUtil {
int[] tempBt; int[] tempBt;
int x, y, z; int x, y, z;
tempBt = tempByte; tempBt = tempByte;
for (x = 0; x < firstLength; x++) { if (null != firstKeyBt) {
tempBt = enc(tempBt, (int[]) firstKeyBt.get(x)); for (x = 0; x < firstLength; x++) {
tempBt = enc(tempBt, (int[]) firstKeyBt.get(x));
}
} }
for (y = 0; y < secondLength; y++) { if (null != secondKeyBt) {
tempBt = enc(tempBt, (int[]) secondKeyBt.get(y)); for (y = 0; y < secondLength; y++) {
tempBt = enc(tempBt, (int[]) secondKeyBt.get(y));
}
} }
for (z = 0; z < thirdLength; z++) { if (null != thirdKeyBt) {
tempBt = enc(tempBt, (int[]) thirdKeyBt.get(z)); for (z = 0; z < thirdLength; z++) {
tempBt = enc(tempBt, (int[]) thirdKeyBt.get(z));
}
} }
encByte = tempBt; encByte = tempBt;
} else { } else {
...@@ -203,11 +233,15 @@ public class DesUtil { ...@@ -203,11 +233,15 @@ public class DesUtil {
int[] tempBt; int[] tempBt;
int x, y; int x, y;
tempBt = tempByte; tempBt = tempByte;
for (x = 0; x < firstLength; x++) { if (null != firstKeyBt) {
tempBt = enc(tempBt, (int[]) firstKeyBt.get(x)); for (x = 0; x < firstLength; x++) {
tempBt = enc(tempBt, (int[]) firstKeyBt.get(x));
}
} }
for (y = 0; y < secondLength; y++) { if (null != secondKeyBt) {
tempBt = enc(tempBt, (int[]) secondKeyBt.get(y)); for (y = 0; y < secondLength; y++) {
tempBt = enc(tempBt, (int[]) secondKeyBt.get(y));
}
} }
encByte = tempBt; encByte = tempBt;
} else { } else {
...@@ -215,8 +249,10 @@ public class DesUtil { ...@@ -215,8 +249,10 @@ public class DesUtil {
int[] tempBt; int[] tempBt;
int x; int x;
tempBt = tempByte; tempBt = tempByte;
for (x = 0; x < firstLength; x++) { if (null != firstKeyBt) {
tempBt = enc(tempBt, (int[]) firstKeyBt.get(x)); for (x = 0; x < firstLength; x++) {
tempBt = enc(tempBt, (int[]) firstKeyBt.get(x));
}
} }
encByte = tempBt; encByte = tempBt;
} }
...@@ -267,14 +303,20 @@ public class DesUtil { ...@@ -267,14 +303,20 @@ public class DesUtil {
int[] tempBt; int[] tempBt;
int x, y, z; int x, y, z;
tempBt = intByte; tempBt = intByte;
for (x = thirdLength - 1; x >= 0; x--) { if (null != thirdKeyBt) {
tempBt = dec(tempBt, (int[]) thirdKeyBt.get(x)); for (x = thirdLength - 1; x >= 0; x--) {
tempBt = dec(tempBt, (int[]) thirdKeyBt.get(x));
}
} }
for (y = secondLength - 1; y >= 0; y--) { if (null != secondKeyBt) {
tempBt = dec(tempBt, (int[]) secondKeyBt.get(y)); for (y = secondLength - 1; y >= 0; y--) {
tempBt = dec(tempBt, (int[]) secondKeyBt.get(y));
}
} }
for (z = firstLength - 1; z >= 0; z--) { if (null != firstKeyBt) {
tempBt = dec(tempBt, (int[]) firstKeyBt.get(z)); for (z = firstLength - 1; z >= 0; z--) {
tempBt = dec(tempBt, (int[]) firstKeyBt.get(z));
}
} }
decByte = tempBt; decByte = tempBt;
} else { } else {
...@@ -282,11 +324,15 @@ public class DesUtil { ...@@ -282,11 +324,15 @@ public class DesUtil {
int[] tempBt; int[] tempBt;
int x, y, z; int x, y, z;
tempBt = intByte; tempBt = intByte;
for (x = secondLength - 1; x >= 0; x--) { if (null != secondKeyBt) {
tempBt = dec(tempBt, (int[]) secondKeyBt.get(x)); for (x = secondLength - 1; x >= 0; x--) {
tempBt = dec(tempBt, (int[]) secondKeyBt.get(x));
}
} }
for (y = firstLength - 1; y >= 0; y--) { if (null != firstKeyBt) {
tempBt = dec(tempBt, (int[]) firstKeyBt.get(y)); for (y = firstLength - 1; y >= 0; y--) {
tempBt = dec(tempBt, (int[]) firstKeyBt.get(y));
}
} }
decByte = tempBt; decByte = tempBt;
} else { } else {
...@@ -294,8 +340,10 @@ public class DesUtil { ...@@ -294,8 +340,10 @@ public class DesUtil {
int[] tempBt; int[] tempBt;
int x, y, z; int x, y, z;
tempBt = intByte; tempBt = intByte;
for (x = firstLength - 1; x >= 0; x--) { if (null != firstKeyBt) {
tempBt = dec(tempBt, (int[]) firstKeyBt.get(x)); for (x = firstLength - 1; x >= 0; x--) {
tempBt = dec(tempBt, (int[]) firstKeyBt.get(x));
}
} }
decByte = tempBt; decByte = tempBt;
} }
......
...@@ -62,8 +62,12 @@ public class FileUtils { ...@@ -62,8 +62,12 @@ public class FileUtils {
} catch (Exception ex) { } catch (Exception ex) {
ex.printStackTrace(); ex.printStackTrace();
} finally { } finally {
br.close(); if (null != br) {
out.close(); br.close();
}
if (null != out) {
out.close();
}
} }
} }
......
package com.yeejoin.amos.fas.business.util; package com.yeejoin.amos.fas.business.util;
import java.security.SecureRandom;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.Date; import java.util.Date;
import java.util.Random; import java.util.Random;
...@@ -12,7 +13,7 @@ public class RandomUtil { ...@@ -12,7 +13,7 @@ public class RandomUtil {
SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss"); SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss");
String newDate = sdf.format(new Date()); String newDate = sdf.format(new Date());
String result = ""; String result = "";
Random random = new Random(); SecureRandom random = new SecureRandom();
for (int i = 0; i < 3; i++) { for (int i = 0; i < 3; i++) {
result += random.nextInt(10); result += random.nextInt(10);
} }
......
...@@ -401,9 +401,11 @@ public static Time formatStrToTime(String strDate){ ...@@ -401,9 +401,11 @@ public static Time formatStrToTime(String strDate){
d = format.parse(str); d = format.parse(str);
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }
Time date = new Time(d.getTime()); if (null != d) {
return date; return new Time(d.getTime());
}
return null;
} }
/** /**
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment