Skip to content

Commit

Permalink
fix: NodeSearch权限校验失败 #2724
Browse files Browse the repository at this point in the history
  • Loading branch information
yaoxuwan committed Oct 31, 2024
1 parent b0680b3 commit 191f6e3
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,16 +36,17 @@ import com.tencent.bkrepo.auth.pojo.enums.PermissionAction
import com.tencent.bkrepo.common.api.constant.ensureSuffix
import com.tencent.bkrepo.common.artifact.exception.RepoNotFoundException
import com.tencent.bkrepo.common.artifact.path.PathUtils
import com.tencent.bkrepo.common.metadata.condition.SyncCondition
import com.tencent.bkrepo.common.metadata.permission.PermissionManager
import com.tencent.bkrepo.common.metadata.service.repo.RepositoryService
import com.tencent.bkrepo.common.metadata.util.NodeQueryHelper.listPermissionPaths
import com.tencent.bkrepo.common.metadata.condition.SyncCondition
import com.tencent.bkrepo.common.query.enums.OperationType
import com.tencent.bkrepo.common.query.interceptor.QueryContext
import com.tencent.bkrepo.common.query.interceptor.QueryRuleInterceptor
import com.tencent.bkrepo.common.query.model.Rule
import com.tencent.bkrepo.common.security.exception.PermissionException
import com.tencent.bkrepo.common.security.util.SecurityUtils
import com.tencent.bkrepo.common.service.util.HttpContextHolder
import com.tencent.bkrepo.repository.pojo.node.NodeInfo
import com.tencent.bkrepo.repository.pojo.repo.RepoListOption
import org.slf4j.LoggerFactory
Expand Down Expand Up @@ -217,7 +218,7 @@ class RepoNameRuleInterceptor(
repoName: String,
repoPublic: Boolean? = null
): Boolean {
if (SecurityUtils.isServiceRequest()) {
if (HttpContextHolder.getRequestOrNull() == null || SecurityUtils.isServiceRequest()) {
return true
}
return try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -369,9 +369,9 @@ class FixToolServiceImpl : FixToolService, AbstractChartService() {
private fun resolveNode(record: Map<String, Any?>): NodeInfo {
return NodeInfo(
createdBy = record["createdBy"] as String,
createdDate = record["createdDate"] as String,
createdDate = (record["createdDate"] as LocalDateTime).toString(),
lastModifiedBy = record["lastModifiedBy"] as String,
lastModifiedDate = record["lastModifiedDate"] as String,
lastModifiedDate = (record["lastModifiedDate"] as LocalDateTime).toString(),
folder = record["folder"] as Boolean,
path = record["path"] as String,
name = record["name"] as String,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ class NpmLocalRepository(
metadata["description"] as? String,
metadata["maintainers"] as? List<Map<String, Any>> ?: emptyList(),
metadata["version"] as? String,
it["lastModifiedDate"] as String,
(it["lastModifiedDate"] as LocalDateTime).toString(),
metadata["keywords"] as? List<String> ?: emptyList(),
metadata["author"] as? Map<String, Any> ?: emptyMap()
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -367,9 +367,9 @@ class NpmFixToolServiceImpl(
private fun resolveNode(record: Map<String, Any?>): NodeInfo {
return NodeInfo(
createdBy = record["createdBy"] as String,
createdDate = record["createdDate"] as String,
createdDate = (record["createdDate"] as LocalDateTime).toString(),
lastModifiedBy = record["lastModifiedBy"] as String,
lastModifiedDate = record["lastModifiedDate"] as String,
lastModifiedDate = (record["lastModifiedDate"] as LocalDateTime).toString(),
folder = record["folder"] as Boolean,
path = record["path"] as String,
name = record["name"] as String,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ import java.io.File
import java.io.FileInputStream
import java.io.FileOutputStream
import java.io.RandomAccessFile
import java.time.LocalDateTime
import java.util.Locale
import java.util.concurrent.ConcurrentHashMap
import javax.xml.parsers.SAXParserFactory
Expand Down Expand Up @@ -492,8 +493,8 @@ class JobService(
return NodeInfo(
createdBy = mapData["createdBy"] as String,
createdDate = mapData["lastModifiedBy"] as String,
lastModifiedBy = mapData["lastModifiedDate"] as String,
lastModifiedDate = mapData["lastModifiedDate"] as String,
lastModifiedBy = (mapData["lastModifiedDate"] as LocalDateTime).toString(),
lastModifiedDate = (mapData["lastModifiedDate"] as LocalDateTime).toString(),
folder = mapData["folder"] as Boolean,
path = mapData["path"] as String,
name = mapData["name"] as String,
Expand Down

0 comments on commit 191f6e3

Please sign in to comment.