@@ -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
}
@@ -651,7 +655,7 @@ module CryptographyBase<LocationSig Location, InputSig<Location> Input> {
651
655
/**
652
656
* Gets the key artifact produced by this operation.
653
657
*/
654
- abstract DataFlowNode getOutputKeyArtifact ( ) ;
658
+ abstract ArtifactOutputDataFlowNode getOutputKeyArtifact ( ) ;
655
659
656
660
/**
657
661
* Gets the key artifact type produced.
@@ -898,29 +902,8 @@ module CryptographyBase<LocationSig Location, InputSig<Location> Input> {
898
902
predicate isExcludedFromGraph ( ) { none ( ) }
899
903
}
900
904
901
- signature string getDefaultValueSig ( ) ;
902
-
903
- signature ConsumerInputDataFlowNode getConsumerSig ( ) ;
904
-
905
- signature class NodeBaseSig instanceof NodeBase ;
906
-
907
- module PropertyOutput< getDefaultValueSig / 0 getDefault, getConsumerSig / 0 getConsumer> {
908
- bindingset [ root]
909
- predicate get ( NodeBase root , string value , Location location ) {
910
- if not exists ( getDefault ( ) ) and not exists ( getConsumer ( ) .getConsumer ( ) .getASource ( ) )
911
- then value instanceof UnknownPropertyValue and location instanceof UnknownLocation
912
- else (
913
- if exists ( getDefault ( ) )
914
- then
915
- value = "Default:" + getDefault ( ) and
916
- location = root .getLocation ( )
917
- else node_as_property ( getConsumer ( ) .getConsumer ( ) .getAGenericSourceNode ( ) , value , location )
918
- )
919
- }
920
- }
921
-
922
905
/**
923
- * A generic source node is a source of data that is not resolvable to a specific value or type .
906
+ * A generic source node is a source of data that is not resolvable to a specific asset .
924
907
*/
925
908
private class GenericSourceNode extends NodeBase , TGenericSourceNode {
926
909
GenericSourceInstance instance ;
@@ -956,7 +939,7 @@ module CryptographyBase<LocationSig Location, InputSig<Location> Input> {
956
939
* Holds if `node` is a potential candidate for a known algorithm node.
957
940
* This predicate should be used to restrict the set of candidate algorithm node types.
958
941
*/
959
- abstract predicate isCandidateKnownAlgorithmNode ( AlgorithmNode node ) ;
942
+ abstract predicate isCandidateAlgorithmNode ( AlgorithmNode node ) ;
960
943
961
944
/**
962
945
* Gets the algorithm or generic source nodes consumed as an algorithm associated with this operation.
@@ -968,12 +951,12 @@ module CryptographyBase<LocationSig Location, InputSig<Location> Input> {
968
951
}
969
952
970
953
/**
971
- * Gets a known algorithm associated with this operation, subject to `isCandidateKnownAlgorithmNode `.
954
+ * Gets a known algorithm associated with this operation, subject to `isCandidateAlgorithmNode `.
972
955
*/
973
956
AlgorithmNode getAKnownAlgorithm ( ) {
974
957
result =
975
958
this .asElement ( ) .( OperationInstance ) .getAnAlgorithmValueConsumer ( ) .getAKnownSourceNode ( ) and
976
- this .isCandidateKnownAlgorithmNode ( result )
959
+ this .isCandidateAlgorithmNode ( result )
977
960
}
978
961
979
962
override NodeBase getChild ( string edgeName ) {
@@ -1147,9 +1130,11 @@ module CryptographyBase<LocationSig Location, InputSig<Location> Input> {
1147
1130
// [KNOWN_OR_UNKNOWN] - only if asymmetric
1148
1131
edgeName = "Algorithm" and
1149
1132
instance .getKeyType ( ) instanceof TAsymmetricKeyType and
1150
- if exists ( this .getAKnownAlgorithmOrGenericSourceNode ( ) )
1151
- then result = this .getAKnownAlgorithmOrGenericSourceNode ( )
1152
- else result = this
1133
+ (
1134
+ if exists ( this .getAKnownAlgorithmOrGenericSourceNode ( ) )
1135
+ then result = this .getAKnownAlgorithmOrGenericSourceNode ( )
1136
+ else result = this
1137
+ )
1153
1138
}
1154
1139
1155
1140
override predicate properties ( string key , string value , Location location ) {
@@ -1217,7 +1202,7 @@ module CryptographyBase<LocationSig Location, InputSig<Location> Input> {
1217
1202
1218
1203
override LocatableElement asElement ( ) { result = instance }
1219
1204
1220
- override predicate isCandidateKnownAlgorithmNode ( AlgorithmNode node ) {
1205
+ override predicate isCandidateAlgorithmNode ( AlgorithmNode node ) {
1221
1206
node instanceof MACAlgorithmNode
1222
1207
}
1223
1208
@@ -1292,7 +1277,7 @@ module CryptographyBase<LocationSig Location, InputSig<Location> Input> {
1292
1277
1293
1278
KeyGenerationOperationNode ( ) { keyGenInstance = instance }
1294
1279
1295
- override predicate isCandidateKnownAlgorithmNode ( AlgorithmNode node ) {
1280
+ override predicate isCandidateAlgorithmNode ( AlgorithmNode node ) {
1296
1281
node instanceof CipherAlgorithmNode
1297
1282
}
1298
1283
@@ -1326,7 +1311,7 @@ module CryptographyBase<LocationSig Location, InputSig<Location> Input> {
1326
1311
result .asElement ( ) = kdfInstance .getOutputKeySizeConsumer ( ) .getConsumer ( ) .getAGenericSource ( )
1327
1312
}
1328
1313
1329
- override predicate isCandidateKnownAlgorithmNode ( AlgorithmNode node ) {
1314
+ override predicate isCandidateAlgorithmNode ( AlgorithmNode node ) {
1330
1315
node instanceof KeyDerivationAlgorithmNode
1331
1316
}
1332
1317
@@ -1585,7 +1570,7 @@ module CryptographyBase<LocationSig Location, InputSig<Location> Input> {
1585
1570
1586
1571
override string getInternalType ( ) { result = "CipherOperation" }
1587
1572
1588
- override predicate isCandidateKnownAlgorithmNode ( AlgorithmNode node ) {
1573
+ override predicate isCandidateAlgorithmNode ( AlgorithmNode node ) {
1589
1574
node instanceof CipherAlgorithmNode
1590
1575
}
1591
1576
@@ -1904,7 +1889,7 @@ module CryptographyBase<LocationSig Location, InputSig<Location> Input> {
1904
1889
type instanceof SM4 and name = "SM4" and s = Block ( )
1905
1890
or
1906
1891
type instanceof OtherCipherType and
1907
- name instanceof UnknownPropertyValue and
1892
+ name instanceof UnknownPropertyValue and // TODO: get rid of this hack to bind structure and type
1908
1893
s = UnknownCipherStructureType ( )
1909
1894
}
1910
1895
@@ -1959,7 +1944,7 @@ module CryptographyBase<LocationSig Location, InputSig<Location> Input> {
1959
1944
1960
1945
override LocatableElement asElement ( ) { result = instance }
1961
1946
1962
- override predicate isCandidateKnownAlgorithmNode ( AlgorithmNode node ) {
1947
+ override predicate isCandidateAlgorithmNode ( AlgorithmNode node ) {
1963
1948
node instanceof HashAlgorithmNode
1964
1949
}
1965
1950
0 commit comments