-
Notifications
You must be signed in to change notification settings - Fork 5
fix: 修复审查发现的安全与公开接口问题 #17
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -47,5 +47,6 @@ plan.md | |
| ### Docker 运行时数据与敏感配置 ### | ||
| .env | ||
| .env.properties | ||
| tmp_*secrets*.txt | ||
| config/rootCA.pem | ||
| config/nginx/certs/ | ||
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
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
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
57 changes: 57 additions & 0 deletions
57
...mortise-product-api/src/main/java/com/rymcu/mortise/product/api/dto/ApiProductModels.java
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,57 @@ | ||
| package com.rymcu.mortise.product.api.dto; | ||
|
|
||
| import com.fasterxml.jackson.annotation.JsonFormat; | ||
| import lombok.Data; | ||
|
|
||
| import java.time.LocalDateTime; | ||
| import java.util.List; | ||
| import java.util.Map; | ||
|
|
||
| public final class ApiProductModels { | ||
|
|
||
| private ApiProductModels() { | ||
| } | ||
|
|
||
| @Data | ||
| public static class ProductDetailVO { | ||
|
|
||
| private Long id; | ||
| private String productCode; | ||
| private String title; | ||
| private String subtitle; | ||
| private String description; | ||
| private String shortDescription; | ||
| private String coverImageUrl; | ||
| private List<String> galleryImages; | ||
| private String productType; | ||
| private Long categoryId; | ||
| private String[] tags; | ||
| private Map<String, Object> features; | ||
| private Map<String, Object> specifications; | ||
| private String seoTitle; | ||
| private String seoDescription; | ||
| private String seoKeywords; | ||
| private Integer status; | ||
| private Boolean isFeatured; | ||
| private Integer sortNo; | ||
| @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") | ||
| private LocalDateTime createdTime; | ||
| @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") | ||
| private LocalDateTime updatedTime; | ||
| @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") | ||
| private LocalDateTime publishedTime; | ||
| private List<SkuTargetVO> skuTargets; | ||
| } | ||
|
|
||
| @Data | ||
| public static class SkuTargetVO { | ||
|
|
||
| private Long id; | ||
| private Long productSkuId; | ||
| private String targetType; | ||
| private Long targetId; | ||
| private Integer quantity; | ||
| private Integer validityDays; | ||
| private String accessLevel; | ||
| } | ||
| } | ||
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
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
19 changes: 19 additions & 0 deletions
19
...-application/src/main/java/com/rymcu/mortise/product/service/ProductSkuTargetService.java
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| package com.rymcu.mortise.product.service; | ||
|
|
||
| import com.mybatisflex.core.service.IService; | ||
| import com.rymcu.mortise.product.entity.ProductSkuTarget; | ||
|
|
||
| import java.util.Collection; | ||
| import java.util.List; | ||
|
|
||
| /** | ||
| * 产品 SKU 目标映射服务 | ||
| * | ||
| * @author ronger | ||
| */ | ||
| public interface ProductSkuTargetService extends IService<ProductSkuTarget> { | ||
|
|
||
| List<ProductSkuTarget> findByProductSkuId(Long productSkuId); | ||
|
|
||
| List<ProductSkuTarget> findByProductSkuIds(Collection<Long> productSkuIds); | ||
| } |
39 changes: 39 additions & 0 deletions
39
...ion/src/main/java/com/rymcu/mortise/product/service/impl/ProductSkuTargetServiceImpl.java
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,39 @@ | ||
| package com.rymcu.mortise.product.service.impl; | ||
|
|
||
| import com.mybatisflex.core.query.QueryWrapper; | ||
| import com.mybatisflex.spring.service.impl.ServiceImpl; | ||
| import com.rymcu.mortise.product.entity.ProductSkuTarget; | ||
| import com.rymcu.mortise.product.mapper.ProductSkuTargetMapper; | ||
| import com.rymcu.mortise.product.service.ProductSkuTargetService; | ||
| import org.springframework.stereotype.Service; | ||
|
|
||
| import java.util.Collection; | ||
| import java.util.List; | ||
|
|
||
| import static com.rymcu.mortise.product.entity.table.ProductSkuTargetTableDef.PRODUCT_SKU_TARGET; | ||
|
|
||
| @Service | ||
| public class ProductSkuTargetServiceImpl extends ServiceImpl<ProductSkuTargetMapper, ProductSkuTarget> | ||
| implements ProductSkuTargetService { | ||
|
|
||
| @Override | ||
| public List<ProductSkuTarget> findByProductSkuId(Long productSkuId) { | ||
| return mapper.selectListByQuery( | ||
| QueryWrapper.create() | ||
| .where(PRODUCT_SKU_TARGET.PRODUCT_SKU_ID.eq(productSkuId)) | ||
| .orderBy(PRODUCT_SKU_TARGET.CREATED_TIME.asc()) | ||
| ); | ||
| } | ||
|
|
||
| @Override | ||
| public List<ProductSkuTarget> findByProductSkuIds(Collection<Long> productSkuIds) { | ||
| if (productSkuIds == null || productSkuIds.isEmpty()) { | ||
| return List.of(); | ||
| } | ||
| return mapper.selectListByQuery( | ||
| QueryWrapper.create() | ||
| .where(PRODUCT_SKU_TARGET.PRODUCT_SKU_ID.in(productSkuIds)) | ||
| .orderBy(PRODUCT_SKU_TARGET.PRODUCT_SKU_ID.asc(), PRODUCT_SKU_TARGET.CREATED_TIME.asc()) | ||
| ); | ||
| } | ||
| } |
15 changes: 15 additions & 0 deletions
15
...n/src/main/java/com/rymcu/mortise/product/service/query/ProductSkuTargetQueryService.java
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| package com.rymcu.mortise.product.service.query; | ||
|
|
||
| import com.rymcu.mortise.product.entity.ProductSkuTarget; | ||
|
|
||
| import java.util.Collection; | ||
| import java.util.List; | ||
|
|
||
| public interface ProductSkuTargetQueryService { | ||
|
|
||
| List<ProductSkuTarget> findByProductSkuId(Long productSkuId); | ||
|
|
||
| List<ProductSkuTarget> findByProductSkuIds(Collection<Long> productSkuIds); | ||
|
|
||
| ProductSkuTarget getById(Long id); | ||
| } |
34 changes: 34 additions & 0 deletions
34
...n/java/com/rymcu/mortise/product/service/query/impl/ProductSkuTargetQueryServiceImpl.java
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| package com.rymcu.mortise.product.service.query.impl; | ||
|
|
||
| import com.rymcu.mortise.product.entity.ProductSkuTarget; | ||
| import com.rymcu.mortise.product.service.ProductSkuTargetService; | ||
| import com.rymcu.mortise.product.service.query.ProductSkuTargetQueryService; | ||
| import org.springframework.stereotype.Service; | ||
|
|
||
| import java.util.Collection; | ||
| import java.util.List; | ||
|
|
||
| @Service | ||
| public class ProductSkuTargetQueryServiceImpl implements ProductSkuTargetQueryService { | ||
|
|
||
| private final ProductSkuTargetService productSkuTargetService; | ||
|
|
||
| public ProductSkuTargetQueryServiceImpl(ProductSkuTargetService productSkuTargetService) { | ||
| this.productSkuTargetService = productSkuTargetService; | ||
| } | ||
|
|
||
| @Override | ||
| public List<ProductSkuTarget> findByProductSkuId(Long productSkuId) { | ||
| return productSkuTargetService.findByProductSkuId(productSkuId); | ||
| } | ||
|
|
||
| @Override | ||
| public List<ProductSkuTarget> findByProductSkuIds(Collection<Long> productSkuIds) { | ||
| return productSkuTargetService.findByProductSkuIds(productSkuIds); | ||
| } | ||
|
|
||
| @Override | ||
| public ProductSkuTarget getById(Long id) { | ||
| return productSkuTargetService.getById(id); | ||
| } | ||
| } |
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ProductDetailVO继承了Product实体类,会把createdBy、delFlag等领域/持久化字段一并暴露到公开接口返回值中,这与 PR 描述里“隐藏内部元数据、删除标记等字段”的目标相冲突,也容易造成不必要的数据泄露。建议改为独立的 DTO(只声明需要对外暴露的字段),或至少通过@JsonIgnoreProperties/@JsonIgnore明确屏蔽这些内部字段,而不是继承实体。