Rust: Implement the query.

This commit is contained in:
Geoffrey White
2024-12-04 14:49:25 +00:00
parent 07e3421f6f
commit eeeb142f0b
2 changed files with 40 additions and 3 deletions

View File

@@ -172,3 +172,32 @@ module SqlSanitization {
*/
abstract class Range extends DataFlow::Node { }
}
/**
* Provides models for cryptographic things.
*/
module Cryptography {
private import codeql.rust.internal.ConceptsShared::Cryptography as SC
/**
* A data-flow node that is an application of a cryptographic algorithm. For example,
* encryption, decryption, signature-validation.
*
* Extend this class to refine existing API models. If you want to model new APIs,
* extend `CryptographicOperation::Range` instead.
*/
class CryptographicOperation extends SC::CryptographicOperation instanceof CryptographicOperation::Range
{ }
class EncryptionAlgorithm = SC::EncryptionAlgorithm;
class HashingAlgorithm = SC::HashingAlgorithm;
class PasswordHashingAlgorithm = SC::PasswordHashingAlgorithm;
module CryptographicOperation = SC::CryptographicOperation;
class BlockMode = SC::BlockMode;
class CryptographicAlgorithm = SC::CryptographicAlgorithm;
}

View File

@@ -11,7 +11,15 @@
*/
import rust
import codeql.rust.Concepts
from int i
where none()
select i
from Cryptography::CryptographicOperation operation, string msgPrefix
where
exists(Cryptography::EncryptionAlgorithm algorithm | algorithm = operation.getAlgorithm() |
algorithm.isWeak() and
msgPrefix = "The cryptographic algorithm " + algorithm.getName()
)
or
operation.getBlockMode().isWeak() and msgPrefix = "The block mode " + operation.getBlockMode()
select operation, "$@ is broken or weak, and should not be used.", operation.getInitialization(),
msgPrefix