@@ -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 }
@@ -674,7 +678,7 @@ module CryptographyBase<LocationSig Location, InputSig<Location> Input> {
674678 /**
675679 * Gets the key artifact produced by this operation.
676680 */
677- abstract DataFlowNode getOutputKeyArtifact ( ) ;
681+ abstract ArtifactOutputDataFlowNode getOutputKeyArtifact ( ) ;
678682
679683 /**
680684 * Gets the key artifact type produced.
@@ -924,29 +928,8 @@ module CryptographyBase<LocationSig Location, InputSig<Location> Input> {
924928 predicate isExcludedFromGraph ( ) { none ( ) }
925929 }
926930
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-
948931 /**
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 .
950933 */
951934 private class GenericSourceNode extends NodeBase , TGenericSourceNode {
952935 GenericSourceInstance instance ;
@@ -982,7 +965,7 @@ module CryptographyBase<LocationSig Location, InputSig<Location> Input> {
982965 * Holds if `node` is a potential candidate for a known algorithm node.
983966 * This predicate should be used to restrict the set of candidate algorithm node types.
984967 */
985- abstract predicate isCandidateKnownAlgorithmNode ( AlgorithmNode node ) ;
968+ abstract predicate isCandidateAlgorithmNode ( AlgorithmNode node ) ;
986969
987970 /**
988971 * 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> {
994977 }
995978
996979 /**
997- * Gets a known algorithm associated with this operation, subject to `isCandidateKnownAlgorithmNode `.
980+ * Gets a known algorithm associated with this operation, subject to `isCandidateAlgorithmNode `.
998981 */
999982 AlgorithmNode getAKnownAlgorithm ( ) {
1000983 result =
1001984 this .asElement ( ) .( OperationInstance ) .getAnAlgorithmValueConsumer ( ) .getAKnownSourceNode ( ) and
1002- this .isCandidateKnownAlgorithmNode ( result )
985+ this .isCandidateAlgorithmNode ( result )
1003986 }
1004987
1005988 override NodeBase getChild ( string edgeName ) {
@@ -1173,9 +1156,11 @@ module CryptographyBase<LocationSig Location, InputSig<Location> Input> {
11731156 // [KNOWN_OR_UNKNOWN] - only if asymmetric
11741157 edgeName = "Algorithm" and
11751158 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+ )
11791164 }
11801165
11811166 override predicate properties ( string key , string value , Location location ) {
@@ -1243,7 +1228,7 @@ module CryptographyBase<LocationSig Location, InputSig<Location> Input> {
12431228
12441229 override LocatableElement asElement ( ) { result = instance }
12451230
1246- override predicate isCandidateKnownAlgorithmNode ( AlgorithmNode node ) {
1231+ override predicate isCandidateAlgorithmNode ( AlgorithmNode node ) {
12471232 node instanceof MACAlgorithmNode
12481233 }
12491234
@@ -1318,7 +1303,7 @@ module CryptographyBase<LocationSig Location, InputSig<Location> Input> {
13181303
13191304 KeyGenerationOperationNode ( ) { keyGenInstance = instance }
13201305
1321- override predicate isCandidateKnownAlgorithmNode ( AlgorithmNode node ) {
1306+ override predicate isCandidateAlgorithmNode ( AlgorithmNode node ) {
13221307 node instanceof CipherAlgorithmNode
13231308 }
13241309
@@ -1352,7 +1337,7 @@ module CryptographyBase<LocationSig Location, InputSig<Location> Input> {
13521337 result .asElement ( ) = kdfInstance .getOutputKeySizeConsumer ( ) .getConsumer ( ) .getAGenericSource ( )
13531338 }
13541339
1355- override predicate isCandidateKnownAlgorithmNode ( AlgorithmNode node ) {
1340+ override predicate isCandidateAlgorithmNode ( AlgorithmNode node ) {
13561341 node instanceof KeyDerivationAlgorithmNode
13571342 }
13581343
@@ -1611,7 +1596,7 @@ module CryptographyBase<LocationSig Location, InputSig<Location> Input> {
16111596
16121597 override string getInternalType ( ) { result = "CipherOperation" }
16131598
1614- override predicate isCandidateKnownAlgorithmNode ( AlgorithmNode node ) {
1599+ override predicate isCandidateAlgorithmNode ( AlgorithmNode node ) {
16151600 node instanceof CipherAlgorithmNode
16161601 }
16171602
@@ -1930,7 +1915,7 @@ module CryptographyBase<LocationSig Location, InputSig<Location> Input> {
19301915 type instanceof SM4 and name = "SM4" and s = Block ( )
19311916 or
19321917 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
19341919 s = UnknownCipherStructureType ( )
19351920 }
19361921
@@ -1985,7 +1970,7 @@ module CryptographyBase<LocationSig Location, InputSig<Location> Input> {
19851970
19861971 override LocatableElement asElement ( ) { result = instance }
19871972
1988- override predicate isCandidateKnownAlgorithmNode ( AlgorithmNode node ) {
1973+ override predicate isCandidateAlgorithmNode ( AlgorithmNode node ) {
19891974 node instanceof HashAlgorithmNode
19901975 }
19911976
0 commit comments