]> git.ipfire.org Git - thirdparty/elfutils.git/commitdiff
debuginfod: filter webapi for bad keywords early
authorFrank Ch. Eigler <fche@redhat.com>
Thu, 25 Feb 2021 19:04:20 +0000 (14:04 -0500)
committerFrank Ch. Eigler <fche@redhat.com>
Thu, 25 Feb 2021 19:07:51 +0000 (14:07 -0500)
Prevent some unnecessary processing of user data and
keep invalid request types out of metrics.

Signed-off-by: Frank Ch. Eigler <fche@redhat.com>
debuginfod/ChangeLog
debuginfod/debuginfod.cxx
tests/ChangeLog
tests/run-debuginfod-find.sh

index a66ded383a9f8b047ad9778173ea41c43b214093..98089b2d97bc3282aed74da722893f8a27341d5a 100644 (file)
@@ -1,3 +1,8 @@
+2021-02-25  Frank Ch. Eigler <fche@redhat.com>
+
+       * debuginfod.cxx (handler_cb): Filter webapi for bad
+       artifacttype keywords early for metric hygiene.
+
 2021-02-14  Frank Ch. Eigler <fche@redhat.com>
 
        * debuginfod.cxx (main -U): Use bsdtar unconditionally.  Also map
index 6fdaf60e6632e53504eefc6a5e5630d2fe18da9d..2aecc04940622b86a3ac286cd1921f046171fcf5 100644 (file)
@@ -1587,6 +1587,8 @@ handle_buildid (MHD_Connection* conn,
   else if (artifacttype == "source") atype_code = "S";
   else throw reportable_exception("invalid artifacttype");
 
+  inc_metric("http_requests_total", "type", artifacttype);
+  
   if (atype_code == "S" && suffix == "")
      throw reportable_exception("invalid source suffix");
 
@@ -1936,7 +1938,6 @@ handler_cb (void * /*cls*/,
               suffix = url_copy.substr(slash3); // include the slash in the suffix
             }
 
-          inc_metric("http_requests_total", "type", artifacttype);
           // get the resulting fd so we can report its size
           int fd;
           r = handle_buildid(connection, buildid, artifacttype, suffix, &fd);
index 889f5066d537aee9c7f207db6f39b42cf0ebf3b8..9444712889a6d1b74df2dfeda2fe72fa5afca748 100644 (file)
@@ -1,3 +1,7 @@
+2021-02-25  Frank Ch. Eigler <fche@redhat.com>
+
+       * run-debuginfod-find.sh: Add bad webapi artifacttype test.
+
 2021-02-17  Frank Ch. Eigler <fche@redhat.com>
 
        * run-debuginfod-find.sh: Tweak wait_ready() to also print -vvv log of
index 1ae63e0ee79afd4f1f6ddbbe8938c422ecf0d3e1..bcca61301b2bbba1d750a820b37a4f94a7a032c6 100755 (executable)
@@ -493,6 +493,9 @@ curl -s http://127.0.0.1:$PORT1/metrics | grep 'scanned_bytes_total'
 curl -s http://127.0.0.1:$PORT2/badapi > /dev/null || true
 curl -s http://127.0.0.1:$PORT2/buildid/deadbeef/debuginfo > /dev/null || true
 
+# Confirm bad artifact types are rejected without leaving trace
+curl -s http://127.0.0.1:$PORT2/buildid/deadbeef/badtype > /dev/null || true
+(curl -s http://127.0.0.1:$PORT2/metrics | grep 'badtype') && false
 
 ########################################################################
 # Corrupt the sqlite database and get debuginfod to trip across its errors