Skip to content
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

fix: NodeSearch权限校验失败 #2724 #2726

Merged
merged 1 commit into from
Oct 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading