Skip to content

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

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

Merged
merged 5 commits into from
Nov 8, 2023

Conversation

max-schaefer
Copy link
Contributor

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.

Max Schaefer added 3 commits October 26, 2023 11:28
…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

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 👍

@sidshank sidshank requested review from RasmusWL and aibaars November 6, 2023 12:17
@RasmusWL
Copy link
Member

RasmusWL commented Nov 7, 2023

sorry, I got away from reviewing this PR, and shall have a proper look today 👍

Copy link
Member

@RasmusWL RasmusWL left a comment

Choose a reason for hiding this comment

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

Thanks for this PR. I'm currently thinking about a next generation of Concepts for cryptography, so wanted to give proper thought to this addition. Sorry for taking so long to review, I got wound up in other work 😐

Overall I think the additions in this PR makes sense right now, so I think we should just accept them. Thanks for making this 🎉 💪 The only thing holding me back is to confirm there are no performance regressions, I've just started a DCA run for all languages, so once that finishes we should be able to merge 👍

In the long term, we might run into more complicated scenarios, where a combination of properties of the configuration makes the operation weak... but no need to worry too much about that for the queries and models with have right now 😊

@RasmusWL
Copy link
Member

RasmusWL commented Nov 8, 2023

Performance looks good

@RasmusWL RasmusWL merged commit 43d9d2c into main Nov 8, 2023
@RasmusWL RasmusWL deleted the max-schaefer/broken-crypto-algorithm-link branch November 8, 2023 13:29
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.

4 participants