@@ -826,5 +826,46 @@ module Logging {
826826 * to improve our libraries in the future to more precisely capture this aspect.
827827 */
828828module Cryptography {
829- import codeql.ruby.internal.ConceptsShared:: Cryptography
829+ // Since we still rely on `isWeak` predicate on `CryptographicOperation` in Ruby, we
830+ // modify that part of the shared concept... which means we have to explicitly
831+ // re-export everything else.
832+ // Using SC shorthand for "Shared Cryptography"
833+ import codeql.ruby.internal.ConceptsShared:: Cryptography as SC
834+
835+ class CryptographicAlgorithm = SC:: CryptographicAlgorithm ;
836+
837+ class EncryptionAlgorithm = SC:: EncryptionAlgorithm ;
838+
839+ class HashingAlgorithm = SC:: HashingAlgorithm ;
840+
841+ class PasswordHashingAlgorithm = SC:: PasswordHashingAlgorithm ;
842+
843+ /**
844+ * A data-flow node that is an application of a cryptographic algorithm. For example,
845+ * encryption, decryption, signature-validation.
846+ *
847+ * Extend this class to refine existing API models. If you want to model new APIs,
848+ * extend `CryptographicOperation::Range` instead.
849+ */
850+ class CryptographicOperation extends SC:: CryptographicOperation instanceof CryptographicOperation:: Range {
851+ /** DEPRECATED: Use `getAlgorithm().isWeak() or getBlockMode().isWeak()` instead */
852+ deprecated predicate isWeak ( ) { super .isWeak ( ) }
853+ }
854+
855+ /** Provides classes for modeling new applications of a cryptographic algorithms. */
856+ module CryptographicOperation {
857+ /**
858+ * A data-flow node that is an application of a cryptographic algorithm. For example,
859+ * encryption, decryption, signature-validation.
860+ *
861+ * Extend this class to model new APIs. If you want to refine existing API models,
862+ * extend `CryptographicOperation` instead.
863+ */
864+ abstract class Range extends SC:: CryptographicOperation:: Range {
865+ /** DEPRECATED: Use `getAlgorithm().isWeak() or getBlockMode().isWeak()` instead */
866+ deprecated predicate isWeak ( ) { this .getAlgorithm ( ) .isWeak ( ) or this .getBlockMode ( ) .isWeak ( ) }
867+ }
868+ }
869+
870+ class BlockMode = SC:: BlockMode ;
830871}
0 commit comments