Skip to content

Commit 85fa6fb

Browse files
committed
Concepts: Move CryptographicOperation.isWeak to be Ruby specific
1 parent 6b7abef commit 85fa6fb

File tree

4 files changed

+42
-19
lines changed

4 files changed

+42
-19
lines changed

javascript/ql/lib/semmle/javascript/internal/ConceptsShared.qll

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,6 @@ module Cryptography {
4343
/** Gets an input the algorithm is used on, for example the plain text input to be encrypted. */
4444
DataFlow::Node getAnInput() { result = super.getAnInput() }
4545

46-
/** DEPRECATED: Use `getAlgorithm().isWeak() or getBlockMode().isWeak()` instead */
47-
deprecated predicate isWeak() { super.isWeak() }
48-
4946
/**
5047
* Gets the block mode used to perform this cryptographic operation.
5148
* This may have no result - for example if the `CryptographicAlgorithm` used
@@ -70,9 +67,6 @@ module Cryptography {
7067
/** Gets an input the algorithm is used on, for example the plain text input to be encrypted. */
7168
abstract DataFlow::Node getAnInput();
7269

73-
/** DEPRECATED: Use `getAlgorithm().isWeak() or getBlockMode().isWeak()` instead */
74-
deprecated predicate isWeak() { this.getAlgorithm().isWeak() or this.getBlockMode().isWeak() }
75-
7670
/**
7771
* Gets the block mode used to perform this cryptographic operation.
7872
* This may have no result - for example if the `CryptographicAlgorithm` used

python/ql/lib/semmle/python/internal/ConceptsShared.qll

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,6 @@ module Cryptography {
4343
/** Gets an input the algorithm is used on, for example the plain text input to be encrypted. */
4444
DataFlow::Node getAnInput() { result = super.getAnInput() }
4545

46-
/** DEPRECATED: Use `getAlgorithm().isWeak() or getBlockMode().isWeak()` instead */
47-
deprecated predicate isWeak() { super.isWeak() }
48-
4946
/**
5047
* Gets the block mode used to perform this cryptographic operation.
5148
* This may have no result - for example if the `CryptographicAlgorithm` used
@@ -70,9 +67,6 @@ module Cryptography {
7067
/** Gets an input the algorithm is used on, for example the plain text input to be encrypted. */
7168
abstract DataFlow::Node getAnInput();
7269

73-
/** DEPRECATED: Use `getAlgorithm().isWeak() or getBlockMode().isWeak()` instead */
74-
deprecated predicate isWeak() { this.getAlgorithm().isWeak() or this.getBlockMode().isWeak() }
75-
7670
/**
7771
* Gets the block mode used to perform this cryptographic operation.
7872
* This may have no result - for example if the `CryptographicAlgorithm` used

ruby/ql/lib/codeql/ruby/Concepts.qll

Lines changed: 42 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -826,5 +826,46 @@ module Logging {
826826
* to improve our libraries in the future to more precisely capture this aspect.
827827
*/
828828
module 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
}

ruby/ql/lib/codeql/ruby/internal/ConceptsShared.qll

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,6 @@ module Cryptography {
4343
/** Gets an input the algorithm is used on, for example the plain text input to be encrypted. */
4444
DataFlow::Node getAnInput() { result = super.getAnInput() }
4545

46-
/** DEPRECATED: Use `getAlgorithm().isWeak() or getBlockMode().isWeak()` instead */
47-
deprecated predicate isWeak() { super.isWeak() }
48-
4946
/**
5047
* Gets the block mode used to perform this cryptographic operation.
5148
* This may have no result - for example if the `CryptographicAlgorithm` used
@@ -70,9 +67,6 @@ module Cryptography {
7067
/** Gets an input the algorithm is used on, for example the plain text input to be encrypted. */
7168
abstract DataFlow::Node getAnInput();
7269

73-
/** DEPRECATED: Use `getAlgorithm().isWeak() or getBlockMode().isWeak()` instead */
74-
deprecated predicate isWeak() { this.getAlgorithm().isWeak() or this.getBlockMode().isWeak() }
75-
7670
/**
7771
* Gets the block mode used to perform this cryptographic operation.
7872
* This may have no result - for example if the `CryptographicAlgorithm` used

0 commit comments

Comments
 (0)