@@ -41,6 +41,10 @@ module CryptographyBase<LocationSig Location, InputSig<Location> Input> {
41
41
ConsumerElement getConsumer ( ) { result .getInputNode ( ) = this }
42
42
}
43
43
44
+ class ArtifactOutputDataFlowNode extends DataFlowNode {
45
+ OutputArtifactInstance getArtifact ( ) { result .getOutputNode ( ) = this }
46
+ }
47
+
44
48
final class UnknownPropertyValue extends string {
45
49
UnknownPropertyValue ( ) { this = "<unknown>" }
46
50
}
@@ -461,7 +465,7 @@ module CryptographyBase<LocationSig Location, InputSig<Location> Input> {
461
465
this = Input:: dfn_to_element ( inputNode )
462
466
}
463
467
464
- override KeyArtifactType getKeyType ( ) { result instanceof TUnknownKeyType }
468
+ override KeyArtifactType getKeyType ( ) { result instanceof TUnknownKeyType } // A consumer node does not have a key type, refer to source (TODO: refine, should this be none())
465
469
466
470
final override ConsumerInputDataFlowNode getInputNode ( ) { result = inputNode }
467
471
}
@@ -674,7 +678,7 @@ module CryptographyBase<LocationSig Location, InputSig<Location> Input> {
674
678
/**
675
679
* Gets the key artifact produced by this operation.
676
680
*/
677
- abstract DataFlowNode getOutputKeyArtifact ( ) ;
681
+ abstract ArtifactOutputDataFlowNode getOutputKeyArtifact ( ) ;
678
682
679
683
/**
680
684
* Gets the key artifact type produced.
@@ -924,29 +928,8 @@ module CryptographyBase<LocationSig Location, InputSig<Location> Input> {
924
928
predicate isExcludedFromGraph ( ) { none ( ) }
925
929
}
926
930
927
- signature string getDefaultValueSig ( ) ;
928
-
929
- signature ConsumerInputDataFlowNode getConsumerSig ( ) ;
930
-
931
- signature class NodeBaseSig instanceof NodeBase ;
932
-
933
- module PropertyOutput< getDefaultValueSig / 0 getDefault, getConsumerSig / 0 getConsumer> {
934
- bindingset [ root]
935
- predicate get ( NodeBase root , string value , Location location ) {
936
- if not exists ( getDefault ( ) ) and not exists ( getConsumer ( ) .getConsumer ( ) .getASource ( ) )
937
- then value instanceof UnknownPropertyValue and location instanceof UnknownLocation
938
- else (
939
- if exists ( getDefault ( ) )
940
- then
941
- value = "Default:" + getDefault ( ) and
942
- location = root .getLocation ( )
943
- else node_as_property ( getConsumer ( ) .getConsumer ( ) .getAGenericSourceNode ( ) , value , location )
944
- )
945
- }
946
- }
947
-
948
931
/**
949
- * A generic source node is a source of data that is not resolvable to a specific value or type .
932
+ * A generic source node is a source of data that is not resolvable to a specific asset .
950
933
*/
951
934
private class GenericSourceNode extends NodeBase , TGenericSourceNode {
952
935
GenericSourceInstance instance ;
@@ -982,7 +965,7 @@ module CryptographyBase<LocationSig Location, InputSig<Location> Input> {
982
965
* Holds if `node` is a potential candidate for a known algorithm node.
983
966
* This predicate should be used to restrict the set of candidate algorithm node types.
984
967
*/
985
- abstract predicate isCandidateKnownAlgorithmNode ( AlgorithmNode node ) ;
968
+ abstract predicate isCandidateAlgorithmNode ( AlgorithmNode node ) ;
986
969
987
970
/**
988
971
* Gets the algorithm or generic source nodes consumed as an algorithm associated with this operation.
@@ -994,12 +977,12 @@ module CryptographyBase<LocationSig Location, InputSig<Location> Input> {
994
977
}
995
978
996
979
/**
997
- * Gets a known algorithm associated with this operation, subject to `isCandidateKnownAlgorithmNode `.
980
+ * Gets a known algorithm associated with this operation, subject to `isCandidateAlgorithmNode `.
998
981
*/
999
982
AlgorithmNode getAKnownAlgorithm ( ) {
1000
983
result =
1001
984
this .asElement ( ) .( OperationInstance ) .getAnAlgorithmValueConsumer ( ) .getAKnownSourceNode ( ) and
1002
- this .isCandidateKnownAlgorithmNode ( result )
985
+ this .isCandidateAlgorithmNode ( result )
1003
986
}
1004
987
1005
988
override NodeBase getChild ( string edgeName ) {
@@ -1173,9 +1156,11 @@ module CryptographyBase<LocationSig Location, InputSig<Location> Input> {
1173
1156
// [KNOWN_OR_UNKNOWN] - only if asymmetric
1174
1157
edgeName = "Algorithm" and
1175
1158
instance .getKeyType ( ) instanceof TAsymmetricKeyType and
1176
- if exists ( this .getAKnownAlgorithmOrGenericSourceNode ( ) )
1177
- then result = this .getAKnownAlgorithmOrGenericSourceNode ( )
1178
- else result = this
1159
+ (
1160
+ if exists ( this .getAKnownAlgorithmOrGenericSourceNode ( ) )
1161
+ then result = this .getAKnownAlgorithmOrGenericSourceNode ( )
1162
+ else result = this
1163
+ )
1179
1164
}
1180
1165
1181
1166
override predicate properties ( string key , string value , Location location ) {
@@ -1243,7 +1228,7 @@ module CryptographyBase<LocationSig Location, InputSig<Location> Input> {
1243
1228
1244
1229
override LocatableElement asElement ( ) { result = instance }
1245
1230
1246
- override predicate isCandidateKnownAlgorithmNode ( AlgorithmNode node ) {
1231
+ override predicate isCandidateAlgorithmNode ( AlgorithmNode node ) {
1247
1232
node instanceof MACAlgorithmNode
1248
1233
}
1249
1234
@@ -1318,7 +1303,7 @@ module CryptographyBase<LocationSig Location, InputSig<Location> Input> {
1318
1303
1319
1304
KeyGenerationOperationNode ( ) { keyGenInstance = instance }
1320
1305
1321
- override predicate isCandidateKnownAlgorithmNode ( AlgorithmNode node ) {
1306
+ override predicate isCandidateAlgorithmNode ( AlgorithmNode node ) {
1322
1307
node instanceof CipherAlgorithmNode
1323
1308
}
1324
1309
@@ -1352,7 +1337,7 @@ module CryptographyBase<LocationSig Location, InputSig<Location> Input> {
1352
1337
result .asElement ( ) = kdfInstance .getOutputKeySizeConsumer ( ) .getConsumer ( ) .getAGenericSource ( )
1353
1338
}
1354
1339
1355
- override predicate isCandidateKnownAlgorithmNode ( AlgorithmNode node ) {
1340
+ override predicate isCandidateAlgorithmNode ( AlgorithmNode node ) {
1356
1341
node instanceof KeyDerivationAlgorithmNode
1357
1342
}
1358
1343
@@ -1611,7 +1596,7 @@ module CryptographyBase<LocationSig Location, InputSig<Location> Input> {
1611
1596
1612
1597
override string getInternalType ( ) { result = "CipherOperation" }
1613
1598
1614
- override predicate isCandidateKnownAlgorithmNode ( AlgorithmNode node ) {
1599
+ override predicate isCandidateAlgorithmNode ( AlgorithmNode node ) {
1615
1600
node instanceof CipherAlgorithmNode
1616
1601
}
1617
1602
@@ -1930,7 +1915,7 @@ module CryptographyBase<LocationSig Location, InputSig<Location> Input> {
1930
1915
type instanceof SM4 and name = "SM4" and s = Block ( )
1931
1916
or
1932
1917
type instanceof OtherCipherType and
1933
- name instanceof UnknownPropertyValue and
1918
+ name instanceof UnknownPropertyValue and // TODO: get rid of this hack to bind structure and type
1934
1919
s = UnknownCipherStructureType ( )
1935
1920
}
1936
1921
@@ -1985,7 +1970,7 @@ module CryptographyBase<LocationSig Location, InputSig<Location> Input> {
1985
1970
1986
1971
override LocatableElement asElement ( ) { result = instance }
1987
1972
1988
- override predicate isCandidateKnownAlgorithmNode ( AlgorithmNode node ) {
1973
+ override predicate isCandidateAlgorithmNode ( AlgorithmNode node ) {
1989
1974
node instanceof HashAlgorithmNode
1990
1975
}
1991
1976
0 commit comments