-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathResources.qll
More file actions
48 lines (39 loc) · 1.24 KB
/
Resources.qll
File metadata and controls
48 lines (39 loc) · 1.24 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
private import codeql.Locations
private import codeql.hcl.AST
private import codeql.hcl.Terraform::Terraform
// Resources are the most important element in the Terraform language.
// Each resource block describes one or more infrastructure objects, such as
// virtual networks, compute instances, or higher-level components such as DNS
// records.
//
// https://developer.hashicorp.com/terraform/language/resources/syntax
class Resource extends Block {
Resource() { this.hasType("resource") }
/**
* Get the name of the resource.
*/
string getName() { result = this.getLabel(1) }
/**
* Get the provider of the resource.
*/
RequiredProvider getProvider() { none() }
/**
* Returns the resource id.
*/
string getId() { result = this.getName() }
/**
* Returns the resource type.
*/
string getResourceType() { result = this.getLabel(0) }
/**
* Checks to see if the resource type matches the given type.
*/
predicate hasResourceType(string type) { this.getResourceType() = type }
override string toString() {
result = "resource " + this.getResourceType() + " " + this.getName()
}
}
class Provider extends Block {
Provider() { this.hasType("provider") }
string getName() { result = this.getLabel(0) }
}