Skip to content

Commit 25ab1a9

Browse files
committed
Merge branch 'main' into redsun82/bazel-fix
2 parents bfc37fd + 67e2ea1 commit 25ab1a9

File tree

11 files changed

+97
-61
lines changed

11 files changed

+97
-61
lines changed

.github/workflows/swift.yml

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -68,21 +68,6 @@ jobs:
6868
steps:
6969
- uses: actions/checkout@v4
7070
- uses: ./swift/actions/run-ql-tests
71-
integration-tests-linux:
72-
if: github.repository_owner == 'github'
73-
needs: build-and-test-linux
74-
runs-on: ubuntu-latest-xl
75-
steps:
76-
- uses: actions/checkout@v4
77-
- uses: ./swift/actions/run-integration-tests
78-
integration-tests-macos:
79-
if: ${{ github.repository_owner == 'github' && github.event_name == 'pull_request' }}
80-
needs: build-and-test-macos
81-
runs-on: macos-12-xl
82-
timeout-minutes: 60
83-
steps:
84-
- uses: actions/checkout@v4
85-
- uses: ./swift/actions/run-integration-tests
8671
clang-format:
8772
if : ${{ github.event_name == 'pull_request' }}
8873
runs-on: ubuntu-latest

java/ql/lib/semmle/code/java/security/SpringCsrfProtection.qll

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,18 @@ predicate disablesSpringCsrfProtection(MethodCall call) {
1717
.getReferencedCallable()
1818
.hasQualifiedName("org.springframework.security.config.annotation.web.configurers",
1919
"AbstractHttpConfigurer", "disable")
20+
or
21+
call.getMethod().hasName("disable") and
22+
call.getReceiverType()
23+
.hasQualifiedName("org.springframework.security.config.web.server",
24+
"ServerHttpSecurity$CsrfSpec")
25+
or
26+
call.getMethod()
27+
.hasQualifiedName("org.springframework.security.config.web.server", "ServerHttpSecurity",
28+
"csrf") and
29+
call.getArgument(0)
30+
.(MemberRefExpr)
31+
.getReferencedCallable()
32+
.hasQualifiedName("org.springframework.security.config.web.server",
33+
"ServerHttpSecurity$CsrfSpec", "disable")
2034
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
---
2+
category: minorAnalysis
3+
---
4+
* The query `java/spring-disabled-csrf-protection` detects disabling CSRF via `ServerHttpSecurity$CsrfSpec::disable`.
Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,15 @@
11
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
22
import org.springframework.security.config.annotation.web.configurers.AbstractHttpConfigurer;
3+
import org.springframework.security.config.web.server.ServerHttpSecurity;
34

45
public class SpringCsrfProtectionTest {
5-
protected void test(HttpSecurity http) throws Exception {
6+
protected void test(HttpSecurity http, final ServerHttpSecurity httpSecurity) throws Exception {
67
http.csrf(csrf -> csrf.disable()); // $ hasSpringCsrfProtectionDisabled
78
http.csrf().disable(); // $ hasSpringCsrfProtectionDisabled
89
http.csrf(AbstractHttpConfigurer::disable); // $ hasSpringCsrfProtectionDisabled
10+
11+
httpSecurity.csrf(csrf -> csrf.disable()); // $ hasSpringCsrfProtectionDisabled
12+
httpSecurity.csrf().disable(); // $ hasSpringCsrfProtectionDisabled
13+
httpSecurity.csrf(ServerHttpSecurity.CsrfSpec::disable); // $ hasSpringCsrfProtectionDisabled
914
}
10-
}
15+
}

java/ql/test/stubs/springframework-5.3.8/org/springframework/security/config/web/server/ServerHttpSecurity.java

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

misc/bazel/pkg.bzl

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ def codeql_pkg_files(
7272

7373
def _extract_pkg_filegroup_impl(ctx):
7474
src = ctx.attr.src[PackageFilegroupInfo]
75+
arch_overrides = ctx.attr.arch_overrides
7576
platform = _detect_platform(ctx)
7677

7778
if src.pkg_dirs or src.pkg_symlinks:
@@ -82,8 +83,11 @@ def _extract_pkg_filegroup_impl(ctx):
8283
dest_src_map = {}
8384
for dest, file in pfi.dest_src_map.items():
8485
file_kind, expanded_dest = _expand_path(dest, platform)
86+
if file_kind == "generic" and dest in arch_overrides:
87+
file_kind = "arch"
8588
if file_kind == ctx.attr.kind:
8689
dest_src_map[expanded_dest] = file
90+
8791
if dest_src_map:
8892
pkg_files.append((PackageFilesInfo(dest_src_map = dest_src_map, attributes = pfi.attributes), origin))
8993

@@ -101,12 +105,14 @@ _extract_pkg_filegroup = rule(
101105
destination paths to the relevant codeql platform (linux64, win64 or osx64).
102106
The distinction between generic and arch contents is given on a per-file basis depending on the install path
103107
containing {CODEQL_PLATFORM}, which will typically have been added by a `prefix` attribute to a `pkg_*` rule.
108+
Files that are arch-specific, but outside of the `CODEQL_PLATFORM` path can be specified in `arch_overrides`.
104109
No `pkg_dirs` or `pkg_symlink` must have been used for assembling the source mapping information: we could
105110
easily add support for that, but we don't require it for now.
106111
""",
107112
attrs = {
108113
"src": attr.label(providers = [PackageFilegroupInfo, DefaultInfo]),
109114
"kind": attr.string(doc = "What part to extract", values = ["generic", "arch"]),
115+
"arch_overrides": attr.string_list(doc = "A list of files that should be included in the arch package regardless of the path"),
110116
} | OS_DETECTION_ATTRS,
111117
)
112118

@@ -253,28 +259,35 @@ def codeql_pack(
253259
visibility = None,
254260
install_dest = "extractor-pack",
255261
compression_level = None,
262+
arch_overrides = None,
263+
zip_prefix = None,
256264
**kwargs):
257265
"""
258266
Define a codeql pack. This macro accepts `pkg_files`, `pkg_filegroup` or their `codeql_*` counterparts as `srcs`.
259-
`zips` is a map from prefixes to `.zip` files to import.
267+
`zips` is a map from `.zip` files to prefixes to import.
260268
* defines a `<name>-generic-zip` target creating a `<zip_filename>-generic.zip` archive with the generic bits,
261-
prefixed with `name`
269+
prefixed with `zip_prefix`
262270
* defines a `<name>-arch-zip` target creating a `<zip_filename>-<codeql_platform>.zip` archive with the
263-
arch-specific bits, prefixed with `name`
271+
arch-specific bits, prefixed with `zip_prefix`
264272
* defines a runnable `<name>-installer` target that will install the pack in `install_dest`, relative to where the
265273
rule is used. The install destination can be overridden appending `-- --destdir=...` to the `bazel run`
266-
invocation. This installation _does not_ prefix the contents with `name`.
274+
invocation. This installation _does not_ prefix the contents with `zip_prefix`.
275+
The prefix for the zip files can be set with `zip_prefix`, it is `name` by default.
267276
268277
The distinction between arch-specific and generic contents is made based on whether the paths (including possible
269278
prefixes added by rules) contain the special `{CODEQL_PLATFORM}` placeholder, which in case it is present will also
270279
be replaced by the appropriate platform (`linux64`, `win64` or `osx64`).
280+
Specific file paths can be placed in the arch-specific package by adding them to `arch_overrides`, even if their
281+
path doesn't contain the `CODEQL_PLATFORM` placeholder.
271282
272283
`compression_level` can be used to tweak the compression level used when creating archives. Consider that this
273284
does not affect the contents of `zips`, only `srcs`.
274285
"""
275286
internal = _make_internal(name)
276287
zip_filename = zip_filename or name
277288
zips = zips or {}
289+
if zip_prefix == None:
290+
zip_prefix = name
278291
pkg_filegroup(
279292
name = internal("all"),
280293
srcs = srcs,
@@ -292,6 +305,7 @@ def codeql_pack(
292305
name = internal(kind),
293306
src = internal("all"),
294307
kind = kind,
308+
arch_overrides = arch_overrides,
295309
visibility = ["//visibility:private"],
296310
)
297311
if zips:
@@ -311,15 +325,15 @@ def codeql_pack(
311325
name = internal(kind, "zip"),
312326
srcs = [internal(kind, "zip-base"), internal(kind, "zip-info")],
313327
out = _get_zip_filename(name, kind),
314-
prefix = name,
328+
prefix = zip_prefix,
315329
visibility = visibility,
316330
)
317331
else:
318332
pkg_zip(
319333
name = internal(kind, "zip"),
320334
srcs = [internal(kind)],
321335
visibility = visibility,
322-
package_dir = name,
336+
package_dir = zip_prefix,
323337
package_file_name = _get_zip_filename(name, kind),
324338
compression_level = compression_level,
325339
)

ql/extractor/src/extractor.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ pub fn run(options: Options) -> std::io::Result<()> {
5353
trap_dir: options.output_dir,
5454
trap_compression: trap::Compression::from_env("CODEQL_QL_TRAP_COMPRESSION"),
5555
source_archive_dir: options.source_archive_dir,
56-
file_list: options.file_list,
56+
file_lists: vec![options.file_list],
5757
};
5858

5959
extractor.run()

shared/tree-sitter-extractor/src/extractor/simple.rs

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ pub struct Extractor {
2020
pub languages: Vec<LanguageSpec>,
2121
pub trap_dir: PathBuf,
2222
pub source_archive_dir: PathBuf,
23-
pub file_list: PathBuf,
23+
pub file_lists: Vec<PathBuf>,
2424
// Typically constructed via `trap::Compression::from_env`.
2525
// This allow us to report the error using our diagnostics system
2626
// without exposing it to consumers.
@@ -74,7 +74,14 @@ impl Extractor {
7474
.build_global()
7575
.unwrap();
7676

77-
let file_list = File::open(&self.file_list)?;
77+
let file_lists: Vec<File> = self
78+
.file_lists
79+
.iter()
80+
.map(|file_list| {
81+
File::open(file_list)
82+
.unwrap_or_else(|_| panic!("Unable to open file list at {:?}", file_list))
83+
})
84+
.collect();
7885

7986
let mut schemas = vec![];
8087
for lang in &self.languages {
@@ -103,8 +110,10 @@ impl Extractor {
103110
)
104111
};
105112

106-
let lines: std::io::Result<Vec<String>> =
107-
std::io::BufReader::new(file_list).lines().collect();
113+
let lines: std::io::Result<Vec<String>> = file_lists
114+
.iter()
115+
.flat_map(|file_list| std::io::BufReader::new(file_list).lines())
116+
.collect();
108117
let lines = lines?;
109118

110119
lines

shared/tree-sitter-extractor/tests/integration_test.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ fn simple_extractor() {
3030
languages: vec![language],
3131
trap_dir,
3232
source_archive_dir,
33-
file_list,
33+
file_lists: vec![file_list],
3434
trap_compression: Ok(trap::Compression::Gzip),
3535
};
3636

shared/tree-sitter-extractor/tests/multiple_languages.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ fn multiple_language_extractor() {
3939
languages: vec![lang_ql, lang_json],
4040
trap_dir,
4141
source_archive_dir,
42-
file_list,
42+
file_lists: vec![file_list],
4343
trap_compression: Ok(trap::Compression::Gzip),
4444
};
4545

0 commit comments

Comments
 (0)