Skip to content

解密函数 rsa_decrypt_password 报错 #7977

@xiaoheiren04

Description

@xiaoheiren04

base64.decodestring was removed in Python 3.9. Use base64.b64decode instead, It seems that the function of the base64 decryption method in this file needs to be modified.

Traceback (most recent call last):
File "/usr/local/lib/python3.11/site-packages/bamboo_engine/handlers/service_activity.py", line 286, in execute
execute_success = service.execute(data=service_data, root_pipeline_data=root_pipeline_data)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/pipeline/eri/imp/service.py", line 54, in execute
execute_res = self.service.execute(data_obj, parent_data_obj)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/opsfe/sops/ebay/component.py", line 14, in wrapper
return func(self, *args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/opsfe/sops/ebay/tenants/searchops/components/collections/schedule_altus_deploy_job.py", line 49, in execute
user_password = rsa_decrypt_password(ecrypt_password, settings.RSA_PRIV_KEY)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/pipeline/utils/crypt.py", line 20, in rsa_decrypt_password
base64.decodestring(encrypted_password.encode("utf-8")), rsa.PrivateKey.load_pkcs1(private_key)
^^^^^^^^^^^^^^^^^^^
AttributeError: module 'base64' has no attribute 'decodestring'

it should like:

def rsa_decrypt_password(encrypted_password, private_key):
    return rsa.decrypt(
        base64.b64decode(encrypted_password.encode("utf-8")), rsa.PrivateKey.load_pkcs1(private_key)
    ).decode("utf-8")

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions