瀏覽代碼

修复两处存在SQL注入漏洞问题

RuoYi 4 年之前
父節點
當前提交
af479c7838

+ 14 - 0
ruoyi-common/ruoyi-common-datascope/src/main/java/com/ruoyi/common/datascope/aspect/DataScopeAspect.java

@@ -68,6 +68,7 @@ public class DataScopeAspect
68 68
     @Before("dataScopePointCut()")
69 69
     public void doBefore(JoinPoint point) throws Throwable
70 70
     {
71
+        clearDataScope(point);
71 72
         handleDataScope(point);
72 73
     }
73 74
 
@@ -169,4 +170,17 @@ public class DataScopeAspect
169 170
         }
170 171
         return null;
171 172
     }
173
+
174
+    /**
175
+     * 拼接权限sql前先清空params.dataScope参数防止注入
176
+     */
177
+    private void clearDataScope(final JoinPoint joinPoint)
178
+    {
179
+        Object params = joinPoint.getArgs()[0];
180
+        if (StringUtils.isNotNull(params) && params instanceof BaseEntity)
181
+        {
182
+            BaseEntity baseEntity = (BaseEntity) params;
183
+            baseEntity.getParams().put(DATA_SCOPE, "");
184
+        }
185
+    }
172 186
 }

+ 1 - 1
ruoyi-modules/ruoyi-system/src/main/resources/mapper/system/SysDeptMapper.xml

@@ -147,7 +147,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
147 147
  	        <if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if>
148 148
  	        update_time = sysdate()
149 149
         </set>
150
- 	    where dept_id in (${ancestors})
150
+ 	    where find_in_set(#{deptId}, ancestors)
151 151
 	</update>
152 152
 	
153 153
 	<delete id="deleteDeptById" parameterType="Long">