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
68 changes: 36 additions & 32 deletions cmd/edgefetch-wasm/reactor.go
Original file line number Diff line number Diff line change
Expand Up @@ -1170,22 +1170,24 @@ func dispatchWasmRPC(rawReq []byte) (any, error) {
return map[string]any{"matched": false}, nil
}
out := map[string]any{
"matched": true,
"id": m.ID,
"adapterId": m.AdapterID,
"fetchUrl": m.FetchURL,
"kind": string(m.Kind),
"accept": m.Accept,
"rawAccept": m.RawAccept(),
"maxBytes": m.EffectiveMaxBytes(),
"commerceMode": m.CommerceMode(),
"requiresPageKeyOptIn": m.RequiresPageKeyOptIn,
"authMode": m.AuthMode,
"userAgentProfile": m.UserAgentProfile,
"minIntervalMs": m.MinIntervalMs,
"maxCacheTtlMs": m.MaxCacheTtlMs,
"maxConcurrent": m.MaxConcurrent,
"strictRobots": m.StrictRobots,
"matched": true,
"id": m.ID,
"adapterId": m.AdapterID,
"fetchUrl": m.FetchURL,
"kind": string(m.Kind),
"accept": m.Accept,
"rawAccept": m.RawAccept(),
"maxBytes": m.EffectiveMaxBytes(),
"commerceMode": m.CommerceMode(),
"requiresPageKeyOptIn": m.RequiresPageKeyOptIn,
"authMode": m.AuthMode,
"userAgentProfile": m.UserAgentProfile,
"minIntervalMs": m.MinIntervalMs,
"maxCacheTtlMs": m.MaxCacheTtlMs,
"maxConcurrent": m.MaxConcurrent,
"strictRobots": m.StrictRobots,
"allowCrossOriginRedirects": m.AllowCrossOriginRedirects(),
"allowTruncatedStream": m.AllowTruncatedStream(),
}
if m.FallbackFetchURL != "" {
out["fallbackFetchUrl"] = m.FallbackFetchURL
Expand Down Expand Up @@ -1341,22 +1343,24 @@ func dispatchWasmRPC(rawReq []byte) (any, error) {
return map[string]any{"matched": false}, nil
}
out := map[string]any{
"matched": true,
"id": m.ID,
"adapterId": m.AdapterID,
"fetchUrl": m.FetchURL,
"kind": string(m.Kind),
"accept": m.Accept,
"rawAccept": m.RawAccept(),
"maxBytes": m.EffectiveMaxBytes(),
"commerceMode": m.CommerceMode(),
"requiresPageKeyOptIn": m.RequiresPageKeyOptIn,
"authMode": m.AuthMode,
"userAgentProfile": m.UserAgentProfile,
"minIntervalMs": m.MinIntervalMs,
"maxCacheTtlMs": m.MaxCacheTtlMs,
"maxConcurrent": m.MaxConcurrent,
"strictRobots": m.StrictRobots,
"matched": true,
"id": m.ID,
"adapterId": m.AdapterID,
"fetchUrl": m.FetchURL,
"kind": string(m.Kind),
"accept": m.Accept,
"rawAccept": m.RawAccept(),
"maxBytes": m.EffectiveMaxBytes(),
"commerceMode": m.CommerceMode(),
"requiresPageKeyOptIn": m.RequiresPageKeyOptIn,
"authMode": m.AuthMode,
"userAgentProfile": m.UserAgentProfile,
"minIntervalMs": m.MinIntervalMs,
"maxCacheTtlMs": m.MaxCacheTtlMs,
"maxConcurrent": m.MaxConcurrent,
"strictRobots": m.StrictRobots,
"allowCrossOriginRedirects": m.AllowCrossOriginRedirects(),
"allowTruncatedStream": m.AllowTruncatedStream(),
}
if m.FallbackFetchURL != "" {
out["fallbackFetchUrl"] = m.FallbackFetchURL
Expand Down
32 changes: 32 additions & 0 deletions hub/scripts/compile-manifests.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,38 @@ export const VALID_HTML_MODES = new Set([
'branded_tracking_pack_html',
'gorgias_reamaze_html',
'klaviyo_attentive_forms_html',
// Wave 3 B3 Category J (Trade, Tariffs & Sanctions #271-#278)
'usitc_hts_html',
'cbp_cross_html',
'census_foreign_trade_html',
'ustr_301_html',
'trade_gov_csl_html',
'ofac_html',
'bis_entity_list_html',
'import_alerts_fda_aphis_html',
// Wave 3 B3 Category K1 (Regulators & Enforcement #279-#288)
'dol_enforcement_html',
'osha_establishment_html',
'nlrb_cases_html',
'eeoc_litigation_html',
'ftc_cases_html',
'fcc_ecfs_html',
'fcc_uls_html',
'ferc_nrc_dockets_html',
'financial_regulators_html',
'oversight_gov_html',
// Wave 3 B3 Category K2 (Reports, Health, Price Transparency & Tracking #289-#300)
'gao_reports_html',
'cbo_html',
'everycrs_html',
'gov_wp_newsroom_html',
'gsa_site_scanning_html',
'va_facilities_html',
'healthcare_gov_html',
'cms_price_transparency_html',
'medicaid_nadac_html',
'usps_docs_html',
'sba_dsbs_loans_html',
]);

const pslDatPath = join(manifestsDir, 'public_suffix_list.dat');
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 @@ -104,6 +104,7 @@ const suiteSpecs = [
['test/wave2d-sports-misc.test.ts', 'wave2d-sports-misc.test.mjs'],
['test/wave3-b1-gov-edu-jobs.test.ts', 'wave3-b1-gov-edu-jobs.test.mjs'],
['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/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
65 changes: 60 additions & 5 deletions hub/src/extractors/declarative.ts
Original file line number Diff line number Diff line change
Expand Up @@ -599,7 +599,23 @@ export type DeclarativeJsonMode =
| 'fediverse_pack_json'
| 'q4_ir_json'
| 'shopify_filter_apps_json'
| 'rebuy_searchanise_json';
| 'rebuy_searchanise_json'
| 'usitc_hts_json'
| 'cbp_cross_json'
| 'trade_gov_csl_json'
| 'dol_enforcement_json'
| 'fcc_ecfs_json'
| 'fcc_uls_json'
| 'everycrs_json'
| 'gov_wp_posts_json'
| 'gsa_site_scanning_json'
| 'va_facilities_json'
| 'healthcare_marketplace_json'
| 'cms_mrf_json'
| 'medicaid_nadac_json'
| 'usps_addresses_json'
| 'carrier_tracking_json'
| 'sba_dkan_json';

export interface DeclarativeExtractSpec {
commerceMode?: DeclarativeCommerceMode;
Expand Down Expand Up @@ -632,7 +648,14 @@ export interface DeclarativeExtractSpec {
| 'public_share_csv'
| 'boarddocs_text'
| 'ir_portal_rss_xml'
| 'company_newsroom_rss_xml';
| 'company_newsroom_rss_xml'
| 'ofac_sdn_xml'
| 'ustr_301_rss_xml'
| 'gao_rss_xml'
| 'cbo_rss_xml'
| 'everycrs_csv'
| 'cms_hpt_txt'
| 'cms_mrf_csv';
pathParam?: string;
codeByPath?: DeclarativeCodeByPathSpec;
xml?: DeclarativeXmlSpec;
Expand Down Expand Up @@ -968,7 +991,36 @@ export type DeclarativeHtmlMode =
| 'aftership_tracking_html'
| 'branded_tracking_pack_html'
| 'gorgias_reamaze_html'
| 'klaviyo_attentive_forms_html';
| 'klaviyo_attentive_forms_html'
| 'usitc_hts_html'
| 'cbp_cross_html'
| 'census_foreign_trade_html'
| 'ustr_301_html'
| 'trade_gov_csl_html'
| 'ofac_html'
| 'bis_entity_list_html'
| 'import_alerts_fda_aphis_html'
| 'dol_enforcement_html'
| 'osha_establishment_html'
| 'nlrb_cases_html'
| 'eeoc_litigation_html'
| 'ftc_cases_html'
| 'fcc_ecfs_html'
| 'fcc_uls_html'
| 'ferc_nrc_dockets_html'
| 'financial_regulators_html'
| 'oversight_gov_html'
| 'gao_reports_html'
| 'cbo_html'
| 'everycrs_html'
| 'gov_wp_newsroom_html'
| 'gsa_site_scanning_html'
| 'va_facilities_html'
| 'healthcare_gov_html'
| 'cms_price_transparency_html'
| 'medicaid_nadac_html'
| 'usps_docs_html'
| 'sba_dsbs_loans_html';

export interface DeclarativeHtmlRouteSpec {
id?: string;
Expand Down Expand Up @@ -1215,6 +1267,8 @@ interface ResolvedTwinWasmPayload {
maxCacheTtlMs?: number;
maxConcurrent?: number;
strictRobots?: boolean;
allowCrossOriginRedirects?: boolean;
allowTruncatedStream?: boolean;
}

function buildTwinFromResolvedWasm(
Expand All @@ -1231,8 +1285,7 @@ function buildTwinFromResolvedWasm(
...(resolved.fallbackFetchUrl ? { fallbackFetchUrl: resolved.fallbackFetchUrl } : {}),
kind: resolved.kind,
accept:
resolved.rawAccept ||
resolved.accept ||
(resolved.kind === 'text' ? resolved.accept || resolved.rawAccept : resolved.rawAccept || resolved.accept) ||
(resolved.kind === 'json' ? 'application/json' : 'text/plain'),
...(resolved.method ? { method: resolved.method } : {}),
...(resolved.requestBody ? { requestBody: resolved.requestBody } : {}),
Expand All @@ -1257,6 +1310,8 @@ function buildTwinFromResolvedWasm(
? { maxConcurrent: resolved.maxConcurrent }
: {}),
...(resolved.strictRobots ? { strictRobots: true } : {}),
...(resolved.allowCrossOriginRedirects ? { allowCrossOriginRedirects: true } : {}),
...(resolved.allowTruncatedStream ? { allowTruncatedStream: true } : {}),
formatTwin: (rawBody: string, originalUrl: string, htmlToMd: HtmlFragmentConverter) => {
if (resolved.commerceMode) {
return formatCommerceTwinDoc(
Expand Down
2 changes: 2 additions & 0 deletions hub/src/extractors/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,8 @@ export interface SiteExtractorTwin {
maxCacheTtlMs?: number;
maxConcurrent?: number;
strictRobots?: boolean;
allowCrossOriginRedirects?: boolean;
allowTruncatedStream?: boolean;
formatTwin: (rawBody: string, originalUrl: string, htmlToMd: HtmlFragmentConverter) => TwinFormattedDoc | null;
}

Expand Down
6 changes: 3 additions & 3 deletions hub/src/otel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,7 @@ export function buildOtlpTracePayload(params: {
}

const SENSITIVE_ATTR_KEY_RE =
/(?:token|secret|password|authorization|cookie|api[_.-]?key|web[_.-]?key|registration[_.-]?key|passkey|auth[_.-]?key|credential|private[_.-]?key|bearer|csrf|sealed|verifier|session[_.-]?id)/i;
/(?:token|secret|password|authorization|cookie|api[_.-]?key|web[_.-]?key|registration[_.-]?key|subscription[_.-]?key|passkey|auth[_.-]?key|credential|private[_.-]?key|bearer|csrf|sealed|verifier|session[_.-]?id)/i;
const SENSITIVE_CASE_SENSITIVE_ATTR_KEY_RE = /(?:^|[._-])UserID$/;
const URL_ATTR_KEY_RE = /^(?:url\.full|http\.url|url|target\.url|origin\.url)$/i;

Expand All @@ -408,7 +408,7 @@ function scrubFreeTextUrlsAndSecrets(raw: string): string {
.replace(/\bBasic(?:[ \t]+|[ \t]*:[ \t]*)\S+/gi, 'Basic [redacted]')
.replace(/\b(?:efc|efa|efr)_[A-Za-z0-9_-]{8,}\b/g, '[redacted]')
.replace(
/(\b[a-z0-9_.-]{0,32}(?:api[_.-]?key|web[_.-]?key|registration[_.-]?key|authorization[_.-]?key|passkey|auth[_.-]?key|access[_.-]?token|refresh[_.-]?token|client[_.-]?secret|token|secret|password|passwd|pwd|signature|sig|code)["']?[ \t]*(?:[:=]|%3[Dd])[ \t]*["']?)([^\s&"'`,;)\]}]+)/gi,
/(\b[a-z0-9_.-]{0,32}(?:api[_.-]?key|web[_.-]?key|registration[_.-]?key|authorization[_.-]?key|subscription[_.-]?key|passkey|auth[_.-]?key|access[_.-]?token|refresh[_.-]?token|client[_.-]?secret|token|secret|password|passwd|pwd|signature|sig|code)["']?[ \t]*(?:[:=]|%3[Dd])[ \t]*["']?)([^\s&"'`,;)\]}]+)/gi,
'$1[redacted]',
)
.replace(/(\bUserID["']?[ \t]*(?:[:=]|%3[Dd])[ \t]*["']?)([^\s&"'`,;)\]}]+)/g, '$1[redacted]');
Expand Down Expand Up @@ -456,7 +456,7 @@ export function sanitizeUrlForSpan(rawUrl: string): string {
.replace(/:\/\/[^/?#\s]+@/g, '://')
.replace(/[?#].*$/, '')
.replace(
/(\b[a-z0-9_.-]{0,32}(?:api[_.-]?key|web[_.-]?key|registration[_.-]?key|authorization[_.-]?key|passkey|auth[_.-]?key|access[_.-]?token|refresh[_.-]?token|client[_.-]?secret|token|secret|password|passwd|pwd|signature|sig|code)["']?[ \t]*(?:[:=]|%3[Dd])[ \t]*["']?)([^\s&"'`,;)\]}]+)/gi,
/(\b[a-z0-9_.-]{0,32}(?:api[_.-]?key|web[_.-]?key|registration[_.-]?key|authorization[_.-]?key|subscription[_.-]?key|passkey|auth[_.-]?key|access[_.-]?token|refresh[_.-]?token|client[_.-]?secret|token|secret|password|passwd|pwd|signature|sig|code)["']?[ \t]*(?:[:=]|%3[Dd])[ \t]*["']?)([^\s&"'`,;)\]}]+)/gi,
'$1[redacted]',
)
.replace(/(\bUserID["']?[ \t]*(?:[:=]|%3[Dd])[ \t]*["']?)([^\s&"'`,;)\]}]+)/g, '$1[redacted]')
Expand Down
1 change: 1 addition & 0 deletions hub/src/search-index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2547,6 +2547,7 @@ export async function executeExtractCall(params: {
finalUrl: item.url,
status: typeof r.status === 'number' ? r.status : 200,
cached: false,
extractorId: twinSpec.id,
contentState: 'soft_404',
markdown: '',
fetchCompletedAt: itemFetchCompletedAt,
Expand Down
35 changes: 35 additions & 0 deletions hub/test/fixtures/adapters/bis-entity-list.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{
"adapterId": "bis-entity-list",
"mode": "html",
"inputUrl": "https://www.bis.gov/regulations/ear/744",
"mockPayload": "<!doctype html><html lang=\"en\"><head><meta charset=\"utf-8\"><title>EAR Part 744 | Bureau of Industry and Security</title><meta name=\"description\" content=\"Export Administration Regulations Part 744 End-User and End-Use Controls including the Entity List (Supplement No. 4).\"><link rel=\"canonical\" href=\"https://www.bis.gov/regulations/ear/744\"></head><body><main><h1>Export Administration Regulations Part 744 (End-User &amp; Entity List)</h1><p>Part 744 of the Export Administration Regulations establishes end-use and end-user based controls, including the BIS Entity List in Supplement No. 4 to Part 744.</p><a href=\"https://www.bis.gov/regulations/ear/774\">Commerce Control List (Part 774)</a></main></body></html>",
"expectTitleIncludes": "Export Administration Regulations Part 744",
"expectMarkdownIncludes": [
"Part 744",
"Entity List",
"Supplement No. 4"
],
"negativeCases": [
{
"name": "http-404",
"status": 404,
"payload": "<!doctype html><html lang=\"en\"><head><title>Page not found | Bureau of Industry and Security</title><meta property=\"og:url\" content=\"https://media.bis.gov//404\"></head><body><h1>Page not found</h1></body></html>"
},
{
"name": "redirect-to-error",
"status": 200,
"finalUrl": "https://www.bis.gov/error",
"payload": "<!doctype html><html><head><title>404 Page Not Found</title></head><body><h1>Not Found</h1></body></html>"
},
{
"name": "maintenance",
"status": 200,
"payload": "<!doctype html><html><head><title>Scheduled Maintenance</title></head><body><p>BIS portal is down for scheduled maintenance. Please check back shortly.</p></body></html>"
},
{
"name": "empty-nextjs-shell",
"status": 200,
"payload": "<!doctype html><html><head><title>Loading...</title></head><body><div id=\"__next\"></div><noscript>JavaScript required.</noscript></body></html>"
}
]
}
36 changes: 36 additions & 0 deletions hub/test/fixtures/adapters/carrier-tracking-official.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
{
"adapterId": "carrier-tracking-official",
"mode": "twin",
"inputUrl": "https://apis.usps.com/tracking/v3/tracking/9400111899223344556677",
"expectedFetchUrl": "https://apis.usps.com/tracking/v3/tracking/9400111899223344556677",
"mockPayload": "{\"trackingNumber\":\"9400111899223344556677\",\"statusCategory\":\"Delivered\",\"status\":\"Delivered, In/At Mailbox\",\"statusSummary\":\"Your item was delivered in or at the mailbox at 1:14 pm on November 26, 2026 in WASHINGTON, DC 20260.\",\"mailClass\":\"USPS Ground Advantage\",\"expectedDeliveryDate\":\"2026-11-26\",\"trackingEvents\":[{\"eventType\":\"Delivered, In/At Mailbox\",\"eventTimestamp\":\"2026-11-26T13:14:00-05:00\",\"eventCity\":\"WASHINGTON\",\"eventState\":\"DC\",\"eventZIP\":\"20260\"}]}",
"expectTitleIncludes": "USPS Tracking: 9400111899223344556677",
"expectMarkdownIncludes": [
"9400111899223344556677",
"Delivered, In/At Mailbox",
"WASHINGTON, DC, 20260"
],
"negativeCases": [
{
"name": "http-401-invalid-token",
"status": 401,
"payload": "{\"error\":{\"code\":\"401\",\"message\":\"Missing or malformed access token.\",\"errors\":[{\"title\":\"invalid_token\"}]}}"
},
{
"name": "redirect-to-error",
"status": 200,
"finalUrl": "https://apis.usps.com/error",
"payload": "<!doctype html><html><head><title>404 Not Found</title></head><body><h1>Not Found</h1></body></html>"
},
{
"name": "maintenance",
"status": 503,
"payload": "<!doctype html><html><head><title>Service Unavailable</title></head><body><p>Scheduled maintenance.</p></body></html>"
},
{
"name": "tracking-not-found",
"status": 404,
"payload": "{\"error\":{\"code\":\"404\",\"message\":\"Tracking number not found\"}}"
}
]
}
36 changes: 36 additions & 0 deletions hub/test/fixtures/adapters/cbo.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
{
"adapterId": "cbo",
"mode": "twin",
"inputUrl": "https://www.cbo.gov/publications/all/rss.xml",
"expectedFetchUrl": "https://www.cbo.gov/publications/all/rss.xml",
"mockPayload": "<?xml version=\"1.0\" encoding=\"UTF-8\"?><rss version=\"2.0\"><channel><title>CBO All Publications</title><link>https://www.cbo.gov/publications</link><item><title>Cost Estimate for H.R. 4120, Infrastructure Modernization Act</title><link>https://www.cbo.gov/publication/62899</link><pubDate>Wed, 25 Nov 2026 14:00:00 +0000</pubDate><description>CBO estimates enacting H.R. 4120 would increase direct spending by $1.4 billion over 2027-2036.</description></item></channel></rss>",
"expectTitleIncludes": "CBO All Publications",
"expectMarkdownIncludes": [
"Cost Estimate for H.R. 4120",
"https://www.cbo.gov/publication/62899",
"$1.4 billion"
],
"negativeCases": [
{
"name": "http-404",
"status": 404,
"payload": "<!doctype html><html><head><title>404 Not Found</title></head><body><h1>Page Not Found</h1></body></html>"
},
{
"name": "redirect-to-error",
"status": 200,
"finalUrl": "https://www.cbo.gov/error",
"payload": "<!doctype html><html><head><title>Error</title></head><body><h1>Error</h1></body></html>"
},
{
"name": "maintenance",
"status": 503,
"payload": "<!doctype html><html><head><title>Scheduled Maintenance</title></head><body><p>Service temporarily unavailable.</p></body></html>"
},
{
"name": "datadome-challenge",
"status": 403,
"payload": "<html><head><title>cbo.gov</title></head><body><p id=\"cmsg\">Please enable JS and disable any ad blocker</p><script data-cfasync=\"false\">var dd={'rt':'c','cid':'abc123','hsh':'xyz','host':'geo.captcha-delivery.com'}</script></body></html>"
}
]
}
Loading
Loading