Skip to content

Commit

Permalink
feat: merge master branch
Browse files Browse the repository at this point in the history
  • Loading branch information
normal-wls committed Jan 5, 2024
2 parents e542201 + c2d7695 commit b96edf4
Show file tree
Hide file tree
Showing 11 changed files with 81 additions and 44 deletions.
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ repos:
hooks:
- id: flake8
- repo: https://github.com/alessandrojcm/commitlint-pre-commit-hook
rev: v2.2.0
rev: v9.11.0
hooks:
- id: commitlint
stages: [commit-msg]
Expand Down
19 changes: 17 additions & 2 deletions commitlint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,30 @@ const Configuration = {
'perf',
'chore',
],
]
],
'content-rule': [2, 'always'],
},
plugins: [
{
rules: {
'content-rule': ({subject}) => {
const pattern = /#\d+$|--story=\d+$|--bug=\d+$/;
return [
pattern.test(subject.trim()),
`Your subject should contain issue id`,
];
}
}
}
],
/*
* Functions that return true if commitlint should ignore the given message.
*/
ignores: [
(commit) => commit === '',
(message) => message.includes('Merge'),
(message) => message.includes('merge')
(message) => message.includes('merge'),
(message) => message.includes('ignore')
],
/*
* Whether commitlint uses the default ignore rules.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,8 @@
},
// 变量tag设置
setVariableTag (value, valueUpdate) {
const { attrs } = this.scheme
if (attrs.variable_render !== false) return
const regex = /\${[a-zA-Z_]\w*}/
const rows = value.split('\n')
// 获取光标所在行
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@
selectedNodes.push(item.id)
}
})
this.selectedNodes = selectedNodes
this.selectedNodes = this.selectedNodes.length ? this.selectedNodes : selectedNodes
if (this.viewMode === 'appmaker') {
const appmakerData = await this.loadAppmakerDetail(this.app_id)
Expand All @@ -257,6 +257,7 @@
this.$set(item, 'checked', true)
}
})
this.updateExcludeNodes()
} catch (e) {
if (e.status === 404) {
this.$router.push({ name: 'notFoundPage' })
Expand Down Expand Up @@ -486,6 +487,7 @@
* 设置默认勾选值
*/
async setCanvasSelected (selectNodes = []) {
if (this.excludeNode.length) return
if (selectNodes.length) {
// 使用传进来的选中节点,取消画布默认全选
this.selectedNodes = selectNodes
Expand Down
57 changes: 29 additions & 28 deletions frontend/desktop/src/pages/task/TaskExecute/TaskOperation.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2057,19 +2057,38 @@
const targetNodes = this.nodeTargetMaps[id] || []
// 多条输出分支
if (targetNodes.length > 1) {
// 非递归时,将节点分支添加到总分支,删除旧分支。
if (!isDeep) {
convergeInfo[parentId].branchCount += targetNodes.length - 1
if (!convergeInfo[id]) {
const subConvergeInfo = {}
this.getGatewayConvergeNodes({
id: id,
parentId: id,
convergeInfo: subConvergeInfo
})
const { convergeNode: subConvergeNodes } = subConvergeInfo[id]
convergeInfo[parentId].checkedNodes.push(subConvergeNodes)
const branchConvergeNode = convergeInfo[parentId][`branch${index}`]
if (!branchConvergeNode) {
convergeInfo[parentId][`branch${index}`] = [subConvergeNodes]
} else if (!branchConvergeNode.includes(subConvergeNodes)) {
branchConvergeNode.push(subConvergeNodes)
}
// 如果是最后一条分支,则需要判断是否找到最终汇聚节点
if (isLastBranch) {
this.getGatewayConvergeNodes({
id: this.pipelineData.end_event.id,
parentId,
convergeInfo,
index,
isDeep,
isLastBranch
})
}
return
}
convergeInfo[parentId].branchCount = targetNodes.length
targetNodes.forEach((targetId, branchIndex) => {
let newIndex = branchIndex
// 当前节点属于存在分支下时,向下查找时采用新的分支数
if (index !== 0) {
const branches = Object.keys(convergeInfo[parentId]).filter(item => /^branch[0-9]*$/.test(item))
newIndex = branches.length
}
// 非递归时使用传入的分支数
newIndex = isDeep ? index : newIndex
const newIndex = isDeep ? index : branchIndex
this.getGatewayConvergeNodes({
id: targetId,
parentId,
Expand Down Expand Up @@ -2110,28 +2129,10 @@
} else if (index === branchCount - 1 && (isDeep ? isLastBranch : true)) { // 最后一条分支
// 没找到汇聚节点则继续向下递归
if (!convergeInfo[parentId].convergeNode) {
const executedNodes = []
countArr.forEach(idx => {
// 根据各条分支最后的汇聚节点继续查找
const data = convergeInfo[parentId][`branch${idx}`] || []
const [lastId] = data.slice(-1)
// 合并有相同汇聚节点的分支
const existed = executedNodes.find(item => item.id === lastId)
if (existed && lastId !== end_event.id) {
const samePreBranch = convergeInfo[parentId][`branch${existed.index}`]
convergeInfo[parentId][`branch${idx}`] = [...samePreBranch]
const [preLastId] = samePreBranch.slice(-1)
this.getGatewayConvergeNodes({
id: preLastId,
parentId,
convergeInfo,
index: idx,
isDeep: true,
isLastBranch: idx === countArr.length - 1
})
return
}
executedNodes.push({ id: lastId, index: idx })
const targetIds = this.nodeTargetMaps[lastId] || [lastId]
// 向下递归
targetIds.forEach(targetId => {
Expand Down
2 changes: 1 addition & 1 deletion frontend/desktop/src/pages/task/TaskList/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -531,7 +531,7 @@
data['pipeline_template__finish_time__gte'] = moment(finish_time[0]).format('YYYY-MM-DD HH:mm:ss')
data['pipeline_template__finish_time__lte'] = moment(finish_time[1]).format('YYYY-MM-DD HH:mm:ss')
} else {
data['pipeline_instance__finish_time_gte'] = moment.tz(finish_time[0], this.timeZone).format('YYYY-MM-DD HH:mm:ss')
data['pipeline_instance__finish_time__gte'] = moment.tz(finish_time[0], this.timeZone).format('YYYY-MM-DD HH:mm:ss')
data['pipeline_instance__finish_time__lte'] = moment.tz(finish_time[1], this.timeZone).format('YYYY-MM-DD HH:mm:ss')
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -625,13 +625,16 @@
}
}
// 根据source_info中获取勾选的表单项code
const [formCode] = curVar?.source_info[subflow.id] || []
if (!formCode) return
const { form, inputsConfig } = subflow.latestForm
const formValue = form[key]
const formValue = form[formCode]
const inputRef = this.$refs.inputParams[index]
let hook = false
// 获取输入参数的勾选状态
if (inputRef && inputRef.hooked) {
hook = inputRef.hooked[key] || false
hook = inputRef.hooked[formCode] || false
}
if (varItem.is_meta && formValue && hook) {
const schema = formSchema.getSchema(formValue.key, inputsConfig)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1041,7 +1041,8 @@
await this.getPluginDetail()
if (Array.isArray(this.inputs)) {
this.inputsRenderConfig = this.inputs.reduce((acc, crt) => {
acc[crt.tag_code] = crt.type !== 'code_editor'
// 普通插件值为true,codeEditor类型插件优先使用variable_render字段,默认值为true
acc[crt.tag_code] = crt.type !== 'code_editor' || 'variable_render' in crt.attrs ? crt.attrs.variable_render : true
return acc
}, {})
}
Expand All @@ -1068,7 +1069,8 @@
await this.getPluginDetail()
if (Array.isArray(this.inputs)) {
this.inputsRenderConfig = this.inputs.reduce((acc, crt) => {
acc[crt.tag_code] = crt.type !== 'code_editor'
// 普通插件值为true,codeEditor类型插件优先使用variable_render字段,默认值为true
acc[crt.tag_code] = crt.type !== 'code_editor' || 'variable_render' in crt.attrs ? crt.attrs.variable_render : true
return acc
}, {})
}
Expand Down Expand Up @@ -1614,11 +1616,14 @@
// 更新子流程已勾选的变量值
Object.keys(this.localConstants).forEach(key => {
const constantValue = this.localConstants[key]
const formValue = this.subflowForms[key]
// 根据source_info中获取勾选的表单项code
const [formCode] = constantValue.source_info[this.nodeId] || []
if (!formCode) return
const formValue = this.subflowForms[formCode]
let hook = false
// 获取输入参数的勾选状态
if (inputRef && inputRef.hooked) {
hook = inputRef.hooked[key] || false
hook = inputRef.hooked[formCode] || false
}
if (constantValue.is_meta && formValue && hook) {
const schema = formSchema.getSchema(formValue.key, this.inputs)
Expand Down
2 changes: 1 addition & 1 deletion gcloud/taskflow3/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@
"""

import logging
from typing import Any, Dict, List, Optional
import typing
from collections import defaultdict
from typing import Any, Dict, List, Optional

from django.apps import apps
from django.utils.translation import ugettext_lazy as _
Expand Down
3 changes: 3 additions & 0 deletions gcloud/tests/utils/test_crypto.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,3 +60,6 @@ def test_ciphertext(self):

def test_plaintext(self):
self.assertEqual(self.plaintext, crypto.decrypt(self.plaintext))

def test_invalid_b64(self):
self.assertEqual("AAAA", crypto.decrypt("AAAA"))
14 changes: 10 additions & 4 deletions gcloud/utils/crypto.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
specific language governing permissions and limitations under the License.
"""
import base64
import json
import typing
import base64

from bkcrypto import constants as crypto_constants
from bkcrypto.asymmetric.configs import KeyConfig as AsymmetricKeyConfig
Expand Down Expand Up @@ -66,9 +66,15 @@ def decrypt(ciphertext: str, using: typing.Optional[str] = None) -> str:
# 如果抛出异常,在外层被 catch 后返回
if not base64.b64decode(plaintext.encode(encoding="utf-8")):
return plaintext
plaintext = asymmetric_cipher_manager.cipher(using=using, cipher_type=AsymmetricCipherType.RSA.value).decrypt(
plaintext
)
candidate_plaintext: str = asymmetric_cipher_manager.cipher(
using=using, cipher_type=AsymmetricCipherType.RSA.value
).decrypt(plaintext)

# 空字符串的密文是空字符串
# 如果解密结果为空,属于解密失败,直接返回原文
if candidate_plaintext:
plaintext = candidate_plaintext

except Exception:
# 已经是明文的情况下会抛出该异常
pass
Expand Down

0 comments on commit b96edf4

Please sign in to comment.