-
Notifications
You must be signed in to change notification settings - Fork 366
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
set line length to 120 #1735
set line length to 120 #1735
Conversation
@@ -173,7 +183,9 @@ | |||
if security_policy.host_certificate: | |||
chunk.SecurityHeader.SenderCertificate = security_policy.host_certificate | |||
if security_policy.peer_certificate: | |||
chunk.SecurityHeader.ReceiverCertificateThumbPrint = hashlib.sha1(security_policy.peer_certificate).digest() | |||
chunk.SecurityHeader.ReceiverCertificateThumbPrint = hashlib.sha1( | |||
security_policy.peer_certificate |
Check failure
Code scanning / CodeQL
Use of a broken or weak cryptographic hashing algorithm on sensitive data High
Sensitive data (certificate)
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix AI 29 days ago
To fix the problem, we need to replace the use of the SHA-1 hashing algorithm with a stronger algorithm, such as SHA-256. This change will ensure that the certificate's hash is more secure against collision attacks.
- General Fix: Replace the
hashlib.sha1
function withhashlib.sha256
. - Detailed Fix: Specifically, change the line where
hashlib.sha1
is used tohashlib.sha256
in themessage_to_chunks
method. - Files/Regions/Lines to Change: The change will be made in the file
asyncua/common/connection.py
on line 187. - Requirements: Ensure that the
hashlib
module is imported (already present in the code).
-
Copy modified line R186
@@ -185,3 +185,3 @@ | ||
if security_policy.peer_certificate: | ||
chunk.SecurityHeader.ReceiverCertificateThumbPrint = hashlib.sha1( | ||
chunk.SecurityHeader.ReceiverCertificateThumbPrint = hashlib.sha256( | ||
security_policy.peer_certificate |
cec8ec7
to
139a04f
Compare
@@ -31,6 +31,7 @@ jobs: | |||
uv tool install pre-commit | |||
- name: Lint with ruff | |||
run: | | |||
uvx ruff format --diff |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It might be better to include formatting in pre-commit, so it would also run it locally when comitting which is more convenient see https://github.com/astral-sh/ruff-pre-commit?tab=readme-ov-file#using-ruff-with-pre-commit
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have 0 ideas how to add that to pre-commit. So you can do it.
But I feel it is a bit strange to use pre-commit to do linting. Isnt't much clearer to have the check we do in plain test here?
No description provided.