Skip to content

Commit

Permalink
Merge pull request #11226 from Kzhou991/issue-11208
Browse files Browse the repository at this point in the history
bug:研发商店组件上架查看日志权限优化 #11208
  • Loading branch information
bkci-bot authored Nov 19, 2024
2 parents 85c27a0 + fe86829 commit 4e9397b
Show file tree
Hide file tree
Showing 4 changed files with 70 additions and 39 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,16 +34,17 @@ import com.tencent.devops.common.log.pojo.QueryLogLineNum
import com.tencent.devops.common.log.pojo.QueryLogStatus
import com.tencent.devops.common.log.pojo.QueryLogs
import com.tencent.devops.common.log.pojo.enums.LogType
import io.swagger.v3.oas.annotations.tags.Tag
import io.swagger.v3.oas.annotations.Operation
import io.swagger.v3.oas.annotations.Parameter
import io.swagger.v3.oas.annotations.tags.Tag
import javax.ws.rs.Consumes
import javax.ws.rs.GET
import javax.ws.rs.HeaderParam
import javax.ws.rs.Path
import javax.ws.rs.PathParam
import javax.ws.rs.Produces
import javax.ws.rs.HeaderParam
import javax.ws.rs.PathParam
import javax.ws.rs.QueryParam
import javax.ws.rs.DefaultValue
import javax.ws.rs.core.MediaType
import javax.ws.rs.core.Response

Expand Down Expand Up @@ -101,6 +102,10 @@ interface ServiceLogResource {
@Parameter(description = "是否查询归档数据", required = false)
@QueryParam("archiveFlag")
archiveFlag: Boolean? = false,
@Parameter(description = "是否校验流水线权限", required = false)
@DefaultValue("true")
@QueryParam("checkPermissionFlag")
checkPermissionFlag: Boolean = true,
@Parameter(description = "查询结果是否倒序,默认false", required = false)
@QueryParam("reverse")
reverse: Boolean? = false
Expand Down Expand Up @@ -157,7 +162,11 @@ interface ServiceLogResource {
stepId: String?,
@Parameter(description = "是否查询归档数据", required = false)
@QueryParam("archiveFlag")
archiveFlag: Boolean? = false
archiveFlag: Boolean? = false,
@Parameter(description = "是否校验流水线权限", required = false)
@DefaultValue("true")
@QueryParam("checkPermissionFlag")
checkPermissionFlag: Boolean = true
): Result<QueryLogs>

@Operation(summary = "获取某行前的日志")
Expand Down Expand Up @@ -202,7 +211,11 @@ interface ServiceLogResource {
stepId: String?,
@Parameter(description = "是否查询归档数据", required = false)
@QueryParam("archiveFlag")
archiveFlag: Boolean? = false
archiveFlag: Boolean? = false,
@Parameter(description = "是否校验流水线权限", required = false)
@DefaultValue("true")
@QueryParam("checkPermissionFlag")
checkPermissionFlag: Boolean = true
): Result<QueryLogs>

@Operation(summary = "下载日志接口")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ class ServiceLogResourceImpl @Autowired constructor(
jobId: String?,
stepId: String?,
archiveFlag: Boolean?,
checkPermissionFlag: Boolean,
reverse: Boolean?
): Result<QueryLogs> {
return buildLogQueryService.getInitLogs(
Expand All @@ -81,7 +82,8 @@ class ServiceLogResourceImpl @Autowired constructor(
jobId = jobId,
stepId = stepId,
archiveFlag = archiveFlag,
reverse = reverse ?: false
reverse = reverse ?: false,
checkPermissionFlag = checkPermissionFlag
)
}

Expand All @@ -101,7 +103,8 @@ class ServiceLogResourceImpl @Autowired constructor(
executeCount: Int?,
jobId: String?,
stepId: String?,
archiveFlag: Boolean?
archiveFlag: Boolean?,
checkPermissionFlag: Boolean
): Result<QueryLogs> {
return buildLogQueryService.getMoreLogs(
userId = userId,
Expand All @@ -119,7 +122,8 @@ class ServiceLogResourceImpl @Autowired constructor(
executeCount = executeCount,
jobId = jobId,
stepId = stepId,
archiveFlag = archiveFlag
archiveFlag = archiveFlag,
checkPermissionFlag = checkPermissionFlag
)
}

Expand All @@ -136,7 +140,8 @@ class ServiceLogResourceImpl @Autowired constructor(
executeCount: Int?,
jobId: String?,
stepId: String?,
archiveFlag: Boolean?
archiveFlag: Boolean?,
checkPermissionFlag: Boolean
): Result<QueryLogs> {
return buildLogQueryService.getAfterLogs(
userId = userId,
Expand All @@ -151,7 +156,8 @@ class ServiceLogResourceImpl @Autowired constructor(
executeCount = executeCount,
jobId = jobId,
stepId = stepId,
archiveFlag = archiveFlag
archiveFlag = archiveFlag,
checkPermissionFlag = checkPermissionFlag
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,16 +67,19 @@ class BuildLogQueryService @Autowired constructor(
jobId: String?,
stepId: String?,
archiveFlag: Boolean? = null,
checkPermissionFlag: Boolean = true,
reverse: Boolean?
): Result<QueryLogs> {
validateAuth(
userId = userId,
projectId = projectId,
pipelineId = pipelineId,
buildId = buildId,
permission = AuthPermission.VIEW,
archiveFlag = archiveFlag
)
if (checkPermissionFlag) {
validateAuth(
userId = userId,
projectId = projectId,
pipelineId = pipelineId,
buildId = buildId,
permission = AuthPermission.VIEW,
archiveFlag = archiveFlag
)
}
val startEpoch = System.currentTimeMillis()
var success = false
val queryLogs = try {
Expand Down Expand Up @@ -168,16 +171,19 @@ class BuildLogQueryService @Autowired constructor(
subTag: String? = null,
jobId: String?,
stepId: String?,
archiveFlag: Boolean? = null
archiveFlag: Boolean? = null,
checkPermissionFlag: Boolean = true
): Result<QueryLogs> {
validateAuth(
userId = userId,
projectId = projectId,
pipelineId = pipelineId,
buildId = buildId,
permission = AuthPermission.VIEW,
archiveFlag = archiveFlag
)
if (checkPermissionFlag) {
validateAuth(
userId = userId,
projectId = projectId,
pipelineId = pipelineId,
buildId = buildId,
permission = AuthPermission.VIEW,
archiveFlag = archiveFlag
)
}
val startEpoch = System.currentTimeMillis()
var success = false
val queryLogs = try {
Expand Down Expand Up @@ -219,16 +225,19 @@ class BuildLogQueryService @Autowired constructor(
subTag: String? = null,
jobId: String?,
stepId: String?,
archiveFlag: Boolean? = null
archiveFlag: Boolean? = null,
checkPermissionFlag: Boolean = true
): Result<QueryLogs> {
validateAuth(
userId = userId,
projectId = projectId,
pipelineId = pipelineId,
buildId = buildId,
permission = AuthPermission.VIEW,
archiveFlag = archiveFlag
)
if (checkPermissionFlag) {
validateAuth(
userId = userId,
projectId = projectId,
pipelineId = pipelineId,
buildId = buildId,
permission = AuthPermission.VIEW,
archiveFlag = archiveFlag
)
}
val startEpoch = System.currentTimeMillis()
var success = false
val queryLogs = try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,8 @@ class StoreLogServiceImpl @Autowired constructor(
containerHashId = null,
executeCount = executeCount,
jobId = null,
stepId = null
stepId = null,
checkPermissionFlag = false
)
if (queryLogsResult.isNotOk()) {
return Result(status = queryLogsResult.status, message = queryLogsResult.message, data = null)
Expand Down Expand Up @@ -116,7 +117,8 @@ class StoreLogServiceImpl @Autowired constructor(
containerHashId = null,
executeCount = executeCount,
jobId = null,
stepId = null
stepId = null,
checkPermissionFlag = false
)
if (queryLogsResult.isNotOk()) {
return Result(status = queryLogsResult.status, message = queryLogsResult.message, data = null)
Expand Down Expand Up @@ -157,7 +159,8 @@ class StoreLogServiceImpl @Autowired constructor(
containerHashId = null,
executeCount = executeCount,
jobId = null,
stepId = null
stepId = null,
checkPermissionFlag = false
)
if (queryLogsResult.isNotOk()) {
return Result(status = queryLogsResult.status, message = queryLogsResult.message, data = null)
Expand Down

0 comments on commit 4e9397b

Please sign in to comment.