Skip to content

Add Database Support #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 15 commits into from
Jun 11, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ If you have an idea for a new feature or enhancement, [please open an issue on G
3. Make your changes
4. Write tests for your changes (if applicable)
5. Run the tests to make sure everything is working
6. Submit a [pull request][pr] with a clear description of your changes

### Requirements

Expand Down
3 changes: 3 additions & 0 deletions ql/lib/bicep.qll
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,8 @@ import codeql.Locations
import codeql.files.FileSystem
// AST
import codeql.bicep.AST
// CFG
import codeql.bicep.CFG
// Frameworks
import codeql.bicep.Frameworks
import codeql.bicep.Concepts
28 changes: 28 additions & 0 deletions ql/lib/codeql/bicep/Concepts.qll
Original file line number Diff line number Diff line change
@@ -1,2 +1,30 @@
private import codeql.bicep.AST
private import codeql.bicep.CFG

/**
* A Public Resource is a resource that is publicly accessible to the Internet.
*/
abstract class PublicResource extends Resource {
/**
* Returns the property that indicates public access.
*/
abstract Expr getPublicAccessProperty();
}

module Cryptography {
abstract class WeakTlsVersion extends Resource {
abstract StringLiteral getWeakTlsVersionProperty();

/**
* Returns true if the resource has a weak TLS version.
*
* 1.0 and 1.1 are considered weak TLS versions.
*/
predicate hasWeakTlsVersion() {
exists(StringLiteral literal |
literal = this.getWeakTlsVersionProperty() and
literal.getValue().regexpMatch("^(1\\.0|1\\.1)$")
)
}
}
}
3 changes: 2 additions & 1 deletion ql/lib/codeql/bicep/Frameworks.qll
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import frameworks.Microsoft.Compute
import frameworks.Microsoft.Network
import frameworks.Microsoft.Storage
import frameworks.Microsoft.Storage
import frameworks.Microsoft.Databases
11 changes: 7 additions & 4 deletions ql/lib/codeql/bicep/ast/Resources.qll
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ private import codeql.Locations
private import Expr
private import Idents
private import Literals

private import internal.ResourceDeclaration
private import internal.ObjectProperty
private import internal.Object
Expand Down Expand Up @@ -79,7 +78,6 @@ Resource resolveResource(Expr expr) {
)
}


class Resource extends TResource {
private ResourceDeclaration resource;

Expand All @@ -89,10 +87,15 @@ class Resource extends TResource {
exists(StringLiteral sl | sl = resource.getName() | result = sl.getValue())
}

Expr getProperty(string name) {
result = resource.getProperty(name)
string getName() {
exists(StringLiteral name |
name = resource.getProperty("name") and
result = name.getValue()
)
}

Expr getProperty(string name) { result = resource.getProperty(name) }

Resource getParent() { result = resolveResource(this.getProperty("parent")) }

string toString() { result = resource.toString() }
Expand Down
Loading