Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions cmd/edgefetch-wasm/reactor.go
Original file line number Diff line number Diff line change
Expand Up @@ -2058,6 +2058,19 @@ func dispatchWasmRPC(rawReq []byte) (any, error) {
}
return map[string]any{"url": extract.ScrubTwinURLSecrets(p.URL)}, nil

case "check_unbounded_twin_guard":
var p struct {
URL string `json:"url"`
}
if err := json.Unmarshal(env.Payload, &p); err != nil {
return nil, err
}
blocked, msg := extract.CheckUnboundedTwinEndpointGuard(p.URL)
if !blocked {
return map[string]any{"blocked": false}, nil
}
return map[string]any{"blocked": true, "message": msg}, nil

case "refine_blocked_map":
var p classify.RefineBlockedMapInput
if err := json.Unmarshal(env.Payload, &p); err != nil {
Expand Down
51 changes: 50 additions & 1 deletion hub/scripts/compile-manifests.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -385,6 +385,35 @@ export const VALID_HTML_MODES = new Set([
'endoflife_html',
'caniuse_html',
'bundle_packagephobia_html',
// Wave 3 B5 Category O1 (Bike Components & Help #341-#349)
'fox_ridefox_html',
'park_tool_html',
'ifixit_html',
'ebike_drive_systems_html',
'specialized_turbo_support_html',
'bicycle_tire_specs_html',
'wheel_hub_specs_html',
'bicycle_brake_docs_html',
'suspension_cockpit_compat_html',
// Wave 3 B5 Category O2 (Bike & E-Bike OEMs, Geometry & Compliance #350-#358)
'cargo_ebike_oems_html',
'us_ebike_oems_html',
'qbp_frame_brands_html',
'mtb_geometry_brands_html',
'geometrygeeks_99spokes_html',
'sheldon_brown_html',
'ul_product_iq_html',
'e_bike_state_laws_html',
'cpsc_ebike_incidents_html',
// Wave 3 B5 Category P (Resale & Marketplaces #359-#367)
'pinkbike_buysell_html',
'used_bikes_shopify_html',
'bicycle_blue_book_html',
'back_market_swappa_html',
'peer_resale_fashion_html',
'local_classifieds_html',
'creator_digital_stores_html',
'chairish_1stdibs_html',
]);

const pslDatPath = join(manifestsDir, 'public_suffix_list.dat');
Expand Down Expand Up @@ -588,6 +617,10 @@ const APPROVED_WILDCARD_DOMAIN_PATTERNS = new Set([
'*.narvar.com',
'*.gorgias.help',
'*.reamaze.com',
// Wave 3 B5 Category P
'*.craigslist.org',
'*.gumroad.com',
'*.lemonsqueezy.com',
]);

const RESERVED_CORE_ATS_DOMAINS = new Set([
Expand Down Expand Up @@ -638,6 +671,18 @@ function isExemptSapAtsExactClaim(wildOwnerId, wildPat, exactOwnerId, exactDom)
return wildOwnerId === 'sap-rmk-jibe' && wildPat === 'jobs.*.com' && APPROVED_SAP_ATS_EXACT_EXEMPTIONS.has(`${exactOwnerId}:${exactDom}`);
}

const APPROVED_PATH_DISJOINT_EXACT_EXEMPTIONS = Object.freeze(
new Set([
'cpsc-ebike-incidents|cpsc-recalls:saferproducts.gov',
'cpsc-ebike-incidents|cpsc-recalls:www.saferproducts.gov',
]),
);

function isExemptPathDisjointExactClaim(ownerA, ownerB, exactDom) {
const pair = [ownerA, ownerB].sort().join('|');
return APPROVED_PATH_DISJOINT_EXACT_EXEMPTIONS.has(`${pair}:${exactDom}`);
}

const SCHEMA_KEYS = {
manifest: new Set([
'id', 'name', 'category', 'description', 'domains', 'universalEngine', 'exampleUrls',
Expand Down Expand Up @@ -1284,7 +1329,11 @@ export function validateManifestSet(manifestEntries) {
wildcardClaims.push({ id: obj.id, pattern: normDomain });
} else {
const prevExactOwner = exactOwners.get(normDomain);
if (prevExactOwner && prevExactOwner !== obj.id) {
if (
prevExactOwner &&
prevExactOwner !== obj.id &&
!isExemptPathDisjointExactClaim(prevExactOwner, obj.id, normDomain)
) {
throw new Error(
`${label}: duplicate domain "${normDomain}" overlaps claim by manifest "${prevExactOwner}" (M2)`,
);
Expand Down
1 change: 1 addition & 0 deletions hub/scripts/run-tests.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ const suiteSpecs = [
['test/wave3-b2-schema-community-store.test.ts', 'wave3-b2-schema-community-store.test.mjs'],
['test/wave3-b3-trade-regulators.test.ts', 'wave3-b3-trade-regulators.test.mjs'],
['test/wave3-b4-research-security-dev.test.ts', 'wave3-b4-research-security-dev.test.mjs'],
['test/wave3-b5-cycling-resale.test.ts', 'wave3-b5-cycling-resale.test.mjs'],
['test/mcp-part2-wave2e.test.ts', 'mcp-part2-wave2e.test.mjs'],
['test/wave2-security-fixes.test.ts', 'wave2-security-fixes.test.mjs'],
['test/hub-secrets-policy.test.ts', 'hub-secrets-policy.test.mjs'],
Expand Down
37 changes: 34 additions & 3 deletions hub/src/extractors/declarative.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@ export type DeclarativeCharset =
| 'leading_digits_slug'
| 'brew_id'
| 'cpsc_recall_num'
| 'hex';
| 'hex'
| 'cpsc_query_term';

export type DeclarativeParamTransform =
| 'lower'
Expand Down Expand Up @@ -654,7 +655,11 @@ export type DeclarativeJsonMode =
| 'endoflife_json'
| 'web_compat_json'
| 'bundlephobia_json'
| 'packagephobia_json';
| 'packagephobia_json'
| 'ifixit_json'
| 'cpsc_ebike_incidents_json'
| 'reverb_listing_json'
| 'reverb_search_json';

export interface DeclarativeExtractSpec {
commerceMode?: DeclarativeCommerceMode;
Expand Down Expand Up @@ -1103,7 +1108,33 @@ export type DeclarativeHtmlMode =
| 'apis_guru_html'
| 'endoflife_html'
| 'caniuse_html'
| 'bundle_packagephobia_html';
| 'bundle_packagephobia_html'
| 'fox_ridefox_html'
| 'park_tool_html'
| 'ifixit_html'
| 'ebike_drive_systems_html'
| 'specialized_turbo_support_html'
| 'bicycle_tire_specs_html'
| 'wheel_hub_specs_html'
| 'bicycle_brake_docs_html'
| 'suspension_cockpit_compat_html'
| 'cargo_ebike_oems_html'
| 'us_ebike_oems_html'
| 'qbp_frame_brands_html'
| 'mtb_geometry_brands_html'
| 'geometrygeeks_99spokes_html'
| 'sheldon_brown_html'
| 'ul_product_iq_html'
| 'e_bike_state_laws_html'
| 'cpsc_ebike_incidents_html'
| 'pinkbike_buysell_html'
| 'used_bikes_shopify_html'
| 'bicycle_blue_book_html'
| 'back_market_swappa_html'
| 'peer_resale_fashion_html'
| 'local_classifieds_html'
| 'creator_digital_stores_html'
| 'chairish_1stdibs_html';

export interface DeclarativeHtmlRouteSpec {
id?: string;
Expand Down
83 changes: 23 additions & 60 deletions hub/src/extractors/twin-companions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ export type FetchBoundedTwinFn = (params: {
const ZENDESK_ARTICLE_TWIN_RE = /^https:\/\/([^/]+)\/api\/v2\/help_center\/([a-z0-9-]+)\/articles\/(\d+)\.json(?:\?|$)/i;
const DOCKER_HUB_REPO_TWIN_RE = /^https:\/\/hub\.docker\.com\/v2\/repositories\/([^/]+)\/([^/]+)\/?$/i;
const GOVINFO_DETAILS_PATH_RE = /^\/app\/details\/([A-Za-z0-9_.-]{4,120})(?:\/([A-Za-z0-9_.-]{4,160}))?\/?$/;
const SAFERPRODUCTS_RECALL_PATH_RE = /^\/restwebservices\/recall(?:\/.*)?$/i;
const CPSC_RECALL_NUM_RE = /Recall\s*(?:Number|No\.?|#)\s*:?\s*(?:<[^>]{0,60}>|\s|\*|`)*([0-9]{2}-?[0-9]{2,5})/i;

const ZENDESK_ATTACHMENTS_EXTRACT_SPEC: DeclarativeExtractSpec = {
Expand Down Expand Up @@ -69,72 +68,36 @@ function stripLeadingMarkdownHeading(md: string): string {

/**
* Pre-fetch guard blocking unfiltered `saferproducts.gov/RestWebServices/Recall` dumps (> 25 MiB)
* that lack a valid bounded `RecallNumber` query parameter.
* that lack a valid bounded `RecallNumber`, `ProductType`, or `ProductDescription` query parameter.
*/
export function checkUnboundedTwinEndpointGuard(
parsedUrl: URL,
normalizedUrl: string,
): { status: number; via: string; body: Record<string, unknown> } | null {
const hostLower = parsedUrl.hostname.toLowerCase().replace(/\.+$/, '');
if (hostLower === 'www.saferproducts.gov' || hostLower === 'saferproducts.gov') {
let decodedPath = parsedUrl.pathname;
try {
for (let pass = 0; pass < 2; pass++) {
const next = decodeURIComponent(decodedPath);
if (next === decodedPath) break;
decodedPath = next;
}
} catch {
return {
status: 422,
via: 'hub',
body: {
ok: false,
success: false,
url: normalizedUrl,
finalUrl: normalizedUrl,
outcome: 'skip',
code: 'UNBOUNDED_ENDPOINT_BLOCKED',
error: 'unbounded_endpoint_blocked',
message:
'Malformed percent-encoding on saferproducts.gov endpoint.',
},
};
}
const normPath = decodedPath.replace(/[\\/]+/g, '/').toLowerCase();
if (SAFERPRODUCTS_RECALL_PATH_RE.test(normPath)) {
const recallMatches: string[] = [];
for (const [k, v] of parsedUrl.searchParams.entries()) {
if (k.toLowerCase() === 'recallnumber') {
recallMatches.push(v.trim());
}
}
const rawRecallNum = recallMatches.length === 1 ? recallMatches[0]! : '';
const strippedRecallNum = rawRecallNum.replace(/-/g, '');
if (
recallMatches.length !== 1 ||
!/^[A-Za-z0-9-]{2,24}$/.test(rawRecallNum) ||
!/^[A-Za-z0-9]{2,24}$/.test(strippedRecallNum)
) {
return {
status: 422,
via: 'hub',
body: {
ok: false,
success: false,
url: normalizedUrl,
finalUrl: normalizedUrl,
outcome: 'skip',
code: 'UNBOUNDED_ENDPOINT_BLOCKED',
error: 'unbounded_endpoint_blocked',
message:
'Unfiltered saferproducts.gov/RestWebServices/Recall endpoint exceeds 25 MiB and requires a bounded RecallNumber query parameter (e.g., ?RecallNumber=24123).',
},
};
}
}
if (hostLower !== 'www.saferproducts.gov' && hostLower !== 'saferproducts.gov') {
return null;
}
return null;
const guard = callCoreWasm<{ blocked: boolean; message?: string }>('check_unbounded_twin_guard', {
url: parsedUrl.toString(),
});
if (!guard.blocked) return null;
return {
status: 422,
via: 'hub',
body: {
ok: false,
success: false,
url: normalizedUrl,
finalUrl: normalizedUrl,
outcome: 'skip',
code: 'UNBOUNDED_ENDPOINT_BLOCKED',
error: 'unbounded_endpoint_blocked',
message:
guard.message ||
'Unfiltered saferproducts.gov/RestWebServices/Recall endpoint exceeds 25 MiB and requires a bounded RecallNumber, ProductType, or ProductDescription query parameter (e.g., ?RecallNumber=24123).',
},
};
}

/**
Expand Down
42 changes: 42 additions & 0 deletions hub/test/fixtures/adapters/back-market-swappa.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
{
"adapterId": "back-market-swappa",
"mode": "html",
"inputUrl": "https://swappa.com/buy/apple-iphone-14",
"mockPayload": "<!doctype html><html><head><title>Apple iPhone 14 Used &amp; Refurbished | Swappa</title><script type=\"application/ld+json\">{\"@context\":\"https://schema.org\",\"@type\":\"Product\",\"name\":\"Apple iPhone 14 (Unlocked)\",\"brand\":{\"@type\":\"Brand\",\"name\":\"Apple\"},\"sku\":\"SWP-IP14-128\",\"description\":\"Refurbished unlocked Apple iPhone 14 tested and verified.\",\"aggregateRating\":{\"@type\":\"AggregateRating\",\"ratingValue\":\"4.8\",\"reviewCount\":\"312\"},\"offers\":{\"@type\":\"AggregateOffer\",\"lowPrice\":\"349\",\"highPrice\":\"499\",\"priceCurrency\":\"USD\",\"offerCount\":\"42\"}}</script></head><body><main><h1>Apple iPhone 14 (Unlocked)</h1><table><tr><td>Storage</td><td>128 GB</td></tr><tr><td>Display</td><td>6.1-inch Super Retina XDR</td></tr></table></main></body></html>",
"expectTitleIncludes": "Apple iPhone 14",
"expectMarkdownIncludes": [
"Apple",
"349.00 - 499.00 USD",
"42",
"128 GB"
],
"negativeCases": [
{
"name": "http-404",
"status": 404,
"payload": "<html><head><title>404 Page Not Found</title></head><body><h1>Product Not Found</h1></body></html>"
},
{
"name": "redirect-to-error",
"status": 200,
"finalUrl": "https://swappa.com/error",
"payload": "<html><head><title>Error</title></head><body><h1>Error</h1></body></html>"
},
{
"name": "maintenance",
"status": 503,
"payload": "<html><head><title>Scheduled Maintenance</title></head><body><h1>Temporarily Unavailable</h1></body></html>"
},
{
"name": "backmarket-bot-need-challenge",
"status": 403,
"inputUrl": "https://www.backmarket.com/en-us/p/iphone-13-512gb-red-locked-verizon/f600a6e0-4627-4b38-b17d-efa60fed7568",
"payload": "{\"errors\":[{\"code\":\"bot-need-challenge\",\"message\":\"Forbidden\",\"challengePath\":\"/testchallengepage\"}]}"
},
{
"name": "cloudflare-just-a-moment",
"status": 403,
"payload": "<!doctype html><html><head><title>Just a moment...</title></head><body><div id=\"challenge-platform\">Checking your browser...</div></body></html>"
}
]
}
36 changes: 36 additions & 0 deletions hub/test/fixtures/adapters/bicycle-blue-book.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
{
"adapterId": "bicycle-blue-book",
"mode": "html",
"inputUrl": "https://www.bicyclebluebook.com/value-guide/cyclocross/all-city/macho-king-ltd/2017",
"mockPayload": "<!doctype html><html><head><title>2017 All-City Macho King LTD - Bicycle Blue Book</title><meta name=\"description\" content=\"Valuation and specifications for the 2017 All-City Macho King LTD cyclocross bike.\"><script type=\"application/ld+json\">{\"@context\":\"https://schema.org\",\"@type\":\"WebPage\",\"name\":\"2017 All-City Macho King LTD\"}</script></head><body><main><h1>2017 All-City Macho King LTD</h1><section><div>Original MSRP $3,399</div><div>Previous used estimate $1,084 - $1,115</div><div>Trade-in Value $680</div><div>12-month projected trend 8 %</div></section></main></body></html>",
"expectTitleIncludes": "2017 All-City Macho King LTD",
"expectMarkdownIncludes": [
"$3399",
"$1084 - $1115",
"$680",
"8%"
],
"negativeCases": [
{
"name": "http-404",
"status": 404,
"payload": "<html><head><title>404 Page Not Found</title></head><body><h1>Not Found</h1></body></html>"
},
{
"name": "redirect-to-error",
"status": 200,
"finalUrl": "https://www.bicyclebluebook.com/error",
"payload": "<html><head><title>Error</title></head><body><h1>Something went wrong</h1></body></html>"
},
{
"name": "maintenance",
"status": 503,
"payload": "<html><head><title>Scheduled Maintenance</title></head><body><h1>Temporarily Unavailable</h1></body></html>"
},
{
"name": "empty-spa-shell",
"status": 200,
"payload": "<!doctype html><html><head><title>Bicycle Blue Book</title></head><body><div id=\"__next\"></div></body></html>"
}
]
}
37 changes: 37 additions & 0 deletions hub/test/fixtures/adapters/bicycle-brake-docs.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
{
"adapterId": "bicycle-brake-docs",
"mode": "html",
"inputUrl": "https://magura.com/product/mt7-pro/",
"mockPayload": "<!doctype html><html><head><title>MAGURA MT7 PRO disc brake</title><meta name=\"description\" content=\"4-piston hydraulic disc brake using Magura Royal Blood mineral oil and 2.0mm Storm HC rotors.\"><script type=\"application/ld+json\">{\"@context\":\"https://schema.org\",\"@type\":\"Product\",\"name\":\"MAGURA MT7 PRO\",\"sku\":\"2701944\",\"brand\":{\"@type\":\"Brand\",\"name\":\"Magura\"},\"offers\":{\"@type\":\"Offer\",\"price\":\"249.00\",\"priceCurrency\":\"EUR\",\"availability\":\"https://schema.org/InStock\"}}</script></head><body><main><h1>MAGURA MT7 PRO</h1><p>4-piston Post Mount hydraulic caliper engineered for Royal Blood Mineral Oil, 180 mm / 203 mm / 220 mm Storm HC and MDR-P rotors (2.0 mm thickness).</p><table><thead><tr><th>Parameter</th><th>Specification</th></tr></thead><tbody><tr><td>Pistons</td><td>4-piston</td></tr><tr><td>Brake Fluid</td><td>Royal Blood Mineral Oil</td></tr><tr><td>Recommended Rotors</td><td>180 mm, 203 mm, 220 mm (2.0 mm)</td></tr><tr><td>Pad Type</td><td>8.P / 8.R / 9.P</td></tr></tbody></table><a href=\"https://magura.com/media/manuals/mt7-bleed-manual.pdf\">MAGURA MT7 Service & Bleed Manual PDF</a></main></body></html>",
"expectTitleIncludes": "MAGURA MT7 PRO",
"expectMarkdownIncludes": [
"4-piston",
"Mineral Oil",
"203",
"2.0",
"Bleed Manual PDF"
],
"negativeCases": [
{
"name": "http-404",
"status": 404,
"payload": "<!doctype html><html><head><title>404 Page Not Found</title></head><body><h1>404 Not Found</h1></body></html>"
},
{
"name": "redirect-to-error",
"status": 200,
"finalUrl": "https://magura.com/error",
"payload": "<!doctype html><html><head><title>Error</title></head><body><h1>Server Error</h1></body></html>"
},
{
"name": "maintenance",
"status": 200,
"payload": "<!doctype html><html><head><title>Scheduled Maintenance</title></head><body><p>This site is temporarily unavailable due to scheduled maintenance. Please check back shortly.</p></body></html>"
},
{
"name": "empty-spa-shell",
"status": 200,
"payload": "<!doctype html><html><head><title>Loading...</title></head><body><div id=\"app\"></div></body></html>"
}
]
}
Loading
Loading