Skip to content

Commit 94fd962

Browse files
authored
Merge pull request #59 from advanced-security/bicep
Add Initial Bicep support to Extractor
2 parents c049cee + db06a22 commit 94fd962

File tree

30 files changed

+1849
-43
lines changed

30 files changed

+1849
-43
lines changed

.github/workflows/build.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ jobs:
3737
3838
./scripts/create-extractor-pack.sh
3939
40+
gh codeql resolve languages --format=json --search-path ./extractor-pack
41+
4042
- name: "Run Tests"
4143
if: steps.changes.outputs.src == 'true'
4244
run: |

Cargo.lock

Lines changed: 26 additions & 34 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

codeql-extractor.yml

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,33 @@
11
name: "iac"
22
display_name: "IAC"
3-
version: 0.0.3
3+
version: 0.0.4
44
column_kind: "utf8"
55
legacy_qltest_extraction: true
66
github_api_languages:
77
- HCL
88
- Docker
9+
- Bicep
910
scc_languages:
1011
- HCL
1112
- Docker
13+
- Bicep
1214

1315
# File types
1416
file_types:
1517
- name: hcl
1618
display_name: HCL
1719
extensions:
1820
- .tf
19-
- .ftvars
21+
- .tfvars
2022
- .hcl
21-
- name: json
22-
display_name: JSON
23-
extensions:
24-
- .json
23+
2524
- name: dockerfile
2625
display_name: Dockerfile
2726
extensions:
2827
- .Dockerfile
2928
- .Containerfile
29+
30+
- name: bicep
31+
display_name: Bicep
32+
extensions:
33+
- .bicep

docs/languages-and-frameworks.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ The `codeql-extractor-iac` extractor supports the following languages:
1010
| JSON | `.json`, `.jsonl`, `.jsonc` |
1111
| YAML | `.yaml`, `.yml` |
1212
| Container files | `*Dockerfile`, `*Containerfile` |
13+
| Bicep | `.bicep` |
1314

1415
All of these files will be extracted and stored inside the IaC CodeQL Database.
1516

@@ -30,7 +31,7 @@ The following table lists the supported frameworks and technologies:
3031
| Docker / Container file(s) | 2 | extractor and library |
3132
| GitHub Actions | 2 | extractor and library |
3233
| OpenAPI / Swagger | 2 | extractor and library |
33-
| Azure Bicep | 0 | currently unsupported |
34+
| Azure Bicep | 2 | extractor and library |
3435

3536
_levels grades are based on completeness, higher the grade the better its supported._
3637

extractor/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ flate2 = "1.0"
1212
tree-sitter = ">= 0.20, < 0.21"
1313
tree-sitter-hcl = { git = "https://github.com/GeekMasher/tree-sitter-hcl", rev = "5e045dd1ff7852511c249c4c5d919d9556751d98" }
1414
tree-sitter-dockerfile = { git = "https://github.com/GeekMasher/tree-sitter-dockerfile", rev = "c0a9d694d9bf8ab79a919f5f9c7bc9c169caf321" }
15+
tree-sitter-bicep = { git = "https://github.com/GeekMasher/tree-sitter-bicep", rev = "3604d8c961ab129d2bfc6dfca56419c236ccdb83" }
1516
clap = { version = "4.4", features = ["derive"] }
1617
tracing = "0.1"
1718
tracing-subscriber = { version = "0.3.17", features = ["env-filter"] }

extractor/src/autobuilder.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ pub fn run(_: Options) -> std::io::Result<()> {
1919
".tf",
2020
".ftvars", // Terraform / HCL files
2121
".Dockerfile", // Docker files
22+
".bicep", // Bicep files
2223
])
2324
.include_globs(&[
2425
"**/Dockerfile",

extractor/src/extractor.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,12 @@ pub fn run(options: Options) -> std::io::Result<()> {
4242
node_types: tree_sitter_dockerfile::NODE_TYPES,
4343
file_globs: vec!["*Dockerfile".into(), "*Containerfile".into()],
4444
},
45+
simple::LanguageSpec {
46+
prefix: "bicep",
47+
ts_language: tree_sitter_bicep::language(),
48+
node_types: tree_sitter_bicep::NODE_TYPES,
49+
file_globs: vec!["*.bicep".into()],
50+
},
4551
],
4652
trap_dir: options.output_dir,
4753
trap_compression: trap::Compression::from_env("CODEQL_IAC_TRAP_COMPRESSION"),

extractor/src/generator.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,10 @@ pub fn run(options: Options) -> std::io::Result<()> {
3131
name: "DOCKERFILE".to_owned(),
3232
node_types: tree_sitter_dockerfile::NODE_TYPES,
3333
},
34+
Language {
35+
name: "BICEP".to_owned(),
36+
node_types: tree_sitter_bicep::NODE_TYPES,
37+
},
3438
];
3539

3640
generate(languages, options.dbscheme, options.library)

ql/lib/bicep.qll

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import codeql.Locations
2+
import codeql.files.FileSystem
3+
import codeql.bicep.AST
4+
// Resources
5+
import codeql.bicep.microsoft.Compute
6+
import codeql.bicep.microsoft.Storage

ql/lib/codeql/bicep/AST.qll

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
import codeql.bicep.ast.AstNodes
2+
import codeql.bicep.ast.Expr
3+
import codeql.bicep.ast.Literal
4+
import codeql.bicep.ast.Resources

0 commit comments

Comments
 (0)