1+ /**
2+ * Dependencies module for Infrastructure as Code languages.
3+ */
14private import codeql.Locations
25private import codeql.hcl.Terraform
36
47/**
58 * Dependency for all Infrastructure as Code languages.
69 */
7- class Dependency extends Location {
10+ abstract class Dependency extends Location {
11+ /**
12+ * Gets the name of the dependency.
13+ */
14+ abstract string getName ( ) ;
15+ /**
16+ * Gets the version of the dependency (in a format that is human-readable).
17+ */
18+ abstract string getVersion ( ) ;
19+ /**
20+ * Gets the raw version of the dependency (in a format that is machine-readable).
21+ */
22+ abstract string getRawVersion ( ) ;
23+ /**
24+ * Gets the semantic version of the dependency.
25+ */
26+ abstract SemanticVersion getSemanticVersion ( ) ;
27+ }
28+
29+
30+ /**
31+ * Dependency for Terraform.
32+ */
33+ class TerraformDependency extends Dependency {
834 string name ;
935 string version ;
1036
11- Dependency ( ) {
37+ TerraformDependency ( ) {
1238 // Terraform Provider
1339 exists ( Terraform:: Terraform tf , Terraform:: RequiredProvider rp | rp = tf .getRequiredProvider ( ) |
1440 this = rp .getLocation ( ) and
@@ -19,25 +45,15 @@ class Dependency extends Location {
1945
2046 override string toString ( ) { result = this .getName ( ) + "@" + this .getVersion ( ) }
2147
22- /**
23- * Gets the name of the dependency.
24- */
25- string getName ( ) { result = name }
48+ override string getName ( ) { result = name }
2649
27- /**
28- * Gets the version of the dependency.
29- */
30- string getVersion ( ) { result = this .getSemanticVersion ( ) .getPretty ( ) }
3150
32- /**
33- * Gets the raw version of the dependency.
34- */
35- string getRawVersion ( ) { result = version }
51+ override string getVersion ( ) { result = this .getSemanticVersion ( ) .getPretty ( ) }
3652
37- /**
38- * Gets the semantic version of the dependency.
39- */
40- SemanticVersion getSemanticVersion ( ) { result = version }
53+
54+ override string getRawVersion ( ) { result = version }
55+
56+ override SemanticVersion getSemanticVersion ( ) { result = version }
4157}
4258
4359class SemanticVersion extends string {
0 commit comments