@@ -41,6 +41,10 @@ module CryptographyBase<LocationSig Location, InputSig<Location> Input> {
4141 ConsumerElement getConsumer ( ) { result .getInputNode ( ) = this }
4242 }
4343
44+ class ArtifactOutputDataFlowNode extends DataFlowNode {
45+ OutputArtifactInstance getArtifact ( ) { result .getOutputNode ( ) = this }
46+ }
47+
4448 final class UnknownPropertyValue extends string {
4549 UnknownPropertyValue ( ) { this = "<unknown>" }
4650 }
@@ -461,7 +465,7 @@ module CryptographyBase<LocationSig Location, InputSig<Location> Input> {
461465 this = Input:: dfn_to_element ( inputNode )
462466 }
463467
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())
465469
466470 final override ConsumerInputDataFlowNode getInputNode ( ) { result = inputNode }
467471 }
@@ -651,7 +655,7 @@ module CryptographyBase<LocationSig Location, InputSig<Location> Input> {
651655 /**
652656 * Gets the key artifact produced by this operation.
653657 */
654- abstract DataFlowNode getOutputKeyArtifact ( ) ;
658+ abstract ArtifactOutputDataFlowNode getOutputKeyArtifact ( ) ;
655659
656660 /**
657661 * Gets the key artifact type produced.
@@ -898,29 +902,8 @@ module CryptographyBase<LocationSig Location, InputSig<Location> Input> {
898902 predicate isExcludedFromGraph ( ) { none ( ) }
899903 }
900904
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-
922905 /**
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 .
924907 */
925908 private class GenericSourceNode extends NodeBase , TGenericSourceNode {
926909 GenericSourceInstance instance ;
@@ -956,7 +939,7 @@ module CryptographyBase<LocationSig Location, InputSig<Location> Input> {
956939 * Holds if `node` is a potential candidate for a known algorithm node.
957940 * This predicate should be used to restrict the set of candidate algorithm node types.
958941 */
959- abstract predicate isCandidateKnownAlgorithmNode ( AlgorithmNode node ) ;
942+ abstract predicate isCandidateAlgorithmNode ( AlgorithmNode node ) ;
960943
961944 /**
962945 * 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> {
968951 }
969952
970953 /**
971- * Gets a known algorithm associated with this operation, subject to `isCandidateKnownAlgorithmNode `.
954+ * Gets a known algorithm associated with this operation, subject to `isCandidateAlgorithmNode `.
972955 */
973956 AlgorithmNode getAKnownAlgorithm ( ) {
974957 result =
975958 this .asElement ( ) .( OperationInstance ) .getAnAlgorithmValueConsumer ( ) .getAKnownSourceNode ( ) and
976- this .isCandidateKnownAlgorithmNode ( result )
959+ this .isCandidateAlgorithmNode ( result )
977960 }
978961
979962 override NodeBase getChild ( string edgeName ) {
@@ -1147,9 +1130,11 @@ module CryptographyBase<LocationSig Location, InputSig<Location> Input> {
11471130 // [KNOWN_OR_UNKNOWN] - only if asymmetric
11481131 edgeName = "Algorithm" and
11491132 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+ )
11531138 }
11541139
11551140 override predicate properties ( string key , string value , Location location ) {
@@ -1217,7 +1202,7 @@ module CryptographyBase<LocationSig Location, InputSig<Location> Input> {
12171202
12181203 override LocatableElement asElement ( ) { result = instance }
12191204
1220- override predicate isCandidateKnownAlgorithmNode ( AlgorithmNode node ) {
1205+ override predicate isCandidateAlgorithmNode ( AlgorithmNode node ) {
12211206 node instanceof MACAlgorithmNode
12221207 }
12231208
@@ -1292,7 +1277,7 @@ module CryptographyBase<LocationSig Location, InputSig<Location> Input> {
12921277
12931278 KeyGenerationOperationNode ( ) { keyGenInstance = instance }
12941279
1295- override predicate isCandidateKnownAlgorithmNode ( AlgorithmNode node ) {
1280+ override predicate isCandidateAlgorithmNode ( AlgorithmNode node ) {
12961281 node instanceof CipherAlgorithmNode
12971282 }
12981283
@@ -1326,7 +1311,7 @@ module CryptographyBase<LocationSig Location, InputSig<Location> Input> {
13261311 result .asElement ( ) = kdfInstance .getOutputKeySizeConsumer ( ) .getConsumer ( ) .getAGenericSource ( )
13271312 }
13281313
1329- override predicate isCandidateKnownAlgorithmNode ( AlgorithmNode node ) {
1314+ override predicate isCandidateAlgorithmNode ( AlgorithmNode node ) {
13301315 node instanceof KeyDerivationAlgorithmNode
13311316 }
13321317
@@ -1585,7 +1570,7 @@ module CryptographyBase<LocationSig Location, InputSig<Location> Input> {
15851570
15861571 override string getInternalType ( ) { result = "CipherOperation" }
15871572
1588- override predicate isCandidateKnownAlgorithmNode ( AlgorithmNode node ) {
1573+ override predicate isCandidateAlgorithmNode ( AlgorithmNode node ) {
15891574 node instanceof CipherAlgorithmNode
15901575 }
15911576
@@ -1904,7 +1889,7 @@ module CryptographyBase<LocationSig Location, InputSig<Location> Input> {
19041889 type instanceof SM4 and name = "SM4" and s = Block ( )
19051890 or
19061891 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
19081893 s = UnknownCipherStructureType ( )
19091894 }
19101895
@@ -1959,7 +1944,7 @@ module CryptographyBase<LocationSig Location, InputSig<Location> Input> {
19591944
19601945 override LocatableElement asElement ( ) { result = instance }
19611946
1962- override predicate isCandidateKnownAlgorithmNode ( AlgorithmNode node ) {
1947+ override predicate isCandidateAlgorithmNode ( AlgorithmNode node ) {
19631948 node instanceof HashAlgorithmNode
19641949 }
19651950
0 commit comments