Skip to content

Commit 70164b3

Browse files
committed
Skip log lines for s3 bucket listings
The regex for log file parsing was too permissive, so would see bucket listing requests to s3 as downloads. Fixes #867.
1 parent d3cadf9 commit 70164b3

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

src/clojars/tools/process_stats.clj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@
5858
#".*")))
5959

6060
(def re-path
61-
(let [segment #"[^/]+"
61+
(let [segment #"[^/?]+"
6262
sep #"/+"]
6363
(re/regex (re/? sep "repo") sep
6464
[(re/* segment sep) segment :as :group] sep

test/clojars/unit/tools/process_stats_test.clj

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,14 @@
3434
(is (= "0.1.0" (:version m)))
3535
(is (= "jar" (:ext m))))))
3636

37+
(def skipped-lines
38+
["<134>2023-06-04T23:04:45Z cache-bos4631 s3-bucket[170864]: 71.184.230.157 \"GET /?prefix=downloads-&marker=downloads-20230514.edn HTTP/1.1\" 200 4682 (null) Java/17.0.5"
39+
"<134>2023-06-04T23:04:45Z cache-bos4631 s3-bucket[170864]: 71.184.230.157 \"GET /?prefix=/com/foo/bar/1.0/bar.jar HTTP/1.1\" 200 4682 (null) Java/17.0.5"])
40+
41+
(deftest parse-line-does-not-parse-paths-for-lines-we-do-not-want-stats-for
42+
(doseq [line skipped-lines]
43+
(is (nil? (:group (stats/parse-line line))))))
44+
3745
(deftest compute-stats
3846
(let [stats (stats/process-log (io/resource "fake.access.log"))]
3947
(is (= 2 (get-in stats [["snowy" "snowy"] "0.3.0"])))

0 commit comments

Comments
 (0)