Skip to content

Commit b2c5e9f

Browse files
Tighten audit match boundaries
Require the exact Authorization key and a non-empty Windows username so generic map keys and profiles-directory prose remain public-safe.
1 parent 5d766f9 commit b2c5e9f

2 files changed

Lines changed: 17 additions & 3 deletions

File tree

public-source-release-audit/scripts/check_current_source.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
root(?:(?:/|\\/)|(?![A-Za-z0-9._-]))
1919
)
2020
|
21-
[A-Za-z]:[\\/]{1,2}(?i:Users)[\\/]{1,2}[^\\/\r\n]+(?:[\\/]{1,2}|$)
21+
[A-Za-z]:[\\/]{1,2}(?i:Users)[\\/]{1,2}[A-Za-z0-9._-]+(?:[\\/]{1,2}|(?=["'\s,;:)\]\}]|\z))
2222
)
2323
}x
2424
],
@@ -29,7 +29,7 @@
2929
],
3030
[
3131
"bearer credential",
32-
/["']?Authorization["']?\s*(?::|=>)\s*["']?Bearer\s+[A-Za-z0-9._~+\/=:-]{16,}/i
32+
/(?<![A-Za-z0-9_.-])(?<authorization_quote>["']?)Authorization\k<authorization_quote>(?![A-Za-z0-9_.-])\s*(?::|=>)\s*["']?Bearer\s+[A-Za-z0-9._~+\/=:-]{16,}/i
3333
],
3434
[
3535
"GitHub token",

public-source-release-audit/tests/test_check_current_source.rb

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,10 +237,12 @@ def test_ignored_local_files_are_outside_the_release_candidate
237237

238238
def test_unrelated_home_directory_and_web_route_do_not_match_user_homes
239239
with_repo do |repo|
240+
windows_profiles = "C:" + "\\Users\\"
240241
stage(repo, "paths.txt", [
241242
"/tmp/home/.local/bin/tool",
242243
"https://example.invalid/home/user/profile",
243-
"https://example.invalid/login?next=/home/user/profile"
244+
"https://example.invalid/login?next=/home/user/profile",
245+
"Windows stores profiles under #{windows_profiles} by default."
244246
].join("\n"))
245247

246248
stdout, stderr, status = run_checker(repo)
@@ -250,6 +252,18 @@ def test_unrelated_home_directory_and_web_route_do_not_match_user_homes
250252
end
251253
end
252254

255+
def test_similar_bearer_map_key_is_not_authorization
256+
with_repo do |repo|
257+
value = "Bearer " + ("a" * 24)
258+
stage(repo, "map.json", "{\"NotAuthorization\":\"#{value}\"}\n")
259+
260+
stdout, stderr, status = run_checker(repo)
261+
262+
assert status.success?, stderr
263+
assert_includes stdout, "current public-source check passed"
264+
end
265+
end
266+
253267
def test_home_assignment_is_still_detected
254268
with_repo do |repo|
255269
home = "/" + "home/example/private.txt"

0 commit comments

Comments
 (0)