Skip to content
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

JavaScript/Python/Ruby: Improve alert message for */weak-cryptographic-algorithm. #14603

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

max-schaefer
Copy link
Collaborator

The alert message now contains a link to the location where the algorithm was configured, which may be in a different file from the alert location.

The library changes needed to make this work are not conceptually difficult, but quite spread out. I don't understand the affected libraries very well, so I may well have botched a few of the updates. Feedback from the respective maintainers is highly welcome!

I had a quick look at the corresponding queries for Java and C++, and they already seem to link to the right location, so I didn't change anything there. I'm not sure what the query is called for C#, Go and Swift.

…thm`.

Specifically, we add a link to the location where the cryptographic algorithm is configured, which can be far away from its use.
@erik-krogh erik-krogh added the no-change-note-required This PR does not need a change note label Oct 27, 2023
Comment on lines +16 to +27
from Cryptography::CryptographicOperation operation, string msgPrefix
where
algorithm = operation.getAlgorithm() and
// `Cryptography::HashingAlgorithm` and `Cryptography::PasswordHashingAlgorithm` are
// handled by `py/weak-sensitive-data-hashing`
algorithm instanceof Cryptography::EncryptionAlgorithm and
(
exists(Cryptography::EncryptionAlgorithm algorithm | algorithm = operation.getAlgorithm() |
algorithm.isWeak() and
msgPrefix = "The cryptographic algorithm " + operation.getAlgorithm().getName()
msgPrefix = "The cryptographic algorithm " + algorithm.getName()
)
or
operation.getBlockMode().isWeak() and msgPrefix = "The block mode " + operation.getBlockMode()
select operation, msgPrefix + " is broken or weak, and should not be used."
select operation, "$@ is broken or weak, and should not be used.", operation.getInitialization(),
msgPrefix

Check warning

Code scanning / CodeQL

Consistent alert message Warning

The py/weak-cryptographic-algorithm query does not have the same alert message as cpp.
@max-schaefer max-schaefer force-pushed the max-schaefer/broken-crypto-algorithm-link branch from de2b219 to 104700f Compare October 27, 2023 09:19
Copy link
Contributor

@erik-krogh erik-krogh left a comment

Choose a reason for hiding this comment

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

JS 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
JS no-change-note-required This PR does not need a change note Python Ruby
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants