aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authoronefang2019-12-02 22:22:16 +1000
committeronefang2019-12-02 22:22:16 +1000
commit36a706c4ae8e46f88c1f7193b2686df8509a080a (patch)
tree1c47f596ebb68d70ad1ace6b3f2821afbd04976b
parentMake it match test_rewrite.sh more. (diff)
downloadapt-panopticon-36a706c4ae8e46f88c1f7193b2686df8509a080a.zip
apt-panopticon-36a706c4ae8e46f88c1f7193b2686df8509a080a.tar.gz
apt-panopticon-36a706c4ae8e46f88c1f7193b2686df8509a080a.tar.bz2
apt-panopticon-36a706c4ae8e46f88c1f7193b2686df8509a080a.tar.xz
Implement URLSanity test.
-rwxr-xr-xapt-panopticon-report-email-web.lua4
-rwxr-xr-xapt-panopticon.lua38
2 files changed, 32 insertions, 10 deletions
diff --git a/apt-panopticon-report-email-web.lua b/apt-panopticon-report-email-web.lua
index 60027d0..fc1f345 100755
--- a/apt-panopticon-report-email-web.lua
+++ b/apt-panopticon-report-email-web.lua
@@ -326,7 +326,7 @@ if nil == email then C("opening mirrors file - " .. e) else
326 local rsync = "[skip]" 326 local rsync = "[skip]"
327 local dns = "" 327 local dns = ""
328 local protocol = status(k, results, "Protocol") 328 local protocol = status(k, results, "Protocol")
329 local sanity = "[skip]" 329 local sanity = status(k, results, "URLSanity")
330 local integrity = status(k, results, "Integrity") 330 local integrity = status(k, results, "Integrity")
331 local updated = status(k, results, "Updated") 331 local updated = status(k, results, "Updated")
332 332
@@ -434,7 +434,7 @@ if nil == web then C("opening mirrors file - " .. e) else
434 local rsync = "[<font color='grey'><b>skip</b></font>]" 434 local rsync = "[<font color='grey'><b>skip</b></font>]"
435 local dns = "" 435 local dns = ""
436 local protocol = status(k, results, "Protocol") 436 local protocol = status(k, results, "Protocol")
437 local sanity = "[<font color='grey'><b>skip</b></font>]" 437 local sanity = status(k, results, "URLSanity")
438 local integrity = status(k, results, "Integrity") 438 local integrity = status(k, results, "Integrity")
439 local updated = status(k, results, "Updated") 439 local updated = status(k, results, "Updated")
440 local rate = v.Rate 440 local rate = v.Rate
diff --git a/apt-panopticon.lua b/apt-panopticon.lua
index ade9de3..21e7599 100755
--- a/apt-panopticon.lua
+++ b/apt-panopticon.lua
@@ -43,7 +43,7 @@ options =
43-- "rsync", 43-- "rsync",
44 "DNSRR", 44 "DNSRR",
45 "Protocol", 45 "Protocol",
46-- "URLSanity", 46 "URLSanity",
47 "Integrity", 47 "Integrity",
48 "Updated", 48 "Updated",
49 }, 49 },
@@ -404,9 +404,10 @@ end
404 404
405local timeouts = 0; 405local timeouts = 0;
406local totalTimeouts = 0 406local totalTimeouts = 0
407checkHEAD = function (host, URL, r, retry) 407checkHEAD = function (host, URL, r, retry, sanity)
408 if nil == r then r = 0 end 408 if nil == r then r = 0 end
409 if nil == retry then retry = 0 end 409 if nil == retry then retry = 0 end
410 if nil == sanity then sanity = false end
410 local check = "Checking file" 411 local check = "Checking file"
411 local PU = url.parse(URL, defaultURL) 412 local PU = url.parse(URL, defaultURL)
412 local pu = url.parse(PU.scheme .. "://" .. host, defaultURL) 413 local pu = url.parse(PU.scheme .. "://" .. host, defaultURL)
@@ -469,12 +470,20 @@ checkHEAD = function (host, URL, r, retry)
469 if "0" ~= status then 470 if "0" ~= status then
470 local msg = curlStatus[0 + status] 471 local msg = curlStatus[0 + status]
471 if nil == msg then msg = "UNKNOWN CURL STATUS CODE!" end 472 if nil == msg then msg = "UNKNOWN CURL STATUS CODE!" end
472 E(" The curl command return an error code of " .. status .. " - " .. msg, PU.scheme, "", host) 473 if sanity then
474 E(" The curl command return an error code of " .. status .. " - " .. msg, PU.scheme, "URLSanity", host)
475 else
476 E(" The curl command return an error code of " .. status .. " - " .. msg, PU.scheme, "", host)
477 end
473 if ("28" == status) or ("7" == status) then 478 if ("28" == status) or ("7" == status) then
474 E(" TIMEOUT " .. timeouts + 1 .. ", retry " .. retry + 1, PU.scheme, "", host) 479 if sanity then
480 E(" TIMEOUT " .. timeouts + 1 .. ", retry " .. retry + 1, PU.scheme, "URLSanity", host)
481 else
482 E(" TIMEOUT " .. timeouts + 1 .. ", retry " .. retry + 1, PU.scheme, "", host)
483 end
475 timeouts = timeouts + 1 484 timeouts = timeouts + 1
476 end 485 end
477 checkHEAD(host, URL, r, retry + 1, timeouts) 486 checkHEAD(host, URL, r, retry + 1, sanity)
478 return 487 return
479 end 488 end
480 local rfile, e = io.open("results/STATUS_" .. fname, "r") 489 local rfile, e = io.open("results/STATUS_" .. fname, "r")
@@ -496,7 +505,11 @@ checkHEAD = function (host, URL, r, retry)
496 end 505 end
497 os.execute('rm results/"STATUS_' .. fname .. '" 2>/dev/null') 506 os.execute('rm results/"STATUS_' .. fname .. '" 2>/dev/null')
498 if ("4" == tostring(code):sub(1, 1)) or ("5" == tostring(code):sub(1, 1)) then 507 if ("4" == tostring(code):sub(1, 1)) or ("5" == tostring(code):sub(1, 1)) then
499 E(" " .. code .. " " .. cstr .. ". " .. check .. " " .. host .. " -> " .. URL, PU.scheme, "", host) 508 if sanity then
509 E(" " .. code .. " " .. cstr .. ". " .. check .. " " .. host .. " -> " .. URL, PU.scheme, "URLSanity", host)
510 else
511 E(" " .. code .. " " .. cstr .. ". " .. check .. " " .. host .. " -> " .. URL, PU.scheme, "", host)
512 end
500 else 513 else
501 I(" " .. code .. " " .. cstr .. ". " .. check .. " " .. host .. " -> " .. URL) 514 I(" " .. code .. " " .. cstr .. ". " .. check .. " " .. host .. " -> " .. URL)
502-- timeouts = timeouts - 1 -- Backoff the timeouts count if we managed to get through. 515-- timeouts = timeouts - 1 -- Backoff the timeouts count if we managed to get through.
@@ -511,9 +524,9 @@ checkHEAD = function (host, URL, r, retry)
511 E(" redirect loop! " .. check .. " " .. host .. " -> " .. URL, PU.scheme, "", host) 524 E(" redirect loop! " .. check .. " " .. host .. " -> " .. URL, PU.scheme, "", host)
512 elseif nil == pu.host then 525 elseif nil == pu.host then
513 I(" relative redirect. " .. check .. " " .. host .. " -> " .. URL .. " -> " .. location) 526 I(" relative redirect. " .. check .. " " .. host .. " -> " .. URL .. " -> " .. location)
514 checkHEAD(host, PU.scheme .. "://" .. PU.host .. location, r + 1) 527 checkHEAD(host, PU.scheme .. "://" .. PU.host .. location, r + 1, retry, sanity)
515 elseif (PU.host == pu.host) or (host == pu.host) then 528 elseif (PU.host == pu.host) or (host == pu.host) then
516 checkHEAD(pu.host, location, r + 1) 529 checkHEAD(pu.host, location, r + 1, retry, sanity)
517 else 530 else
518 --[[ The hard part here is that we end up throwing ALL of the test files at the redirected location. 531 --[[ The hard part here is that we end up throwing ALL of the test files at the redirected location.
519 Not good for deb.debian.org, which we should only be throwing .debs at. 532 Not good for deb.debian.org, which we should only be throwing .debs at.
@@ -544,6 +557,15 @@ local checkTimeouts = function(host, scheme, URL)
544 return true 557 return true
545 end 558 end
546 end 559 end
560 if testing("URLSanity") then
561 URL = URL:gsub("merged/", "merged///")
562 totalTimeouts = totalTimeouts + timeouts; timeouts = 0
563 checkHEAD(host, scheme .. "://" .. URL, 0, 0, true)
564 if 4 <= (totalTimeouts) then
565 E("Way too many timeouts!", scheme, "URLSanity", host)
566 return true
567 end
568 end
547 return false 569 return false
548end 570end
549 571