Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@MKLeb
Copy link
Contributor

@MKLeb MKLeb commented Oct 17, 2023

What does this PR do?

See title

What issues does this PR fix or reference?

Fixes: One file for #64739

Merge requirements satisfied?

[NOTICE] Bug fixes or features added to Salt require tests.

Commits signed with GPG?

Yes

@MKLeb MKLeb requested a review from a team as a code owner October 17, 2023 20:01
@MKLeb MKLeb requested review from Ch3LL and removed request for a team October 17, 2023 20:01
@MKLeb MKLeb temporarily deployed to ci October 17, 2023 21:05 — with GitHub Actions Inactive
@MKLeb MKLeb temporarily deployed to ci October 17, 2023 21:06 — with GitHub Actions Inactive
@MKLeb MKLeb temporarily deployed to ci October 17, 2023 21:07 — with GitHub Actions Inactive
@MKLeb MKLeb temporarily deployed to ci October 17, 2023 21:07 — with GitHub Actions Inactive
@MKLeb MKLeb temporarily deployed to ci October 17, 2023 21:08 — with GitHub Actions Inactive
@MKLeb MKLeb temporarily deployed to ci October 17, 2023 21:08 — with GitHub Actions Inactive
@MKLeb MKLeb temporarily deployed to ci October 17, 2023 23:42 — with GitHub Actions Inactive
@MKLeb MKLeb temporarily deployed to ci October 17, 2023 23:43 — with GitHub Actions Inactive
@MKLeb MKLeb temporarily deployed to ci October 17, 2023 23:43 — with GitHub Actions Inactive
@MKLeb MKLeb temporarily deployed to ci October 17, 2023 23:43 — with GitHub Actions Inactive
@MKLeb MKLeb temporarily deployed to ci October 17, 2023 23:43 — with GitHub Actions Inactive
@MKLeb MKLeb temporarily deployed to ci October 17, 2023 23:43 — with GitHub Actions Inactive
@MKLeb MKLeb temporarily deployed to ci October 18, 2023 01:07 — with GitHub Actions Inactive
@MKLeb MKLeb temporarily deployed to ci October 18, 2023 01:07 — with GitHub Actions Inactive
@MKLeb MKLeb temporarily deployed to ci October 18, 2023 01:07 — with GitHub Actions Inactive
@MKLeb MKLeb temporarily deployed to ci October 18, 2023 01:07 — with GitHub Actions Inactive
@MKLeb MKLeb temporarily deployed to ci October 18, 2023 01:07 — with GitHub Actions Inactive
@MKLeb MKLeb temporarily deployed to ci October 18, 2023 01:07 — with GitHub Actions Inactive
@MKLeb MKLeb changed the title [3006.x] Add coverage for salt/crypt.py [3006.x] Add coverage for salt/crypt.py Oct 18, 2023
@MKLeb MKLeb temporarily deployed to ci October 18, 2023 05:21 — with GitHub Actions Inactive
@MKLeb MKLeb temporarily deployed to ci October 18, 2023 05:22 — with GitHub Actions Inactive
@MKLeb MKLeb temporarily deployed to ci October 18, 2023 05:23 — with GitHub Actions Inactive
@MKLeb MKLeb temporarily deployed to ci October 18, 2023 05:24 — with GitHub Actions Inactive
@MKLeb MKLeb temporarily deployed to ci October 18, 2023 05:24 — with GitHub Actions Inactive
@MKLeb MKLeb temporarily deployed to ci October 18, 2023 05:25 — with GitHub Actions Inactive
@s0undt3ch s0undt3ch temporarily deployed to ci October 20, 2023 20:35 — with GitHub Actions Inactive
@s0undt3ch s0undt3ch temporarily deployed to ci October 20, 2023 20:35 — with GitHub Actions Inactive
@s0undt3ch s0undt3ch temporarily deployed to ci October 20, 2023 20:35 — with GitHub Actions Inactive
@s0undt3ch s0undt3ch temporarily deployed to ci October 20, 2023 20:36 — with GitHub Actions Inactive
Comment on lines +27 to +29
key_path = str(tmp_path / "key")
with salt.utils.files.fopen(key_path, "w") as fp:
fp.write("")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
key_path = str(tmp_path / "key")
with salt.utils.files.fopen(key_path, "w") as fp:
fp.write("")
key_path = tmp_path / "key"
key_path.touch()

FYI

\x1a(\x04&yL8\x19s\n\x11\x81\xfd?\xfb2\x80Ll\xa1\xdc\xc9\xb6P\xca\x8d\'\x11\xc1\
\x07\xa5\xa1\x058\xc7\xce\xbeb\x92\xbf\x0bL\xec\xdf\xc3M\x83\xfb$\xec\xd5\xf9\
"""
assert "1234" == salt.crypt.pwdata_decrypt(key_string, pwdata)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
assert "1234" == salt.crypt.pwdata_decrypt(key_string, pwdata)
assert salt.crypt.pwdata_decrypt(key_string, pwdata) == "1234"

https://gist.github.com/s0undt3ch/92d065815f4ce526345f72d40a40074d

Comment on lines +48 to +49
with pytest.raises(salt.crypt.SaltClientError, match="Nonce verification error"):
assert master_crypt.loads(ret, nonce="abcde")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
with pytest.raises(salt.crypt.SaltClientError, match="Nonce verification error"):
assert master_crypt.loads(ret, nonce="abcde")
with pytest.raises(salt.crypt.SaltClientError, match="Nonce verification error"):
master_crypt.loads(ret, nonce="abcde")

def test_sign_message(priv_key, msg, sig):
key = M2Crypto.RSA.load_key_string(salt.utils.stringutils.to_bytes(priv_key))
with patch("salt.crypt.get_rsa_key", return_value=key):
assert sig == salt.crypt.sign_message("/keydir/keyname.pem", msg)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
assert sig == salt.crypt.sign_message("/keydir/keyname.pem", msg)
assert salt.crypt.sign_message("/keydir/keyname.pem", msg) == sig

https://gist.github.com/s0undt3ch/92d065815f4ce526345f72d40a40074d

Comment on lines +92 to +94
assert sig == crypt.sign_message(
"/keydir/keyname.pem", msg, passphrase="password"
)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
assert sig == crypt.sign_message(
"/keydir/keyname.pem", msg, passphrase="password"
)
assert crypt.sign_message(
"/keydir/keyname.pem", msg, passphrase="password"
) == sig

)
encrypted = salt.crypt.private_encrypt(loaded_priv_key, b"salt")
decrypted = salt.crypt.public_decrypt(loaded_pub_key, encrypted)
assert b"salt" == decrypted
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
assert b"salt" == decrypted
assert b"salt" == decrypted

Switch

@dwoz dwoz added this to the Sulfur v3006.6 milestone Dec 11, 2023
@dwoz dwoz modified the milestones: Sulfur v3006.6, Sulfur v3006.7 Feb 14, 2024
@dwoz dwoz modified the milestones: Sulfur v3006.7, Sulfur v3006.9 Jun 22, 2024
@dwoz dwoz requested a review from a team as a code owner March 20, 2025 21:24
@dmurphy18
Copy link
Contributor

@MKLeb Need conflicts resolved and what about @s0undt3ch comments

@dmurphy18 dmurphy18 requested review from dmurphy18 and removed request for Ch3LL March 20, 2025 21:28
@dmurphy18
Copy link
Contributor

@dwoz Do we care about crypt ?

@dwoz dwoz modified the milestones: Sulfur v3006.12, Sulfer v3006.13 Jun 13, 2025
@twangboy twangboy added test:full Run the full test suite pending-changes The pull request needs additional changes before it can be merged and removed test:coverage labels Jul 2, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pending-changes The pull request needs additional changes before it can be merged test:full Run the full test suite

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants