diff --git a/src/backend/analyst/api-analyst/src/main/kotlin/com/tencent/bkrepo/analyst/api/ScanClient.kt b/src/backend/analyst/api-analyst/src/main/kotlin/com/tencent/bkrepo/analyst/api/ScanClient.kt index 6f671f73cb..3521f3c808 100644 --- a/src/backend/analyst/api-analyst/src/main/kotlin/com/tencent/bkrepo/analyst/api/ScanClient.kt +++ b/src/backend/analyst/api-analyst/src/main/kotlin/com/tencent/bkrepo/analyst/api/ScanClient.kt @@ -106,4 +106,10 @@ interface ScanClient { * */ @GetMapping("/token/verify") fun verifyToken(@RequestParam subtaskId: String, @RequestParam token: String): Response + + /** + * 查询task状态 + * */ + @GetMapping("/task/{taskId}") + fun getTask(@PathVariable taskId: String): Response } diff --git a/src/backend/analyst/biz-analyst/src/main/kotlin/com/tencent/bkrepo/analyst/controller/ScanController.kt b/src/backend/analyst/biz-analyst/src/main/kotlin/com/tencent/bkrepo/analyst/controller/ScanController.kt index a7b6a2643b..dba344c0e6 100644 --- a/src/backend/analyst/biz-analyst/src/main/kotlin/com/tencent/bkrepo/analyst/controller/ScanController.kt +++ b/src/backend/analyst/biz-analyst/src/main/kotlin/com/tencent/bkrepo/analyst/controller/ScanController.kt @@ -35,6 +35,7 @@ import com.tencent.bkrepo.analyst.pojo.license.SpdxLicenseInfo import com.tencent.bkrepo.analyst.pojo.request.ReportResultRequest import com.tencent.bkrepo.analyst.pojo.request.ScanRequest import com.tencent.bkrepo.analyst.service.ScanService +import com.tencent.bkrepo.analyst.service.ScanTaskService import com.tencent.bkrepo.analyst.service.SpdxLicenseService import com.tencent.bkrepo.analyst.service.TemporaryScanTokenService import com.tencent.bkrepo.common.api.pojo.Response @@ -48,7 +49,8 @@ import org.springframework.web.bind.annotation.RestController class ScanController @Autowired constructor( private val scanService: ScanService, private val licenseService: SpdxLicenseService, - private val tokenService: TemporaryScanTokenService + private val tokenService: TemporaryScanTokenService, + private val scanTaskService: ScanTaskService, ) : ScanClient { override fun scan(scanRequest: ScanRequest): Response { @@ -88,4 +90,8 @@ class ScanController @Autowired constructor( } return ResponseBuilder.success(ret) } + + override fun getTask(taskId: String): Response { + return ResponseBuilder.success(scanTaskService.task(taskId)) + } } diff --git a/src/backend/analyst/biz-analyst/src/main/kotlin/com/tencent/bkrepo/analyst/service/impl/ScanTaskServiceImpl.kt b/src/backend/analyst/biz-analyst/src/main/kotlin/com/tencent/bkrepo/analyst/service/impl/ScanTaskServiceImpl.kt index c9b98d2ae1..53a990ec73 100644 --- a/src/backend/analyst/biz-analyst/src/main/kotlin/com/tencent/bkrepo/analyst/service/impl/ScanTaskServiceImpl.kt +++ b/src/backend/analyst/biz-analyst/src/main/kotlin/com/tencent/bkrepo/analyst/service/impl/ScanTaskServiceImpl.kt @@ -107,8 +107,11 @@ class ScanTaskServiceImpl( override fun task(taskId: String): ScanTask { return scanTaskDao.findById(taskId)?.let { task -> + val repos = RuleUtil.getRepoNames(task.rule?.readJsonString()) if (task.projectId == null) { permissionCheckHandler.permissionManager.checkPrincipal(SecurityUtils.getUserId(), PrincipalType.ADMIN) + } else if (repos.isNotEmpty()) { + permissionCheckHandler.checkReposPermission(task.projectId, repos, PermissionAction.READ) } else { permissionCheckHandler.checkProjectPermission(task.projectId, PermissionAction.MANAGE) }