Skip to content

Commit 2bec696

Browse files
committed
Merge branch 'main' into redsun82/pkg
2 parents 546d644 + bd6e233 commit 2bec696

File tree

74 files changed

+3592
-4755
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

74 files changed

+3592
-4755
lines changed

.bazelrc

+2
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,6 @@ common --enable_runfiles
2222
common --registry=file:///%workspace%/misc/bazel/registry
2323
common --registry=https://bcr.bazel.build
2424

25+
common --@rules_dotnet//dotnet/settings:strict_deps=false
26+
2527
try-import %workspace%/local.bazelrc

.bazelrc.internal

+6
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,9 @@
22

33
common --registry=file:///%workspace%/ql/misc/bazel/registry
44
common --registry=https://bcr.bazel.build
5+
6+
# See bazelbuild/rules_dotnet#413: strict_deps in C# also appliy to 3rd-party deps, and when we pull
7+
# in (for example) the xunit package, there's no code in this at all, it just depends transitively on
8+
# its implementation packages without providing any code itself.
9+
# We either can depend on internal implementation details, or turn of strict deps.
10+
common --@rules_dotnet//dotnet/settings:strict_deps=false

.gitattributes

+2
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,8 @@ ruby/extractor/cargo-bazel-lock.json -merge
7878
csharp/paket.lock linguist-generated=true
7979
# needs eol=crlf, as `paket` touches this file and saves it als crlf
8080
csharp/.paket/Paket.Restore.targets linguist-generated=true eol=crlf
81+
csharp/paket.main.bzl linguist-generated=true
82+
csharp/paket.main_extension.bzl linguist-generated=true
8183

8284
# ripunzip tool
8385
/misc/bazel/internal/ripunzip/ripunzip-* filter=lfs diff=lfs merge=lfs -text

.github/workflows/build-ripunzip.yml

+74
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
name: Build runzip
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
ripunzip-version:
7+
description: "what reference to checktout from google/runzip"
8+
required: false
9+
default: v1.2.1
10+
openssl-version:
11+
description: "what reference to checkout from openssl/openssl for Linux"
12+
required: false
13+
default: openssl-3.3.0
14+
15+
jobs:
16+
build:
17+
strategy:
18+
fail-fast: false
19+
matrix:
20+
os: [ubuntu-20.04, macos-12, windows-2019]
21+
runs-on: ${{ matrix.os }}
22+
steps:
23+
- uses: actions/checkout@v4
24+
with:
25+
repository: google/ripunzip
26+
ref: ${{ inputs.ripunzip-version }}
27+
# we need to avoid ripunzip dynamically linking into libssl
28+
# see https://github.com/sfackler/rust-openssl/issues/183
29+
- if: runner.os == 'Linux'
30+
name: checkout openssl
31+
uses: actions/checkout@v4
32+
with:
33+
repository: openssl/openssl
34+
path: openssl
35+
ref: ${{ inputs.openssl-version }}
36+
- if: runner.os == 'Linux'
37+
name: build and install openssl with fPIC
38+
shell: bash
39+
working-directory: openssl
40+
run: |
41+
./config -fPIC --prefix=$HOME/.local --openssldir=$HOME/.local/ssl
42+
make -j $(nproc)
43+
make install_sw -j $(nproc)
44+
- if: runner.os == 'Linux'
45+
name: build (linux)
46+
shell: bash
47+
run: |
48+
env OPENSSL_LIB_DIR=$HOME/.local/lib64 OPENSSL_INCLUDE_DIR=$HOME/.local/include OPENSSL_STATIC=yes cargo build --release
49+
mv target/release/ripunzip ripunzip-linux
50+
- if: runner.os == 'Windows'
51+
name: build (windows)
52+
shell: bash
53+
run: |
54+
cargo build --release
55+
mv target/release/ripunzip ripunzip-windows
56+
- name: build (macOS)
57+
if: runner.os == 'macOS'
58+
shell: bash
59+
run: |
60+
rustup target install x86_64-apple-darwin
61+
rustup target install aarch64-apple-darwin
62+
cargo build --target x86_64-apple-darwin --release
63+
cargo build --target aarch64-apple-darwin --release
64+
lipo -create -output ripunzip-macos \
65+
-arch x86_64 target/x86_64-apple-darwin/release/ripunzip \
66+
-arch arm64 target/aarch64-apple-darwin/release/ripunzip
67+
- uses: actions/upload-artifact@v4
68+
with:
69+
name: ripunzip-${{ runner.os }}
70+
path: ripunzip-*
71+
- name: Check built binary
72+
shell: bash
73+
run: |
74+
./ripunzip-* --version

BUILD.bazel

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
exports_files(["LICENSE"])

MODULE.bazel

+10
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,19 @@ bazel_dep(name = "abseil-cpp", version = "20240116.0", repo_name = "absl")
2323
bazel_dep(name = "nlohmann_json", version = "3.11.3", repo_name = "json")
2424
bazel_dep(name = "fmt", version = "10.0.0")
2525
bazel_dep(name = "gazelle", version = "0.36.0")
26+
bazel_dep(name = "rules_dotnet", version = "0.15.1")
2627

2728
bazel_dep(name = "buildifier_prebuilt", version = "6.4.0", dev_dependency = True)
2829

30+
dotnet = use_extension("@rules_dotnet//dotnet:extensions.bzl", "dotnet")
31+
dotnet.toolchain(dotnet_version = "8.0.101")
32+
use_repo(dotnet, "dotnet_toolchains")
33+
34+
register_toolchains("@dotnet_toolchains//:all")
35+
36+
csharp_main_extension = use_extension("//csharp:paket.main_extension.bzl", "main_extension")
37+
use_repo(csharp_main_extension, "paket.main")
38+
2939
pip = use_extension("@rules_python//python/extensions:pip.bzl", "pip")
3040
pip.parse(
3141
hub_name = "codegen_deps",

config/identical-files.json

+4
Original file line numberDiff line numberDiff line change
@@ -364,5 +364,9 @@
364364
"Python model summaries test extension": [
365365
"python/ql/test/library-tests/dataflow/model-summaries/InlineTaintTest.ext.yml",
366366
"python/ql/test/library-tests/dataflow/model-summaries/NormalDataflowTest.ext.yml"
367+
],
368+
"shared tree-sitter extractor cargo.toml": [
369+
"shared/tree-sitter-extractor/Cargo.toml",
370+
"ruby/extractor/codeql-extractor-fake-crate/Cargo.toml"
367371
]
368372
}

csharp/BUILD.bazel

+77
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
load("@rules_pkg//pkg:mappings.bzl", "pkg_filegroup", "pkg_files")
2+
load("@semmle_code//:dist.bzl", "dist")
3+
load("//misc/bazel:pkg.bzl", "codeql_pkg_files_overlay")
4+
15
package(default_visibility = ["//visibility:public"])
26

37
alias(
@@ -9,3 +13,76 @@ alias(
913
name = "dbscheme-stats",
1014
actual = "//csharp/ql/lib:dbscheme-stats",
1115
)
16+
17+
pkg_files(
18+
name = "dbscheme-group",
19+
srcs = [
20+
":dbscheme",
21+
":dbscheme-stats",
22+
],
23+
strip_prefix = None,
24+
)
25+
26+
pkg_files(
27+
name = "extractor-asp",
28+
srcs = [
29+
"@semmle_code//extractor-asp:extractor-asp-fat",
30+
],
31+
prefix = "tools",
32+
renames = {
33+
"@semmle_code//extractor-asp:extractor-asp-fat": "extractor-asp.jar",
34+
},
35+
)
36+
37+
pkg_filegroup(
38+
name = "db-files",
39+
srcs = [
40+
":dbscheme-group",
41+
"//csharp/downgrades",
42+
],
43+
)
44+
45+
pkg_files(
46+
name = "extra-files",
47+
srcs = [
48+
":codeql-extractor.yml",
49+
"//:LICENSE",
50+
],
51+
)
52+
53+
codeql_pkg_files_overlay(
54+
name = "extractor-arch-overlay",
55+
srcs = [
56+
"//csharp/autobuilder/Semmle.Autobuild.CSharp",
57+
"//csharp/extractor/Semmle.Extraction.CSharp.Driver",
58+
"//csharp/extractor/Semmle.Extraction.CSharp.Standalone",
59+
],
60+
)
61+
62+
dist(
63+
name = "extractor-arch",
64+
srcs = [":extractor-arch-overlay"],
65+
)
66+
67+
dist(
68+
name = "extractor-generic",
69+
srcs = [
70+
":dbscheme-group",
71+
":extra-files",
72+
":extractor-asp",
73+
"//csharp/downgrades",
74+
"//csharp/tools",
75+
],
76+
prefix = "csharp",
77+
visibility = ["//visibility:public"],
78+
)
79+
80+
test_suite(
81+
name = "unit-tests",
82+
tags = ["csharp"],
83+
tests = [
84+
"//csharp/autobuilder/Semmle.Autobuild.CSharp.Tests",
85+
"//csharp/autobuilder/Semmle.Autobuild.Cpp.Tests",
86+
"//csharp/extractor/Semmle.Extraction.Tests",
87+
],
88+
)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
load(
2+
"//misc/bazel:csharp.bzl",
3+
"codeql_xunit_test",
4+
)
5+
6+
codeql_xunit_test(
7+
name = "Semmle.Autobuild.CSharp.Tests",
8+
srcs = glob([
9+
"*.cs",
10+
"Properties/*.cs",
11+
]),
12+
deps = [
13+
"//csharp/autobuilder/Semmle.Autobuild.CSharp:bin/Semmle.Autobuild.CSharp",
14+
"//csharp/autobuilder/Semmle.Autobuild.Shared",
15+
"@paket.main//microsoft.net.test.sdk",
16+
"@paket.main//system.io.filesystem",
17+
],
18+
)

csharp/autobuilder/Semmle.Autobuild.CSharp.Tests/BuildScripts.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -215,9 +215,9 @@ public void DownloadFile(string address, string fileName)
215215

216216
internal class TestDiagnosticWriter : IDiagnosticsWriter
217217
{
218-
public IList<DiagnosticMessage> Diagnostics { get; } = new List<DiagnosticMessage>();
218+
public IList<Semmle.Util.DiagnosticMessage> Diagnostics { get; } = new List<Semmle.Util.DiagnosticMessage>();
219219

220-
public void AddEntry(DiagnosticMessage message) => this.Diagnostics.Add(message);
220+
public void AddEntry(Semmle.Util.DiagnosticMessage message) => this.Diagnostics.Add(message);
221221

222222
public void Dispose() { }
223223
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
load(
2+
"//misc/bazel:csharp.bzl",
3+
"codeql_csharp_binary",
4+
)
5+
6+
codeql_csharp_binary(
7+
name = "Semmle.Autobuild.CSharp",
8+
srcs = glob([
9+
"*.cs",
10+
"Properties/*.cs",
11+
]),
12+
visibility = ["//csharp:__subpackages__"],
13+
deps = [
14+
"//csharp/autobuilder/Semmle.Autobuild.Shared",
15+
"//csharp/extractor/Semmle.Extraction.CSharp",
16+
"//csharp/extractor/Semmle.Extraction.CSharp.DependencyFetching",
17+
"//csharp/extractor/Semmle.Extraction.CSharp.Standalone:bin/Semmle.Extraction.CSharp.Standalone",
18+
"//csharp/extractor/Semmle.Util",
19+
"@paket.main//microsoft.build",
20+
"@paket.main//newtonsoft.json",
21+
],
22+
)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
load(
2+
"//misc/bazel:csharp.bzl",
3+
"codeql_xunit_test",
4+
)
5+
6+
codeql_xunit_test(
7+
name = "Semmle.Autobuild.Cpp.Tests",
8+
srcs = glob([
9+
"*.cs",
10+
"Properties/*.cs",
11+
]),
12+
deps = [
13+
"//csharp/autobuilder/Semmle.Autobuild.Cpp:bin/Semmle.Autobuild.Cpp",
14+
"//csharp/autobuilder/Semmle.Autobuild.Shared",
15+
"@paket.main//microsoft.net.test.sdk",
16+
"@paket.main//system.io.filesystem",
17+
],
18+
)

csharp/autobuilder/Semmle.Autobuild.Cpp.Tests/BuildScripts.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -200,9 +200,9 @@ public void DownloadFile(string address, string fileName)
200200

201201
internal class TestDiagnosticWriter : IDiagnosticsWriter
202202
{
203-
public IList<DiagnosticMessage> Diagnostics { get; } = new List<DiagnosticMessage>();
203+
public IList<Semmle.Util.DiagnosticMessage> Diagnostics { get; } = new List<Semmle.Util.DiagnosticMessage>();
204204

205-
public void AddEntry(DiagnosticMessage message) => this.Diagnostics.Add(message);
205+
public void AddEntry(Semmle.Util.DiagnosticMessage message) => this.Diagnostics.Add(message);
206206

207207
public void Dispose() { }
208208
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
load(
2+
"//misc/bazel:csharp.bzl",
3+
"codeql_csharp_binary",
4+
)
5+
6+
codeql_csharp_binary(
7+
name = "Semmle.Autobuild.Cpp",
8+
srcs = glob([
9+
"*.cs",
10+
"Properties/*.cs",
11+
]),
12+
language_prefix = "cpp",
13+
visibility = ["//visibility:public"],
14+
deps = [
15+
"//csharp/autobuilder/Semmle.Autobuild.Shared",
16+
"//csharp/extractor/Semmle.Util",
17+
"@paket.main//microsoft.build",
18+
],
19+
)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
load(
2+
"//misc/bazel:csharp.bzl",
3+
"codeql_csharp_library",
4+
)
5+
6+
codeql_csharp_library(
7+
name = "Semmle.Autobuild.Shared",
8+
srcs = glob([
9+
"*.cs",
10+
"Properties/*.cs",
11+
]),
12+
visibility = ["//visibility:public"],
13+
deps = [
14+
"//csharp/extractor/Semmle.Util",
15+
"@paket.main//microsoft.build",
16+
],
17+
)

csharp/downgrades/BUILD.bazel

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
load("@rules_pkg//:mappings.bzl", "pkg_files", "strip_prefix")
2+
3+
pkg_files(
4+
name = "downgrades",
5+
srcs = glob(
6+
["**"],
7+
exclude = ["BUILD.bazel"],
8+
),
9+
prefix = "downgrades",
10+
strip_prefix = strip_prefix.from_pkg(),
11+
visibility = ["//csharp:__pkg__"],
12+
)

csharp/extractor/BUILD.bazel

Whitespace-only changes.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
load(
2+
"//misc/bazel:csharp.bzl",
3+
"codeql_csharp_library",
4+
)
5+
6+
codeql_csharp_library(
7+
name = "Semmle.Extraction.CSharp.DependencyFetching",
8+
srcs = glob([
9+
"*.cs",
10+
"Properties/*.cs",
11+
"SourceGenerators/**/*.cs",
12+
]),
13+
allow_unsafe_blocks = True,
14+
internals_visible_to = ["Semmle.Extraction.Tests"],
15+
nowarn = ["CA1822"],
16+
visibility = ["//csharp:__subpackages__"],
17+
deps = [
18+
"//csharp/extractor/Semmle.Extraction",
19+
"//csharp/extractor/Semmle.Util",
20+
],
21+
)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
load(
2+
"//misc/bazel:csharp.bzl",
3+
"codeql_csharp_binary",
4+
)
5+
6+
codeql_csharp_binary(
7+
name = "Semmle.Extraction.CSharp.DependencyStubGenerator",
8+
srcs = glob([
9+
"*.cs",
10+
"Properties/*.cs",
11+
]),
12+
visibility = ["//csharp:__pkg__"],
13+
deps = [
14+
"//csharp/extractor/Semmle.Extraction.CSharp.DependencyFetching",
15+
"//csharp/extractor/Semmle.Extraction.CSharp.StubGenerator",
16+
"//csharp/extractor/Semmle.Util",
17+
],
18+
)

0 commit comments

Comments
 (0)