Skip to content

Commit

Permalink
sprintfix: 兼容使用密码变量的场景
Browse files Browse the repository at this point in the history
  • Loading branch information
ZhuoZhuoCrayon committed Aug 23, 2023
1 parent 82c387e commit e47c532
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
get_node_callback_url,
has_biz_set,
loose_strip,
parse_passwd_value,
plat_ip_reg,
)

Expand Down Expand Up @@ -123,7 +124,7 @@ def execute(self, data, parent_data):
self.biz_scope_type = JobBizScopeType.BIZ.value

for _value in original_global_var:
val = loose_strip(crypto.decrypt(_value["value"]))
val = loose_strip(crypto.decrypt(parse_passwd_value(_value["value"])))
if _value["type"] == JOBV3_VAR_CATEGORY_IP:

ip_list = self.get_ip_list(val)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,12 @@
from pipeline_plugins.components.collections.sites.open.job import JobService
from pipeline_plugins.components.collections.sites.open.job.ipv6_base import GetJobTargetServerMixin
from pipeline_plugins.components.query.sites.open.job import JOBV3_VAR_CATEGORY_IP, JOBV3_VAR_CATEGORY_PASSWORD
from pipeline_plugins.components.utils import get_job_instance_url, get_node_callback_url, loose_strip
from pipeline_plugins.components.utils import (
get_job_instance_url,
get_node_callback_url,
loose_strip,
parse_passwd_value,
)

__group_name__ = _("作业平台(JOB)")

Expand Down Expand Up @@ -151,7 +156,7 @@ def execute(self, data, parent_data):
biz_across = data.get_one_of_inputs("biz_across")

for _value in original_global_var:
val = loose_strip(crypto.decrypt(_value["value"]))
val = loose_strip(crypto.decrypt(parse_passwd_value(_value["value"])))
# category为3,表示变量类型为IP
if _value["category"] == JOBV3_VAR_CATEGORY_IP:
self.logger.info("[job_execute_task_base] start find ip, var={}".format(val))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
ScheduleAssertion,
)

from gcloud.utils import crypto
from pipeline_plugins.components.collections.sites.open.job.all_biz_execute_job_plan.v1_0 import (
AllBizJobExecuteJobPlanComponent,
)
Expand Down Expand Up @@ -709,6 +710,12 @@ def __init__(
"is_tagged_ip": True,
"job_global_var": [
{"id": 1000030, "type": 1, "name": "name", "value": "test", "description": ""},
{
"id": 1000032,
"type": JOBV3_VAR_CATEGORY_PASSWORD,
"name": "password",
"value": {"tag": "variable", "value": crypto.encrypt("123")},
},
{"id": 1000031, "type": 3, "name": "ip", "value": "0:192.168.20.218", "description": ""},
],
}
Expand Down Expand Up @@ -750,6 +757,7 @@ def __init__(
"job_plan_id": 1000010,
"global_var_list": [
{"id": 1000030, "value": "test"},
{"id": 1000032, "value": "123"},
{"id": 1000031, "server": {"ip_list": [{"ip": "192.168.20.218", "bk_cloud_id": 0}]}},
],
"callback_url": "callback_url",
Expand Down

0 comments on commit e47c532

Please sign in to comment.