Skip to content

Commit d1c1ce1

Browse files
committed
feat(tf): Improve Azure provide
1 parent ddb5c39 commit d1c1ce1

1 file changed

Lines changed: 96 additions & 5 deletions

File tree

ql/lib/codeql/hcl/providers/Azure.qll

Lines changed: 96 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,12 @@ module Azure {
109109
*/
110110
override string getName() { result = this.getAttribute("name").(StringLiteral).getValue() }
111111

112+
/**
113+
* Get the `allow_blob_public_access` property of the storage account. Only available
114+
* for `azurerm` v2 and not v3 onwards.
115+
*
116+
* https://github.com/hashicorp/terraform-provider-azurerm/blob/main/CHANGELOG-v3.md
117+
*/
112118
Expr getAllowBlobPublicAccess() {
113119
this.getProvider().getSemanticVersion().maybeBefore("3.0.0") and
114120
result = this.getAttribute("allow_blob_public_access")
@@ -121,43 +127,128 @@ module Azure {
121127
* https://github.com/hashicorp/terraform-provider-azurerm/blob/main/CHANGELOG-v3.md
122128
*/
123129
boolean getAllowBlobPublicAccessValue() {
124-
result = this.getAllowBlobPublicAccess().(BooleanLiteral).getBool()
130+
exists(Expr e | e = this.getAllowBlobPublicAccess() | result = e.(BooleanLiteral).getBool())
125131
or
126-
result = false
132+
not exists(this.getAllowBlobPublicAccess()) and
133+
result = true
127134
}
128135

136+
/**
137+
* Get the `public_network_access_enabled` property of the storage account.
138+
*
139+
* https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/storage_account.html#public_network_access_enabled
140+
*/
129141
Expr getEnableHttpsTrafficOnly() {
130142
result = this.getAttribute("enable_https_traffic_only")
131143
}
132144

133145
/**
134146
* Get the `public_network_access_enabled` property of the storage account.
147+
*
148+
* Defaults to `true`.
149+
*
150+
* https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/storage_account.html#public_network_access_enabled
135151
*/
136152
boolean getEnableHttpsTrafficOnlyValue() {
137-
result = this.getEnableHttpsTrafficOnly().(BooleanLiteral).getBool()
153+
exists(Expr e | e = this.getEnableHttpsTrafficOnly() | result = e.(BooleanLiteral).getBool())
154+
or
155+
not exists(this.getEnableHttpsTrafficOnly()) and
156+
result = true
138157
}
139158

159+
/**
160+
* Get the `public_network_access_enabled` property of the storage account.
161+
*
162+
* https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/storage_account.html#public_network_access_enabled
163+
*/
140164
Expr getPublicNetworkAccess() {
141165
result = this.getAttribute("public_network_access_enabled")
142166
}
143167

144168
/**
145169
* Get the `public_network_access_enabled` property of the storage account.
170+
*
171+
* Defaults to `true`.
172+
*
173+
* https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/storage_account.html#public_network_access_enabled
146174
*/
147175
boolean getPublicNetworkAccessValue() {
148-
result = this.getPublicNetworkAccess().(BooleanLiteral).getBool()
176+
exists(Expr e | e = this.getPublicNetworkAccess() | result = e.(BooleanLiteral).getBool())
177+
or
178+
not exists(this.getPublicNetworkAccess()) and
179+
result = true
149180
}
150181

182+
/**
183+
* Get the `allow_nested_items_to_be_public` property of the storage account.
184+
*
185+
* Defaults to `true`
186+
*
187+
* https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/storage_account.html#allow_nested_items_to_be_public
188+
*/
151189
Expr getAllowNestedItemsToBePublic() {
152190
result = this.getAttribute("allow_nested_items_to_be_public")
153191
}
154192

155193
/**
156194
* Get the `allow_nested_items_to_be_public` property of the storage account.
195+
*
196+
* Defaults to `true`
197+
*
198+
* https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/storage_account.html#allow_nested_items_to_be_public
157199
*/
158200
boolean getAllowNestedItemsToBePublicValue() {
159-
result = this.getPublicNetworkAccess().(BooleanLiteral).getBool()
201+
exists(Expr e | e = this.getAllowNestedItemsToBePublic() | result = e.(BooleanLiteral).getBool())
202+
or
203+
not exists(this.getAllowNestedItemsToBePublic()) and
204+
result = true
160205
}
206+
207+
/**
208+
* Get the `https_traffic_only_enabled` property of the storage account.
209+
*
210+
* https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/storage_account.html#https_traffic_only_enabled
211+
*/
212+
Expr getHttpsTrafficOnlyEnabled() {
213+
result = this.getAttribute("https_traffic_only_enabled")
214+
}
215+
216+
/**
217+
* Get the `https_traffic_only_enabled` property of the storage account.
218+
*
219+
* Defaults to `true`
220+
*
221+
* https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/storage_account.html#https_traffic_only_enabled
222+
*/
223+
boolean getHttpsTrafficOnlyEnabledValue() {
224+
exists(Expr e | e = this.getHttpsTrafficOnlyEnabled() | result = e.(BooleanLiteral).getBool())
225+
or
226+
not exists(this.getHttpsTrafficOnlyEnabled()) and
227+
result = true
228+
}
229+
230+
/**
231+
* Get the `min_tls_version` property of the storage account.
232+
*
233+
* https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/storage_account.html#min_tls_version
234+
*/
235+
Expr getMinTlsVersion() {
236+
result = this.getAttribute("min_tls_version")
237+
}
238+
239+
/**
240+
* Get the `min_tls_version` property of the storage account.
241+
*
242+
* Defaults to `TLS1_2`
243+
*
244+
* https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/storage_account.html#min_tls_version
245+
*/
246+
string getMinTlsVersionValue() {
247+
exists(Expr e | e = this.getMinTlsVersion() | result = e.(StringLiteral).getValue())
248+
or
249+
not exists(this.getMinTlsVersion()) and
250+
result = "TLS1_2"
251+
}
161252
}
162253

163254
/**

0 commit comments

Comments
 (0)