diff --git a/src/backend/ci/core/log/api-log/src/main/kotlin/com/tencent/devops/log/api/ServiceLogResource.kt b/src/backend/ci/core/log/api-log/src/main/kotlin/com/tencent/devops/log/api/ServiceLogResource.kt index 56eb34be5b7d..8291f5aa9421 100644 --- a/src/backend/ci/core/log/api-log/src/main/kotlin/com/tencent/devops/log/api/ServiceLogResource.kt +++ b/src/backend/ci/core/log/api-log/src/main/kotlin/com/tencent/devops/log/api/ServiceLogResource.kt @@ -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 @@ -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 @@ -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 @Operation(summary = "获取某行前的日志") @@ -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 @Operation(summary = "下载日志接口") diff --git a/src/backend/ci/core/log/biz-log/src/main/kotlin/com/tencent/devops/log/resources/ServiceLogResourceImpl.kt b/src/backend/ci/core/log/biz-log/src/main/kotlin/com/tencent/devops/log/resources/ServiceLogResourceImpl.kt index 3a1487102214..5da25e9ae4ec 100644 --- a/src/backend/ci/core/log/biz-log/src/main/kotlin/com/tencent/devops/log/resources/ServiceLogResourceImpl.kt +++ b/src/backend/ci/core/log/biz-log/src/main/kotlin/com/tencent/devops/log/resources/ServiceLogResourceImpl.kt @@ -65,6 +65,7 @@ class ServiceLogResourceImpl @Autowired constructor( jobId: String?, stepId: String?, archiveFlag: Boolean?, + checkPermissionFlag: Boolean, reverse: Boolean? ): Result { return buildLogQueryService.getInitLogs( @@ -81,7 +82,8 @@ class ServiceLogResourceImpl @Autowired constructor( jobId = jobId, stepId = stepId, archiveFlag = archiveFlag, - reverse = reverse ?: false + reverse = reverse ?: false, + checkPermissionFlag = checkPermissionFlag ) } @@ -101,7 +103,8 @@ class ServiceLogResourceImpl @Autowired constructor( executeCount: Int?, jobId: String?, stepId: String?, - archiveFlag: Boolean? + archiveFlag: Boolean?, + checkPermissionFlag: Boolean ): Result { return buildLogQueryService.getMoreLogs( userId = userId, @@ -119,7 +122,8 @@ class ServiceLogResourceImpl @Autowired constructor( executeCount = executeCount, jobId = jobId, stepId = stepId, - archiveFlag = archiveFlag + archiveFlag = archiveFlag, + checkPermissionFlag = checkPermissionFlag ) } @@ -136,7 +140,8 @@ class ServiceLogResourceImpl @Autowired constructor( executeCount: Int?, jobId: String?, stepId: String?, - archiveFlag: Boolean? + archiveFlag: Boolean?, + checkPermissionFlag: Boolean ): Result { return buildLogQueryService.getAfterLogs( userId = userId, @@ -151,7 +156,8 @@ class ServiceLogResourceImpl @Autowired constructor( executeCount = executeCount, jobId = jobId, stepId = stepId, - archiveFlag = archiveFlag + archiveFlag = archiveFlag, + checkPermissionFlag = checkPermissionFlag ) } diff --git a/src/backend/ci/core/log/biz-log/src/main/kotlin/com/tencent/devops/log/service/BuildLogQueryService.kt b/src/backend/ci/core/log/biz-log/src/main/kotlin/com/tencent/devops/log/service/BuildLogQueryService.kt index 54f05636ca2f..0431fcfa7b50 100644 --- a/src/backend/ci/core/log/biz-log/src/main/kotlin/com/tencent/devops/log/service/BuildLogQueryService.kt +++ b/src/backend/ci/core/log/biz-log/src/main/kotlin/com/tencent/devops/log/service/BuildLogQueryService.kt @@ -67,16 +67,19 @@ class BuildLogQueryService @Autowired constructor( jobId: String?, stepId: String?, archiveFlag: Boolean? = null, + checkPermissionFlag: Boolean = true, reverse: Boolean? ): Result { - 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 { @@ -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 { - 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 { @@ -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 { - 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 { diff --git a/src/backend/ci/core/store/biz-store/src/main/kotlin/com/tencent/devops/store/common/service/impl/StoreLogServiceImpl.kt b/src/backend/ci/core/store/biz-store/src/main/kotlin/com/tencent/devops/store/common/service/impl/StoreLogServiceImpl.kt index a17e84c6528a..bf619636973a 100644 --- a/src/backend/ci/core/store/biz-store/src/main/kotlin/com/tencent/devops/store/common/service/impl/StoreLogServiceImpl.kt +++ b/src/backend/ci/core/store/biz-store/src/main/kotlin/com/tencent/devops/store/common/service/impl/StoreLogServiceImpl.kt @@ -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) @@ -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) @@ -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)