Add Lua plugin host, built-in amazon plugin and dibs check.
Sandboxed gopher-lua with time, memory and call-stack limits from [sandbox], a goquery-backed doc API, price parsing, and the 'check', 'plugin test' and 'fixtures' commands. Sellers are first_party, fulfilled (shipped by the shop) or third_party, and items accept fulfilled by default; used-only offers are not available. Plugin tests run on real pages that 'dibs fixtures' fetches into an untracked directory. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
f90ef18f90
commit
bb010356a0
28 files changed
+2096
-26
No files matched your search
Vendored
+36
@@ -0,0 +1,36 @@
|
||||
# Real Amazon pages the amazon plugin is tested on. `dibs fixtures` fetches
|
||||
# them into pages/ (not tracked), together with the report dibs made for
|
||||
# each. Pages change: when a case stops showing what its note says, pick
|
||||
# another product.
|
||||
#
|
||||
# Still wanted: a page sold by Amazon itself, and a preorder.
|
||||
|
||||
[[case]]
|
||||
name = "out-of-stock-de"
|
||||
url = "https://www.amazon.de/dp/B0HMX2FSTF"
|
||||
note = "Metro 2039 CE (Xbox), currently unavailable, no offer at all"
|
||||
|
||||
[[case]]
|
||||
name = "out-of-stock-uk"
|
||||
url = "https://www.amazon.co.uk/dp/B0HM497GJJ"
|
||||
note = "Metro 2039 CE (PC), currently unavailable, prices in GBP"
|
||||
|
||||
[[case]]
|
||||
name = "fulfilled-de"
|
||||
url = "https://www.amazon.de/dp/B0DK51S84Z"
|
||||
note = "Silkland cable, sold by Silkland-DE, shipped by Amazon"
|
||||
|
||||
[[case]]
|
||||
name = "fulfilled-de-2"
|
||||
url = "https://www.amazon.de/dp/B076WS2WJ6"
|
||||
note = "UGREEN enclosure, sold by a marketplace seller, shipped by Amazon"
|
||||
|
||||
[[case]]
|
||||
name = "used-only-de"
|
||||
url = "https://www.amazon.de/dp/B0948LPGNG"
|
||||
note = "Metro Exodus Complete (PS5), only a used copy in the buybox: not available"
|
||||
|
||||
[[case]]
|
||||
name = "not-found-de"
|
||||
url = "https://www.amazon.de/dp/B0NOTREAL1"
|
||||
note = "no such product: Amazon's 404 dog page"
|
||||
Vendored
+20
@@ -0,0 +1,20 @@
|
||||
# How the amazon plugin's normalize() rewrites product URLs. Anything that is
|
||||
# not an Amazon product URL on a supported TLD stays as it is.
|
||||
|
||||
normalize = [
|
||||
{ in = "https://www.amazon.de/dp/B0HMX2FSTF", out = "https://www.amazon.de/dp/B0HMX2FSTF" },
|
||||
{ in = "https://www.amazon.de/dp/B0HMX2FSTF?th=1", out = "https://www.amazon.de/dp/B0HMX2FSTF" },
|
||||
{ in = "https://www.amazon.de/dp/B0HMX2FSTF/ref=sr_1_1?th=1&psc=1", out = "https://www.amazon.de/dp/B0HMX2FSTF" },
|
||||
{ in = "https://www.amazon.de/Metro-2039-Collectors-Edition/dp/B0HMX2FSTF", out = "https://www.amazon.de/dp/B0HMX2FSTF" },
|
||||
{ in = "https://www.amazon.co.uk/gp/product/B0HM497GJJ", out = "https://www.amazon.co.uk/dp/B0HM497GJJ" },
|
||||
{ in = "https://www.amazon.co.uk/gp/product/B0HM497GJJ/ref=ppx_yo_dt_b_asin", out = "https://www.amazon.co.uk/dp/B0HM497GJJ" },
|
||||
{ in = "https://www.amazon.fr/gp/aw/d/B0HMX2FSTF", out = "https://www.amazon.fr/dp/B0HMX2FSTF" },
|
||||
{ in = "https://amazon.it/dp/b0hmx2fstf", out = "https://www.amazon.it/dp/B0HMX2FSTF" },
|
||||
{ in = "HTTPS://WWW.AMAZON.ES/dp/B0HMX2FSTF#reviews", out = "https://www.amazon.es/dp/B0HMX2FSTF" },
|
||||
{ in = "https://www.amazon.nl/dp/B0HMX2FSTF", out = "https://www.amazon.nl/dp/B0HMX2FSTF" },
|
||||
{ in = "https://www.amazon.com/exec/obidos/ASIN/B0HMX2FSTF", out = "https://www.amazon.com/dp/B0HMX2FSTF" },
|
||||
{ in = "https://www.amazon.co.jp/dp/B0HMX2FSTF", out = "https://www.amazon.co.jp/dp/B0HMX2FSTF" },
|
||||
{ in = "https://www.amazon.de/s?k=metro", out = "https://www.amazon.de/s?k=metro" },
|
||||
{ in = "https://www.amazon.de/dp/B0HMX2FSTFX", out = "https://www.amazon.de/dp/B0HMX2FSTFX" },
|
||||
{ in = "https://www.notamazon.de/dp/B0HMX2FSTF", out = "https://www.notamazon.de/dp/B0HMX2FSTF" },
|
||||
]
|
||||
Vendored
+8
@@ -0,0 +1,8 @@
|
||||
-- Recurses until the call stack limit is hit.
|
||||
local function deep(n) return deep(n + 1) + 1 end
|
||||
|
||||
return { parse = function()
|
||||
deep(0)
|
||||
|
||||
return { available = true }
|
||||
end }
|
||||
Vendored
+9
@@ -0,0 +1,9 @@
|
||||
-- Nothing that reads files, loads code or reaches the interpreter's
|
||||
-- internals may be visible to a plugin.
|
||||
local leaked = {}
|
||||
for _, name in ipairs({ "os", "io", "debug", "package", "coroutine", "dofile", "loadfile", "load",
|
||||
"loadstring", "require", "module", "collectgarbage", "getfenv", "setfenv", "newproxy", "_printregs" }) do
|
||||
if _G[name] ~= nil then leaked[#leaked + 1] = name end
|
||||
end
|
||||
|
||||
return { parse = function() return { available = #leaked == 0, title = table.concat(leaked, ",") } end }
|
||||
Vendored
+7
@@ -0,0 +1,7 @@
|
||||
-- Grows a table until the memory watchdog stops it.
|
||||
return { parse = function()
|
||||
local t = {}
|
||||
for i = 1, 1e8 do t[i] = "value " .. i end
|
||||
|
||||
return { available = true }
|
||||
end }
|
||||
Vendored
+6
@@ -0,0 +1,6 @@
|
||||
-- string.rep would allocate 10 GB at once, faster than the watchdog reacts.
|
||||
return { parse = function()
|
||||
local s = string.rep("x", 1e10)
|
||||
|
||||
return { available = true }
|
||||
end }
|
||||
Vendored
+8
@@ -0,0 +1,8 @@
|
||||
-- Loops forever on "loop" and "pcall"; pcall must not be able to swallow the
|
||||
-- timeout. Any other URL returns normally.
|
||||
return { parse = function(doc, url)
|
||||
if url == "loop" then while true do end end
|
||||
if url == "pcall" then while true do pcall(function() while true do end end) end end
|
||||
|
||||
return { available = true }
|
||||
end }
|
||||
Reference in new issue
Block a user