mirror of
https://codeup.aliyun.com/67762337eccfc218f6110e0e/per-boe/java-servers.git
synced 2025-12-10 19:36:50 +08:00
路径遍历
This commit is contained in:
@@ -119,6 +119,10 @@ public class ContentPackageGenerator {
|
|||||||
private String scormPkgDir;
|
private String scormPkgDir;
|
||||||
|
|
||||||
public ContentPackage generateContentPackageFromFile(String scormPkgDir) {
|
public ContentPackage generateContentPackageFromFile(String scormPkgDir) {
|
||||||
|
if (scormPkgDir.contains("..")) {
|
||||||
|
throw new SecurityException("输入路径包含不安全的字符");
|
||||||
|
}
|
||||||
|
|
||||||
if (scormPkgDir == null) {
|
if (scormPkgDir == null) {
|
||||||
log.error("scorm package directory is null");
|
log.error("scorm package directory is null");
|
||||||
return contentPackage;
|
return contentPackage;
|
||||||
|
|||||||
@@ -44,6 +44,10 @@ public class FileUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static File createFile(String dstPath, String fileName) throws IOException {
|
public static File createFile(String dstPath, String fileName) throws IOException {
|
||||||
|
if (dstPath.contains("..") || fileName.contains("..")) {
|
||||||
|
throw new SecurityException("输入路径包含不安全的字符");
|
||||||
|
}
|
||||||
|
|
||||||
String[] dirs = fileName.split("/");
|
String[] dirs = fileName.split("/");
|
||||||
File file = new File(dstPath);
|
File file = new File(dstPath);
|
||||||
|
|
||||||
|
|||||||
@@ -119,6 +119,11 @@ public class SCORMPackageManager {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (packagePath.contains("..")) {
|
||||||
|
// throw new SecurityException("输入路径包含不安全的字符");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
// step 1: uncompress
|
// step 1: uncompress
|
||||||
File f=new File(packagePath);
|
File f=new File(packagePath);
|
||||||
if(!f.exists()) {
|
if(!f.exists()) {
|
||||||
|
|||||||
@@ -60,6 +60,10 @@ public class ZipUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static boolean decompressZip(String zipFilePath, String saveFileDir) {
|
public static boolean decompressZip(String zipFilePath, String saveFileDir) {
|
||||||
|
if (saveFileDir.contains("..")) {
|
||||||
|
throw new SecurityException("输入路径包含不安全的字符");
|
||||||
|
}
|
||||||
|
|
||||||
if (!isEndWithZip(zipFilePath)) {
|
if (!isEndWithZip(zipFilePath)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -66,6 +66,10 @@ public class ExcelToPdfConverter implements ICourseFileConverter {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String convert(String fileType, String filePath) throws Exception{
|
public String convert(String fileType, String filePath) throws Exception{
|
||||||
|
if (filePath.contains("..")) {
|
||||||
|
throw new SecurityException("输入路径包含不安全的字符");
|
||||||
|
}
|
||||||
|
|
||||||
if (this.getLicense()) {
|
if (this.getLicense()) {
|
||||||
FileOutputStream fileOS=null;
|
FileOutputStream fileOS=null;
|
||||||
String previewPath = null;
|
String previewPath = null;
|
||||||
|
|||||||
@@ -65,6 +65,10 @@ public class PPTToPdfConverter implements ICourseFileConverter {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String convert(String fileType, String filePath) throws Exception{
|
public String convert(String fileType, String filePath) throws Exception{
|
||||||
|
if (filePath.contains("..")) {
|
||||||
|
throw new SecurityException("输入路径包含不安全的字符");
|
||||||
|
}
|
||||||
|
|
||||||
if (this.getLicense()) {
|
if (this.getLicense()) {
|
||||||
InputStream slides=null;
|
InputStream slides=null;
|
||||||
Presentation pres=null;
|
Presentation pres=null;
|
||||||
|
|||||||
@@ -69,6 +69,10 @@ public class WordToPdfConverter implements ICourseFileConverter {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String convert(String fileType, String filePath) throws Exception{
|
public String convert(String fileType, String filePath) throws Exception{
|
||||||
|
if (filePath.contains("..")) {
|
||||||
|
throw new SecurityException("输入路径包含不安全的字符");
|
||||||
|
}
|
||||||
|
|
||||||
if (this.getLicense()) {
|
if (this.getLicense()) {
|
||||||
File pdfFile=null;
|
File pdfFile=null;
|
||||||
FileOutputStream fileOS=null;
|
FileOutputStream fileOS=null;
|
||||||
|
|||||||
@@ -227,6 +227,10 @@ public class CourseFileApi extends ApiBaseController {
|
|||||||
return badRequest("请先选择资源归属");
|
return badRequest("请先选择资源归属");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (file.getFilePath().contains("..")) {
|
||||||
|
throw new SecurityException("输入路径包含不安全的字符");
|
||||||
|
}
|
||||||
|
|
||||||
// 重设文件类型为小写
|
// 重设文件类型为小写
|
||||||
file.setFileType(file.getFileType().toLowerCase());
|
file.setFileType(file.getFileType().toLowerCase());
|
||||||
|
|
||||||
@@ -395,8 +399,15 @@ public class CourseFileApi extends ApiBaseController {
|
|||||||
//return badRequest("参数错误");
|
//return badRequest("参数错误");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
String cfPath=null;
|
if (cf.contains("..")) {
|
||||||
|
log.error("参数错误");
|
||||||
|
// throw new SecurityException("输入路径包含不安全的字符");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
String cfPath=null;
|
||||||
String fileName ="";
|
String fileName ="";
|
||||||
if(StringUtils.isNotBlank(cf)) {
|
if(StringUtils.isNotBlank(cf)) {
|
||||||
cfPath=cf;
|
cfPath=cf;
|
||||||
|
|||||||
Reference in New Issue
Block a user