Skip to content

Commit

Permalink
pref:研发商店敏感接口签名校验优化 TencentBlueKing#10759
Browse files Browse the repository at this point in the history
  • Loading branch information
carlyin0801 committed Sep 5, 2024
1 parent 364c5d6 commit 51818e4
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,15 @@ import com.tencent.devops.common.api.util.timestampmilli
import com.tencent.devops.common.pipeline.Model
import com.tencent.devops.common.pipeline.enums.BranchVersionAction
import com.tencent.devops.common.pipeline.enums.VersionStatus
import com.tencent.devops.model.process.Tables.T_PIPELINE_RESOURCE
import com.tencent.devops.model.process.Tables.T_PIPELINE_RESOURCE_VERSION
import com.tencent.devops.model.process.tables.records.TPipelineResourceVersionRecord
import com.tencent.devops.process.engine.pojo.PipelineInfo
import com.tencent.devops.process.pojo.pipeline.PipelineResourceVersion
import com.tencent.devops.process.pojo.setting.PipelineModelVersion
import com.tencent.devops.process.pojo.setting.PipelineVersionSimple
import com.tencent.devops.process.utils.PipelineVersionUtils
import org.jooq.Condition
import org.jooq.DSLContext
import org.jooq.RecordMapper
import org.jooq.impl.DSL
Expand Down Expand Up @@ -513,6 +516,27 @@ class PipelineResourceVersionDao {
}
}

fun updatePipelineModel(
dslContext: DSLContext,
userId: String,
pipelineModelVersion: PipelineModelVersion
) {
with(T_PIPELINE_RESOURCE_VERSION) {
val conditions = mutableListOf<Condition>()
conditions.add(PROJECT_ID.eq(pipelineModelVersion.projectId))
conditions.add(PIPELINE_ID.eq(pipelineModelVersion.pipelineId))
val version = pipelineModelVersion.version
if (version != null) {
conditions.add(VERSION.eq(version))
}
dslContext.update(this)
.set(MODEL, pipelineModelVersion.model)
.set(CREATOR, userId)
.where(conditions)
.execute()
}
}

fun updateSettingVersion(
dslContext: DSLContext,
userId: String,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1782,7 +1782,11 @@ class PipelineRepositoryService constructor(
)
.addAttribute(ActionAuditContent.PROJECT_CODE_TEMPLATE, pipelineModelVersion.projectId)
.scopeId = pipelineModelVersion.projectId
pipelineResourceDao.updatePipelineModel(dslContext, userId, pipelineModelVersion)
dslContext.transaction { configuration ->
val transactionContext = DSL.using(configuration)
pipelineResourceDao.updatePipelineModel(transactionContext, userId, pipelineModelVersion)
pipelineResourceVersionDao.updatePipelineModel(transactionContext, userId, pipelineModelVersion)
}
} finally {
lock.unlock()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,22 @@ class StoreBaseEnvQueryDao {
}
}

fun getDefaultBaseEnvInfo(
dslContext: DSLContext,
storeId: String,
osName: String? = null
): TStoreBaseEnvRecord? {
return with(TStoreBaseEnv.T_STORE_BASE_ENV) {
val conditions = mutableListOf<Condition>()
conditions.add(STORE_ID.eq(storeId))
conditions.add(DEFAULT_FLAG.eq(true))
if (!osName.isNullOrBlank()) {
conditions.add(OS_NAME.eq(osName))
}
dslContext.selectFrom(this).where(conditions).limit(1).fetchOne()
}
}

fun batchQueryStoreLanguage(dslContext: DSLContext, storeIds: List<String>): Result<Record2<String, String>> {
with(TStoreBaseEnv.T_STORE_BASE_ENV) {
return dslContext.select(ID, LANGUAGE).from(this)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -259,13 +259,11 @@ class SensitiveApiServiceImpl @Autowired constructor(
params = arrayOf("$storeType:$storeCode:$version")
)
val baseEnvRecord = storeBaseEnvQueryDao.getBaseEnvsByStoreId(
dslContext = dslContext,
storeId = storeId,
osName = osName,
osArch = osArch
)?.getOrNull(0) ?: throw ErrorCodeException(
errorCode = CommonMessageCode.PARAMETER_IS_INVALID,
params = arrayOf("$osName:$osArch")
dslContext = dslContext, storeId = storeId, osName = osName, osArch = osArch
)?.getOrNull(0) ?: storeBaseEnvQueryDao.getDefaultBaseEnvInfo(
dslContext = dslContext, storeId = storeId, osName = osName
) ?: storeBaseEnvQueryDao.getDefaultBaseEnvInfo(dslContext, storeId) ?: throw ErrorCodeException(
errorCode = CommonMessageCode.PARAMETER_IS_INVALID, params = arrayOf("$osName:$osArch")
)
val dbFileShaContent = storeBaseEnvExtQueryDao.getBaseExtEnvsByEnvId(
dslContext = dslContext,
Expand Down

0 comments on commit 51818e4

Please sign in to comment.