diff --git a/.typos.toml b/.typos.toml index 738b13e271..d9416da7b8 100644 --- a/.typos.toml +++ b/.typos.toml @@ -6,6 +6,7 @@ testng = "testng" ba = "ba" referer = "referer" keynode = "keynode" +SCHEM = "SCHEM" [files] extend-exclude = ["public/", "amap-wx/", "m-icon/", "uni-card/", "uni-col/", "uni-link/", "uni-list/", "uni-list-item/", "uni-row/", "migration/", "mapFiles/", "frontend/src/views/chart/components/table/TableNormal.vue"] diff --git a/Dockerfile b/Dockerfile index 209a5a99b1..83885e4eec 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM registry.cn-qingdao.aliyuncs.com/dataease/fabric8-java-alpine-openjdk8-jre:edge-chromium +FROM registry.cn-qingdao.aliyuncs.com/dataease/fabric8-java-alpine-openjdk8-jre:edge-chromium-11 ARG IMAGE_TAG diff --git a/backend/pom.xml b/backend/pom.xml index a4dfbe8c94..69d5e919d3 100644 --- a/backend/pom.xml +++ b/backend/pom.xml @@ -14,7 +14,7 @@ UTF-8 1.9.1 - 1.8 + 11 20.1.0 3.12.1 4.0.0 @@ -30,7 +30,7 @@ com.google.guava guava - 31.0.1-jre + 32.0.0-jre org.springframework.boot @@ -429,8 +429,8 @@ org.apache.maven.plugins maven-compiler-plugin - 1.8 - 1.8 + 11 + 11 diff --git a/backend/src/main/java/io/dataease/commons/utils/DeFileUtils.java b/backend/src/main/java/io/dataease/commons/utils/DeFileUtils.java index 6adc42e9be..2dcee5fa41 100644 --- a/backend/src/main/java/io/dataease/commons/utils/DeFileUtils.java +++ b/backend/src/main/java/io/dataease/commons/utils/DeFileUtils.java @@ -1,5 +1,7 @@ package io.dataease.commons.utils; +import io.dataease.commons.exception.DEException; +import org.apache.commons.lang3.StringUtils; import org.springframework.web.multipart.MultipartFile; import java.io.*; @@ -41,6 +43,17 @@ public class DeFileUtils { if (dir.exists()) return ; dir.mkdirs(); } + + public static void validateFile(MultipartFile file) { + String name = getFileNameNoEx(file.getOriginalFilename()); + if (StringUtils.contains(name, "./")) { + DEException.throwException("file path invalid"); + } + String suffix = getExtensionName(file.getOriginalFilename()); + if (!StringUtils.equalsIgnoreCase(suffix, "zip")) { + DEException.throwException("please upload valid zip file"); + } + } /** * 将文件名解析成文件的上传路径 */ diff --git a/backend/src/main/java/io/dataease/commons/utils/ExcelXlsxReader.java b/backend/src/main/java/io/dataease/commons/utils/ExcelXlsxReader.java deleted file mode 100644 index 5e2c2ea0ef..0000000000 --- a/backend/src/main/java/io/dataease/commons/utils/ExcelXlsxReader.java +++ /dev/null @@ -1,557 +0,0 @@ -package io.dataease.commons.utils; - -import io.dataease.dto.dataset.ExcelSheetData; -import io.dataease.i18n.Translator; -import io.dataease.plugins.common.base.domain.DatasetTableField; -import io.dataease.plugins.common.dto.datasource.TableField; -import org.apache.commons.collections4.CollectionUtils; -import org.apache.poi.openxml4j.opc.OPCPackage; -import org.apache.poi.ss.usermodel.DataFormatter; -import org.apache.poi.xssf.eventusermodel.XSSFReader; -import org.apache.poi.xssf.model.SharedStringsTable; -import org.apache.poi.xssf.model.StylesTable; -import org.apache.poi.xssf.usermodel.XSSFCellStyle; -import org.apache.poi.xssf.usermodel.XSSFRichTextString; -import org.xml.sax.Attributes; -import org.xml.sax.InputSource; -import org.xml.sax.SAXException; -import org.xml.sax.XMLReader; -import org.xml.sax.helpers.DefaultHandler; -import org.xml.sax.helpers.XMLReaderFactory; - -import java.io.InputStream; -import java.util.*; - -/** - * @author y - * @create 2018-01-18 14:28 - * @desc POI读取excel有两种模式,一种是用户模式,一种是事件驱动模式 - * 采用SAX事件驱动模式解决XLSX文件,可以有效解决用户模式内存溢出的问题, - * 该模式是POI官方推荐的读取大数据的模式, - * 在用户模式下,数据量较大,Sheet较多,或者是有很多无用的空行的情况下,容易出现内存溢出 - *

- * 用于解决.xlsx2007版本大数据量问题 - **/ -public class ExcelXlsxReader extends DefaultHandler { - - /** - * 自定义获取表格某些信 - */ - public Map map = new TreeMap(); - - /** - * 单元格中的数据可能的数据类型 - */ - enum CellDataType { - BOOL, ERROR, FORMULA, INLINESTR, SSTINDEX, NUMBER, DATE, NULL - } - - /** - * 共享字符串表 - */ - private SharedStringsTable sst; - - /** - * 上一次的索引值 - */ - private String lastIndex; - - /** - * 总行数 - */ - private int totalRows = 0; - - /** - * 一行内cell集合 - */ - private List cellList = new ArrayList(); - - /** - * 判断整行是否为空行的标记 - */ - private boolean flag = false; - - /** - * 当前行 - */ - private int curRow = 1; - - /** - * 当前列 - */ - private int curCol = 0; - - /** - * T元素标识 - */ - private boolean isTElement; - - /** - * 单元格数据类型,默认为字符串类型 - */ - private CellDataType nextDataType = CellDataType.SSTINDEX; - - private final DataFormatter formatter = new DataFormatter(); - - /** - * 单元格日期格式的索引 - */ - private short formatIndex; - - /** - * 日期格式字符串 - */ - private String formatString; - - - //定义前一个元素和当前元素的位置,用来计算其中空的单元格数量,如A6和A8等 - private String preRef = null, ref = null; - - //定义该文档一行最大的单元格数,用来补全一行最后可能缺失的单元格 - private String maxRef = null; - - public List getDatasetTableFields() { - return datasetTableFields; - } - - public void setDatasetTableFields(List datasetTableFields) { - this.datasetTableFields = datasetTableFields; - } - - private List datasetTableFields = null; - - /** - * 单元格 - */ - private StylesTable stylesTable; - - public List fields = new ArrayList<>(); - public List> data = new ArrayList<>(); - public List totalSheets = new ArrayList<>(); - /** - * 是否为日期 - */ - private boolean isDateFormat = false; - - public Integer getObtainedNum() { - return obtainedNum; - } - - public void setObtainedNum(Integer obtainedNum) { - this.obtainedNum = obtainedNum; - } - - private Integer obtainedNum = null; - - public List getFields() { - return fields; - } - - public void setFields(List fields) { - this.fields = fields; - } - - public List> getData() { - return data; - } - - public void setData(List> data) { - this.data = data; - } - - public int process(InputStream inputStream) throws Exception { - OPCPackage pkg = OPCPackage.open(inputStream); - XSSFReader xssfReader = new XSSFReader(pkg); - stylesTable = xssfReader.getStylesTable(); - SharedStringsTable sst = xssfReader.getSharedStringsTable(); - XMLReader parser = XMLReaderFactory.createXMLReader("org.apache.xerces.parsers.SAXParser"); - parser.setFeature("http://apache.org/xml/features/disallow-doctype-decl", true); - parser.setFeature("http://xml.org/sax/features/external-general-entities", false); - parser.setFeature("http://xml.org/sax/features/external-parameter-entities", false); - this.sst = sst; - parser.setContentHandler(this); - XSSFReader.SheetIterator sheets = (XSSFReader.SheetIterator) xssfReader.getSheetsData(); - while (sheets.hasNext()) { //遍历sheet - - curRow = 1; //标记初始行为第一行 - fields.clear(); - data.clear(); - InputStream sheet = sheets.next(); //sheets.next()和sheets.getSheetName()不能换位置,否则sheetName报错 - InputSource sheetSource = new InputSource(sheet); - parser.parse(sheetSource); //解析excel的每条记录,在这个过程中startElement()、characters()、endElement()这三个函数会依次执行 - - ExcelSheetData excelSheetData = new ExcelSheetData(); - excelSheetData.setData(new ArrayList<>(data)); - excelSheetData.setExcelLabel(sheets.getSheetName()); - excelSheetData.setFields(new ArrayList<>(fields)); - totalSheets.add(excelSheetData); - - sheet.close(); - } - return totalRows; //返回该excel文件的总行数,不包括首列和空行 - } - - /** - * 第一个执行 - * - * @param uri - * @param localName - * @param name - * @param attributes - * @throws SAXException - */ - @Override - public void startElement(String uri, String localName, String name, Attributes attributes) throws SAXException { - if (this.obtainedNum != null && curRow > this.obtainedNum) { - return; - } - - if (name.equalsIgnoreCase("mergeCell")) { - throw new RuntimeException(Translator.get("i18n_excel_have_merge_region")); - } - //c => 单元格 - if ("c".equals(name)) { - //当前单元格的位置 - ref = attributes.getValue("r"); - //设定单元格类型 - this.setNextDataType(attributes); - } - - //当元素为t时 - if ("t".equals(name)) { - isTElement = true; - } else { - isTElement = false; - } - - //置空 - lastIndex = ""; - } - - /** - * 第二个执行 - * 得到单元格对应的索引值或是内容值 - * 如果单元格类型是字符串、INLINESTR、数字、日期,lastIndex则是索引值 - * 如果单元格类型是布尔值、错误、公式,lastIndex则是内容值 - * - * @param ch - * @param start - * @param length - * @throws SAXException - */ - @Override - public void characters(char[] ch, int start, int length) throws SAXException { - if (this.obtainedNum != null && curRow > this.obtainedNum) { - return; - } - lastIndex += new String(ch, start, length); - } - - /** - * 第三个执行 - * - * @param uri - * @param localName - * @param name - * @throws SAXException - */ - @Override - public void endElement(String uri, String localName, String name) throws SAXException { - if (this.obtainedNum != null && curRow > this.obtainedNum) { - return; - } - //t元素也包含字符串 - if (isTElement) { //这个程序没经过 - //将单元格内容加入rowlist中,在这之前先去掉字符串前后的空白符 - String value = lastIndex.trim(); - if (curRow == 1) { - TableField tableField = new TableField(); - tableField.setFieldType("TEXT"); - tableField.setFieldSize(65533); - tableField.setFieldName(value); - tableField.setRemarks(value); - this.fields.add(tableField); - } - cellList.add(curCol, value); - curCol++; - isTElement = false; - //如果里面某个单元格含有值,则标识该行不为空行 - if (value != null && !"".equals(value)) { - flag = true; - } - } else if ("v".equals(name)) { - //v => 单元格的值,如果单元格是字符串,则v标签的值为该字符串在SST中的索引 - String value = this.getDataValue(lastIndex.trim(), "");//根据索引值获取对应的单元格值 - if (preRef == null) { - preRef = "A" + curRow; - if (!preRef.equalsIgnoreCase(ref)) { - cellList.add(curCol, ""); - curCol++; - } - } - - //补全单元格之间的空单元格 - if (!"A".equals(preRef.substring(0, 1)) && curRow == 1 && preRef.equalsIgnoreCase(ref)) { - throw new RuntimeException(Translator.get("i18n_excel_empty_column")); - } else if (!ref.equals(preRef)) { - int len = countNullCell(ref, preRef); - for (int i = 0; i < len; i++) { - if (curCol < this.fields.size()) { - cellList.add(curCol, ""); - if (curRow == 1) { - addField("", curCol); - } - curCol++; - } - } - } - - if (curCol < this.fields.size()) { - cellList.add(curCol, value); - } - curCol++; - //如果里面某个单元格含有值,则标识该行不为空行 - if (value != null && !"".equals(value)) { - flag = true; - } - preRef = ref; - } else { - //如果标签名称为row,这说明已到行尾 - if ("row".equals(name)) { - //默认第一行为表头,以该行单元格数目为最大数目 - if (curRow == 1) { - maxRef = ref; - } - if (curRow > 1) { - for (int i = cellList.size(); i < this.fields.size(); i++) { - cellList.add(""); - } - List tmp = new ArrayList<>(cellList); - this.getData().add(tmp); - } - totalRows++; - cellList.clear(); - curRow++; - curCol = 0; - preRef = null; - ref = null; - flag = false; - } - } - } - - /** - * 处理数据类型 - * - * @param attributes - */ - public void setNextDataType(Attributes attributes) { - nextDataType = CellDataType.NUMBER; //cellType为空,则表示该单元格类型为数字 - formatIndex = -1; - formatString = null; - isDateFormat = false; - String cellType = attributes.getValue("t"); //单元格类型 - if ("b".equals(cellType)) { //处理布尔值 - nextDataType = CellDataType.BOOL; - } else if ("e".equals(cellType)) { //处理错误 - nextDataType = CellDataType.ERROR; - } else if ("inlineStr".equals(cellType)) { - nextDataType = CellDataType.INLINESTR; - } else if ("s".equals(cellType)) { //处理字符串 - nextDataType = CellDataType.SSTINDEX; - } else if ("str".equals(cellType)) { - nextDataType = CellDataType.SSTINDEX; - } - - String cellStyleStr = attributes.getValue("s"); // - if (cellStyleStr != null) { - int styleIndex = Integer.parseInt(cellStyleStr); - XSSFCellStyle style = this.stylesTable.getStyleAt(styleIndex); - formatIndex = style.getDataFormat(); - formatString = style.getDataFormatString(); - short format = this.formatIndex; - if ((14 <= format && format <= 17) || format == 20 || format == 22 || format == 31 || format == 35 || format == 45 || format == 46 || format == 47 || (57 <= format && format <= 59) - || (175 < format && format < 178) || (182 <= format && format <= 196) || (210 <= format && format <= 213) || (208 == format)) { // 日期 - isDateFormat = true; - } - - } - - } - - /** - * 对解析出来的数据进行类型处理 - * - * @param value 单元格的值, - * value代表解析:BOOL的为0或1, ERROR的为内容值,FORMULA的为内容值,INLINESTR的为索引值需转换为内容值, - * SSTINDEX的为索引值需转换为内容值, NUMBER为内容值,DATE为内容值 - * @param thisStr 一个空字符串 - * @return - */ - @SuppressWarnings("deprecation") - public String getDataValue(String value, String thisStr) { - String type = null; - switch (nextDataType) { - // 这几个的顺序不能随便交换,交换了很可能会导致数据错误 - case BOOL: //布尔值 - char first = value.charAt(0); - thisStr = first == '0' ? "FALSE" : "TRUE"; - type = "LONG"; - break; - case ERROR: //错误 - thisStr = "\"ERROR:" + value.toString() + '"'; - break; - case FORMULA: //公式 - thisStr = '"' + value.toString() + '"'; - type = getType(thisStr); - break; - case INLINESTR: - XSSFRichTextString rtsi = new XSSFRichTextString(value.toString()); - thisStr = rtsi.toString(); - rtsi = null; - break; - case SSTINDEX: //字符串 - String sstIndex = value.toString(); - try { - int idx = Integer.parseInt(sstIndex); - if (sst != null) { - XSSFRichTextString rtss = new XSSFRichTextString(sst.getEntryAt(idx));//根据idx索引值获取内容值 - thisStr = rtss.toString(); - rtss = null; - } else { - thisStr = value.toString(); - } - - } catch (NumberFormatException ex) { - thisStr = value.toString(); - } - - break; - case NUMBER: //数字 - if (formatString != null && isDateFormat) { - if (getDatasetTableFields() != null && getDatasetTableFields().get(curCol).getDeExtractType() == 1) { - thisStr = formatter.formatRawCellContents(Double.parseDouble(value), formatIndex, "yyyy-mm-dd hh:mm:ss").trim(); - } else { - thisStr = formatter.formatRawCellContents(Double.parseDouble(value), formatIndex, formatString).trim(); - } - } else { - thisStr = value; - } - thisStr = thisStr.replace("_", "").trim(); - - if (isDateFormat) { - type = "DATETIME"; - isDateFormat = false; - if (formatString != null && formatString.contains("%")) { - type = getType(thisStr); - } - } else { - type = getType(thisStr); - } - break; - case DATE: //日期 - thisStr = formatter.formatRawCellContents(Double.parseDouble(value), formatIndex, formatString); - // 对日期字符串作特殊处理,去掉T - thisStr = thisStr.replace("T", " "); - type = "DATETIME"; - break; - default: - thisStr = " "; - break; - } - if (curRow == 1) { - addField(thisStr, null); - } else { - if (CollectionUtils.isEmpty(this.getFields())) { - throw new RuntimeException(Translator.get("i18n_excel_header_empty")); - } - if (curCol >= this.fields.size()) { - return thisStr; - } - if (curRow == 2) { - if (type != null) { - this.getFields().get(curCol).setFieldType(type); - } - } else { - if (type != null) { - if (type.equalsIgnoreCase("TEXT")) { - this.getFields().get(curCol).setFieldType(type); - } - if (type.equalsIgnoreCase("DOUBLE") && this.getFields().get(curCol).getFieldType().equalsIgnoreCase("LONG")) { - this.getFields().get(curCol).setFieldType(type); - } - if (type.equalsIgnoreCase("DATETIME")) { - this.getFields().get(curCol).setFieldType(type); - } - } - } - } - return thisStr; - } - - private void addField(String columeName, Integer index) { - TableField tableField = new TableField(); - tableField.setFieldType("TEXT"); - tableField.setFieldSize(65533); - tableField.setFieldName(columeName); - tableField.setRemarks(columeName); - if (index != null) { - this.fields.add(index, tableField); - } else { - this.fields.add(tableField); - } - } - - private String getType(String thisStr) { - if (totalRows == 0) { - return "TEXT"; - } - - try { - if (thisStr.endsWith("%")) { - thisStr = thisStr.substring(0, thisStr.length() - 1); - thisStr = String.valueOf(Double.valueOf(thisStr) / 100); - } - Long.valueOf(thisStr); - return "LONG"; - } catch (Exception e) { - try { - Double.valueOf(thisStr); - return "DOUBLE"; - } catch (Exception ignore) { - } - } - return "TEXT"; - } - - public int countNullCell(String ref, String preRef) { - //excel2007最大行数是1048576,最大列数是16384,最后一列列名是XFD - String xfd = ref.replaceAll("\\d+", ""); - String xfd_1 = preRef.replaceAll("\\d+", ""); - - xfd = fillChar(xfd, 3, '@', true); - xfd_1 = fillChar(xfd_1, 3, '@', true); - - char[] letter = xfd.toCharArray(); - char[] letter_1 = xfd_1.toCharArray(); - int res = (letter[0] - letter_1[0]) * 26 * 26 + (letter[1] - letter_1[1]) * 26 + (letter[2] - letter_1[2]); - return res - 1; - } - - public String fillChar(String str, int len, char let, boolean isPre) { - int len_1 = str.length(); - if (len_1 < len) { - if (isPre) { - for (int i = 0; i < (len - len_1); i++) { - str = let + str; - } - } else { - for (int i = 0; i < (len - len_1); i++) { - str = str + let; - } - } - } - return str; - } - -} diff --git a/backend/src/main/java/io/dataease/commons/wrapper/XssAndSqlHttpServletRequestWrapper.java b/backend/src/main/java/io/dataease/commons/wrapper/XssAndSqlHttpServletRequestWrapper.java index 672f89d46a..0686f48b8f 100644 --- a/backend/src/main/java/io/dataease/commons/wrapper/XssAndSqlHttpServletRequestWrapper.java +++ b/backend/src/main/java/io/dataease/commons/wrapper/XssAndSqlHttpServletRequestWrapper.java @@ -1,18 +1,6 @@ package io.dataease.commons.wrapper; -import java.io.BufferedReader; -import java.io.ByteArrayInputStream; -import java.io.IOException; -import java.io.InputStreamReader; -import java.util.*; -import java.util.regex.Matcher; -import java.util.regex.Pattern; -import javax.servlet.ReadListener; -import javax.servlet.ServletInputStream; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletRequestWrapper; - import com.google.gson.Gson; import io.dataease.commons.holder.ThreadLocalContextHolder; import io.dataease.commons.utils.CommonBeanFactory; @@ -21,16 +9,30 @@ import org.apache.commons.lang3.StringUtils; import org.springframework.core.env.Environment; import org.springframework.util.StreamUtils; +import javax.servlet.ReadListener; +import javax.servlet.ServletInputStream; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletRequestWrapper; +import java.io.BufferedReader; +import java.io.ByteArrayInputStream; +import java.io.IOException; +import java.io.InputStreamReader; +import java.util.*; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + public class XssAndSqlHttpServletRequestWrapper extends HttpServletRequestWrapper { private static Gson gson = new Gson(); + private static final String defaultWhiteList = "/dataset/table/sqlPreview,/dataset/table/update,/dataset/field/multFieldValues,/dataset/field/linkMultFieldValues"; + HttpServletRequest orgRequest = null; private Map parameterMap; private final byte[] body; //用于保存读取body中数据 - public XssAndSqlHttpServletRequestWrapper(HttpServletRequest request) throws IOException{ + public XssAndSqlHttpServletRequestWrapper(HttpServletRequest request) throws IOException { super(request); orgRequest = request; parameterMap = request.getParameterMap(); @@ -38,6 +40,7 @@ public class XssAndSqlHttpServletRequestWrapper extends HttpServletRequestWrappe } // 重写几个HttpServletRequestWrapper中的方法 + /** * 获取所有参数名 * @@ -159,7 +162,6 @@ public class XssAndSqlHttpServletRequestWrapper extends HttpServletRequestWrappe } /** - * * 防止xss跨脚本攻击(替换,根据实际情况调整) */ @@ -208,9 +210,9 @@ public class XssAndSqlHttpServletRequestWrapper extends HttpServletRequestWrappe return value; } - public static boolean checkSqlInjection(Object obj){ + public static boolean checkSqlInjection(Object obj) { HttpServletRequest request = ServletUtils.request(); - String url = request.getRequestURI().toString(); + String url = request.getRequestURI(); if (null == obj) return false; if (StringUtils.isEmpty(obj.toString())) return false; @@ -219,14 +221,14 @@ public class XssAndSqlHttpServletRequestWrapper extends HttpServletRequestWrappe if (StringUtils.isEmpty(orders)) return false; - String whiteLists = CommonBeanFactory.getBean(Environment.class).getProperty("dataease.sqlinjection.whitelists", String.class, null); + String whiteLists = CommonBeanFactory.getBean(Environment.class).getProperty("dataease.sqlinjection.whitelists", String.class, defaultWhiteList); if (StringUtils.isNotEmpty(whiteLists)) { // 命中白名单 无需检测sql注入 if (Arrays.stream(whiteLists.split(",")).anyMatch(item -> url.indexOf(item) != -1)) return false; } - Pattern pattern= Pattern.compile("(.*\\=.*\\-\\-.*)|(.*(\\+).*)|(.*\\w+(%|\\$|#|&)\\w+.*)|(.*\\|\\|.*)|(.*\\s+(and|or)\\s+.*)" + + Pattern pattern = Pattern.compile("(.*\\=.*\\-\\-.*)|(.*(\\+).*)|(.*\\w+(%|\\$|#|&)\\w+.*)|(.*\\|\\|.*)|(.*\\s+(and|or)\\s+.*)" + "|(.*\\b(select|update|union|and|or|delete|insert|trancate|char|into|substr|ascii|declare|exec|count|master|into|drop|execute|sleep|extractvalue|updatexml|substring|database|concat|rand|gtid_subset)\\b.*)"); - Matcher matcher=pattern.matcher(orders.toLowerCase()); + Matcher matcher = pattern.matcher(orders.toLowerCase()); return matcher.find(); } @@ -236,7 +238,7 @@ public class XssAndSqlHttpServletRequestWrapper extends HttpServletRequestWrappe if (value != null) { boolean b = checkSqlInjection(value); - if(b) { + if (b) { ThreadLocalContextHolder.setData("包含SQL注入的参数,请检查参数!"); return true; } @@ -320,7 +322,7 @@ public class XssAndSqlHttpServletRequestWrapper extends HttpServletRequestWrappe return true; } } else if ((submitValues instanceof String[])) { - for (String submitValue : (String[])submitValues){ + for (String submitValue : (String[]) submitValues) { if (checkXSSAndSql(submitValue)) { return true; } @@ -332,7 +334,7 @@ public class XssAndSqlHttpServletRequestWrapper extends HttpServletRequestWrappe private static String orders(String json) { if (StringUtils.isEmpty(json)) return null; - try{ + try { Map map = new Gson().fromJson(json, Map.class); Object orders = map.get("orders"); @@ -345,7 +347,7 @@ public class XssAndSqlHttpServletRequestWrapper extends HttpServletRequestWrappe return sort.toString(); } return null; - }catch (Exception e) { + } catch (Exception e) { return null; } diff --git a/backend/src/main/java/io/dataease/controller/panel/AppLogController.java b/backend/src/main/java/io/dataease/controller/panel/AppLogController.java index 45a547acf3..207cbbb05e 100644 --- a/backend/src/main/java/io/dataease/controller/panel/AppLogController.java +++ b/backend/src/main/java/io/dataease/controller/panel/AppLogController.java @@ -3,6 +3,7 @@ package io.dataease.controller.panel; import com.github.pagehelper.Page; import com.github.pagehelper.PageHelper; import com.github.xiaoymin.knife4j.annotations.ApiSupport; +import io.dataease.auth.annotation.SqlInjectValidator; import io.dataease.commons.utils.PageUtils; import io.dataease.commons.utils.Pager; import io.dataease.controller.handler.annotation.I18n; @@ -35,6 +36,7 @@ public class AppLogController { @ApiImplicitParam(paramType = "path", name = "pageSize", value = "页容量", required = true, dataType = "Integer"), @ApiImplicitParam(name = "request", value = "查询条件", required = true) }) + @SqlInjectValidator(value = {"apply_time"}) public Pager> logGrid(@PathVariable int goPage, @PathVariable int pageSize, @RequestBody KeyGridRequest request) { Page page = PageHelper.startPage(goPage, pageSize, true); diff --git a/backend/src/main/java/io/dataease/controller/sys/SysPluginController.java b/backend/src/main/java/io/dataease/controller/sys/SysPluginController.java index 7f3b3e669f..d8e32122c4 100644 --- a/backend/src/main/java/io/dataease/controller/sys/SysPluginController.java +++ b/backend/src/main/java/io/dataease/controller/sys/SysPluginController.java @@ -3,10 +3,11 @@ package io.dataease.controller.sys; import com.github.pagehelper.Page; import com.github.pagehelper.PageHelper; import io.dataease.auth.annotation.SqlInjectValidator; -import io.dataease.plugins.common.base.domain.MyPlugin; +import io.dataease.commons.utils.DeFileUtils; import io.dataease.commons.utils.PageUtils; import io.dataease.commons.utils.Pager; import io.dataease.controller.sys.base.BaseGridRequest; +import io.dataease.plugins.common.base.domain.MyPlugin; import io.dataease.service.sys.PluginService; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; @@ -41,6 +42,7 @@ public class SysPluginController { @PostMapping("upload") @RequiresPermissions("plugin:upload") public Map localUpload(@RequestParam("file") MultipartFile file) throws Exception { + DeFileUtils.validateFile(file); return pluginService.localInstall(file); } @@ -54,7 +56,8 @@ public class SysPluginController { @ApiOperation("更新插件") @PostMapping("/update/{pluginId}") @RequiresPermissions("plugin:upload") - public Map update(@PathVariable("pluginId") Long pluginId, @RequestParam("file") MultipartFile file) throws Exception{ + public Map update(@PathVariable("pluginId") Long pluginId, @RequestParam("file") MultipartFile file) throws Exception { + DeFileUtils.validateFile(file); if (pluginService.uninstall(pluginId)) { return pluginService.localInstall(file); } diff --git a/backend/src/main/java/io/dataease/controller/sys/SysUserController.java b/backend/src/main/java/io/dataease/controller/sys/SysUserController.java index 38e335dcdd..5f46a52c0d 100644 --- a/backend/src/main/java/io/dataease/controller/sys/SysUserController.java +++ b/backend/src/main/java/io/dataease/controller/sys/SysUserController.java @@ -4,10 +4,13 @@ import com.github.pagehelper.Page; import com.github.pagehelper.PageHelper; import com.github.xiaoymin.knife4j.annotations.ApiSupport; import io.dataease.auth.annotation.DeLog; +import io.dataease.auth.annotation.DePermission; import io.dataease.auth.annotation.SqlInjectValidator; import io.dataease.auth.api.dto.CurrentUserDto; import io.dataease.auth.entity.AccountLockStatus; import io.dataease.auth.service.AuthUserService; +import io.dataease.commons.constants.DePermissionType; +import io.dataease.commons.constants.ResourceAuthLevel; import io.dataease.commons.constants.SysLogConstants; import io.dataease.commons.exception.DEException; import io.dataease.commons.utils.AuthUtils; @@ -102,6 +105,19 @@ public class SysUserController { return users; } + @DePermission(type = DePermissionType.DATASET, level = ResourceAuthLevel.DATASET_LEVEL_MANAGE) + @PostMapping("/userGrid/{datasetId}") + @ApiImplicitParams({ + @ApiImplicitParam(paramType = "path", name = "goPage", value = "页码", required = true, dataType = "Integer"), + @ApiImplicitParam(paramType = "path", name = "pageSize", value = "页容量", required = true, dataType = "Integer"), + @ApiImplicitParam(name = "request", value = "查询条件", required = true) + }) + @SqlInjectValidator(value = {"create_time", "u.enabled", "nick_name", "u.dept_id"}) + public Pager> userGrids(@PathVariable String datasetId, @RequestBody KeyGridRequest request) { + return userGrid(0, 0, request); + } + + @ApiOperation("创建用户") @RequiresPermissions("user:add") @PostMapping("/create") diff --git a/backend/src/main/java/io/dataease/ext/ExtDataSourceMapper.java b/backend/src/main/java/io/dataease/ext/ExtDataSourceMapper.java index f3ca151aa7..2ea36a98bf 100644 --- a/backend/src/main/java/io/dataease/ext/ExtDataSourceMapper.java +++ b/backend/src/main/java/io/dataease/ext/ExtDataSourceMapper.java @@ -10,7 +10,7 @@ import java.util.List; public interface ExtDataSourceMapper { - List query(GridExample example); + // List query(GridExample example); List queryUnion(DatasourceUnionRequest request); diff --git a/backend/src/main/java/io/dataease/ext/ExtPanelViewLinkageMapper.xml b/backend/src/main/java/io/dataease/ext/ExtPanelViewLinkageMapper.xml index 8fcc5c4476..88629926ca 100644 --- a/backend/src/main/java/io/dataease/ext/ExtPanelViewLinkageMapper.xml +++ b/backend/src/main/java/io/dataease/ext/ExtPanelViewLinkageMapper.xml @@ -61,7 +61,7 @@ dataset_table_field.origin_name, dataset_table_field.`name`, dataset_table_field.de_type - from dataset_table_field where table_id = #{table_id} + from dataset_table_field where dataset_table_field.group_type = 'd' and table_id = #{table_id}