Open
Conversation
### 1. JPA getOne() 替换为 findOne() (高优先级) 问题 : getOne() 在实体不存在时会抛出 EntityNotFoundException 运行时异常,而不是返回null,这会导致接口在查询不存在的数据时报500错误。 修复文件 : - ArticleServiceImpl.java:55,89,125 - 3处 - CategoryServiceImpl.java:33,46 - 2处 - TagServiceImpl.java:33,46 - 2处 - CommentServiceImpl.java:45 - 1处 ### 2. Controller层错误码错误 (中优先级) 问题 : 复制粘贴导致的错误码使用错误,在ID为空时错误地返回了 USER_NOT_EXIST (用户不存在) 而不是 PARAM_IS_BLANK (参数为空)。 修复文件 : - CategoryController.java:110 - TagController.java:119 - ArticleController.java:176 ### 3. TagController命名错误 (低优先级) 问题 : 复制粘贴导致的方法名和变量名错误, listCategorysDetail 应该是 listTagsDetail 。 修复文件 : - TagController.java:49-52 ### 4. UploadController缺少@RequestParam (中优先级) 问题 : Spring MVC文件上传需要 @RequestParam 注解才能正确绑定MultipartFile参数。 修复文件 : - UploadController.java:35 - 添加 @RequestParam("image") 注解 ### 5. OAuthSessionManager空指针问题 (中优先级) 问题 : 当请求头中没有 Oauth-Token 时,直接返回null会导致后续空指针异常。 修复 : 添加了空值判断和降级处理。 ### 修复原则 - 不影响现有功能 : 所有修复都是基于原有逻辑的bug修复,没有改变业务流程 - 最小化改动 : 只修复明确的bug,不进行重构 - 向后兼容 : 修复后的接口行为与预期一致,不会破坏前端调用 利用模型 【DOUBAO-DOGFOOD】 纠正接口,并且简单验证没有影响原始代码
### 1. 错误码使用错误(高优先级) 文件 问题 修复 CategoryController.java:108 更新分类时,id为空返回 USER_NOT_EXIST 错误码 改为 PARAM_IS_BLANK UserController.java:110 更新用户时,id为空返回 USER_NOT_EXIST 错误码 改为 PARAM_IS_BLANK ### 2. 空指针异常风险(高优先级) 文件 问题 修复 ArticleServiceImpl.java:88 updateArticle 方法未检查文章是否存在 添加null检查 ArticleServiceImpl.java:126 getArticleAndAddViews 方法未检查文章是否存在 添加null检查 CommentServiceImpl.java:73 saveCommentAndChangeCounts 方法未检查文章是否存在 添加null检查 CommentServiceImpl.java:100 deleteCommentByIdAndChangeCounts 方法未检查评论是否存在 添加null检查 CategoryServiceImpl.java:44 updateCategory 方法未检查分类是否存在 添加null检查 TagServiceImpl.java:45 updateTag 方法未检查标签是否存在 添加null检查 UserServiceImpl.java:58 updateUser 方法未检查用户是否存在 添加null检查 ### 3. JPA方法使用不当(中优先级) 文件 问题 修复 CategoryServiceImpl.java:31 使用 getOne() 方法,当实体不存在时抛出异常 改为 findOne() 方法 ### 4. SQL注入风险(高优先级) 文件 问题 修复 ArticleRepositoryImpl.java:30-50 排序字段直接拼接到HQL中,存在SQL注入风险 添加白名单验证,只允许预定义的排序字段 ### 5. 文件上传安全问题(中优先级) 文件 问题 修复 UploadController.java:55 1. 未验证文件类型 2. 文件名未完全过滤特殊字符 3. 未检查路径遍历攻击 1. 添加文件扩展名白名单验证 2. 过滤文件名特殊字符 3. 添加路径遍历检查 ### 6. Controller层返回值处理(中优先级) 文件 问题 修复 ArticleController.java 更新文章时未处理Service返回null的情况 添加null检查并返回 RESULE_DATA_NONE 错误码 CategoryController.java 更新分类时未处理Service返回null的情况 添加null检查并返回 RESULE_DATA_NONE 错误码 TagController.java 更新标签时未处理Service返回null的情况 添加null检查并返回 RESULE_DATA_NONE 错误码 UserController.java 更新用户时未处理Service返回null的情况 添加null检查并返回 RESULE_DATA_NONE 错误码 CommentController.java 添加评论时未处理Service返回null的情况 添加null检查并返回错误响应 利用模型 【glm5】 纠正接口,并且简单验证没有影响原始代码
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.