The design language that makes your AI harness better at design.
JavaScript
URL scans hide known consent banners before the rule pass
Paul Bakaus8ce96310f7ab
diff --git a/crates/browser/src/consent.rs b/crates/browser/src/consent.rsnew file mode 100644index 000000000..e053a290c--- /dev/null+++ b/crates/browser/src/consent.rs@@ -0,0 +1,448 @@+//! Known consent managers, and hiding their banners before the rule pass.+//!+//! A consent banner is not the site. At capture it covers copy a visitor+//! reads once they dismiss it, so text under it is either skipped as covered+//! or scored against the banner, and the crops show the banner instead of the+//! page. Before the reveal sweep the URL engine hides the banners and+//! backdrops of the consent managers listed here with an injected style+//! (`display: none`), and undoes the scroll lock the manager applied. It never+//! clicks, sets a cookie, or records a consent choice: the page's own state is+//! unchanged, only painted without the manager's layer.+//!+//! The list holds selectors specific to one vendor (its ids, or class names+//! carrying its name), never a generic word such as "cookie" or "banner", so+//! a notice a site wrote for itself stays on the page and is scanned like the+//! rest of it. The validity gate ([`crate::validity`]) reads the same list to+//! recognize a page that is nothing but a consent wall.+//!+//! Corpus evidence (runs 20 and 25, 848 captures of 126 sites, desktop and+//! 390px): OneTrust on 7 sites (adm.com, cisco.com, cvs.com, exxonmobil.com,+//! mckesson.com, otto.de, thecignagroup.com; `#onetrust-consent-sdk`,+//! `#onetrust-banner-sdk` and `.onetrust-pc-dark-filter` on every one),+//! Usercentrics on 2 (fedex.com, tchibo.de; `#usercentrics-cmp-ui`), and one+//! site each for Cookiebot (theagenticdatacompany.com,+//! `#CybotCookiebotDialog`), TrustArc (samsung.com, `#consent_blackbar` and+//! `#truste-consent-track`), Didomi (ladepeche.fr, `#didomi-host`), the+//! open-source Cookie Consent library (centene.com,+//! `.cc-window[aria-label="cookieconsent"]`) and Google's consent messages+//! (ynet.co.il, `.fc-ccpa-root`). The other vendors are listed from their+//! published markup and have no corpus capture yet.++use serde_json::{json, Value};++/// One consent manager: the elements to hide and the scroll lock it applies.+#[derive(Debug, Clone, Copy)]+pub struct ConsentManager {+ pub name: &'static str,+ /// The banner, dialog, or preference-center roots.+ pub roots: &'static [&'static str],+ /// Overlays the manager lays over the page behind its dialog.+ pub backdrops: &'static [&'static str],+ /// Classes the manager puts on `<html>` to stop the page scrolling.+ pub html_lock_classes: &'static [&'static str],+ /// Classes the manager puts on `<body>` to stop the page scrolling.+ pub body_lock_classes: &'static [&'static str],+}++/// Every known consent manager, in the order a report names them.+pub const CONSENT_MANAGERS: &[ConsentManager] = &[+ ConsentManager {+ name: "OneTrust",+ roots: &["#onetrust-consent-sdk", "#onetrust-banner-sdk", "#onetrust-pc-sdk"],+ backdrops: &[".onetrust-pc-dark-filter"],+ html_lock_classes: &[],+ body_lock_classes: &[],+ },+ ConsentManager {+ name: "Cookiebot",+ roots: &["#CybotCookiebotDialog"],+ backdrops: &["#CybotCookiebotDialogBodyUnderlay"],+ html_lock_classes: &[],+ body_lock_classes: &[],+ },+ ConsentManager {+ name: "Usercentrics",+ roots: &["#usercentrics-root", "#usercentrics-cmp-ui"],+ backdrops: &[],+ html_lock_classes: &[],+ body_lock_classes: &[],+ },+ ConsentManager {+ name: "TrustArc",+ roots: &["#consent_blackbar", "#truste-consent-track", ".truste_box_overlay"],+ backdrops: &[".truste_overlay"],+ html_lock_classes: &[],+ body_lock_classes: &[],+ },+ ConsentManager {+ name: "Didomi",+ roots: &["#didomi-host"],+ backdrops: &[],+ html_lock_classes: &[],+ body_lock_classes: &["didomi-popup-open"],+ },+ ConsentManager {+ name: "Quantcast Choice",+ roots: &["#qc-cmp2-container", ".qc-cmp2-container"],+ backdrops: &[],+ html_lock_classes: &[],+ body_lock_classes: &[],+ },+ ConsentManager {+ name: "Sourcepoint",+ roots: &["[id^='sp_message_container_']"],+ backdrops: &[],+ html_lock_classes: &["sp-message-open"],+ body_lock_classes: &[],+ },+ ConsentManager {+ name: "Osano",+ roots: &[".osano-cm-dialog", ".osano-cm-info-dialog"],+ backdrops: &[],+ html_lock_classes: &[],+ body_lock_classes: &[],+ },+ ConsentManager {+ name: "Cookie Consent",+ roots: &[".cc-window[aria-label='cookieconsent']", ".cc-window.cc-banner", ".cc-grower"],+ backdrops: &[],+ html_lock_classes: &[],+ body_lock_classes: &[],+ },+ ConsentManager {+ name: "CookieYes",+ roots: &[".cky-consent-container", ".cky-modal", "#cookie-law-info-bar", "#cliSettingsPopup"],+ backdrops: &[".cky-overlay", ".cli-modal-backdrop"],+ html_lock_classes: &[],+ body_lock_classes: &[],+ },+ ConsentManager {+ name: "Complianz",+ roots: &["#cmplz-cookiebanner-container", ".cmplz-cookiebanner"],+ backdrops: &[".cmplz-soft-cookiewall"],+ html_lock_classes: &[],+ body_lock_classes: &[],+ },+ ConsentManager {+ name: "iubenda",+ roots: &["#iubenda-cs-banner"],+ backdrops: &[],+ html_lock_classes: &[],+ body_lock_classes: &[],+ },+ ConsentManager {+ name: "Termly",+ roots: &["#termly-code-snippet-support"],+ backdrops: &[],+ html_lock_classes: &[],+ body_lock_classes: &[],+ },+ ConsentManager {+ name: "Axeptio",+ roots: &[".axeptio_mount"],+ backdrops: &["#axeptio_overlay"],+ html_lock_classes: &[],+ body_lock_classes: &[],+ },+ ConsentManager {+ name: "Borlabs Cookie",+ roots: &["#BorlabsCookieBox", "#BorlabsCookieBoxWrap", ".brlbs-cmpnt-container"],+ backdrops: &[],+ html_lock_classes: &[],+ body_lock_classes: &[],+ },+ ConsentManager {+ name: "Klaro",+ roots: &["#klaro .cookie-notice", "#klaro .cookie-modal"],+ backdrops: &[],+ html_lock_classes: &[],+ body_lock_classes: &[],+ },+ ConsentManager {+ name: "Cookie Notice",+ roots: &["#cookie-notice:has(#cn-notice-text)"],+ backdrops: &[],+ html_lock_classes: &[],+ body_lock_classes: &[],+ },+ ConsentManager {+ name: "Shopify",+ roots: &["#shopify-pc__banner", "#shopify-pc__prefs"],+ backdrops: &[],+ html_lock_classes: &[],+ body_lock_classes: &[],+ },+ ConsentManager {+ name: "Google Funding Choices",+ roots: &[".fc-consent-root", ".fc-ccpa-root"],+ backdrops: &[".fc-dialog-overlay"],+ html_lock_classes: &[],+ body_lock_classes: &[],+ },+];++/// The id of the style element the hide step injects.+pub const HIDE_STYLE_ID: &str = "impeccable-consent-hide";++fn managers_json() -> Value {+ Value::Array(+ CONSENT_MANAGERS+ .iter()+ .map(|m| {+ json!({+ "name": m.name,+ "roots": m.roots,+ "backdrops": m.backdrops,+ "htmlLock": m.html_lock_classes,+ "bodyLock": m.body_lock_classes,+ })+ })+ .collect(),+ )+}++/// Page JS shared by the probe and the hide step. `showing(el)` is whether an+/// element (or, for a zero-size wrapper such as `#onetrust-consent-sdk`, one+/// of its first descendants) paints a visible box.+const SHOWING_JS: &str = r#"const q = s => { try { return Array.from(document.querySelectorAll(s)); } catch (e) { return []; } };+ const boxShows = el => {+ try {+ if (el.checkVisibility && !el.checkVisibility({ opacityProperty: true, visibilityProperty: true })) return false;+ const r = el.getBoundingClientRect();+ return r.width >= 1 && r.height >= 1;+ } catch (e) { return false; }+ };+ const showing = el => {+ if (!el || !el.isConnected) return false;+ try {+ if (el.checkVisibility && !el.checkVisibility({ opacityProperty: true, visibilityProperty: true })) return false;+ } catch (e) {}+ if (boxShows(el)) return true;+ for (const scope of [el, el.shadowRoot]) {+ if (!scope) continue;+ const kids = scope.querySelectorAll('*');+ for (let i = 0; i < kids.length && i < 400; i++) if (boxShows(kids[i])) return true;+ }+ return false;+ };"#;++/// A probe fragment: `consentShowing(managers)` returns the names of the+/// managers whose roots are showing, and the visible text inside those roots.+pub fn probe_fragment() -> String {+ format!(+ r#"const consentManagers = {managers};+ {showing}+ const consent = [];+ const consentRoots = [];+ for (const m of consentManagers) {{+ let on = false;+ for (const s of m.roots) for (const el of q(s)) if (showing(el)) {{ on = true; consentRoots.push(el); }}+ if (on) consent.push(m.name);+ }}+ let consentChars = 0;+ for (const el of consentRoots) {{+ if (consentRoots.some(o => o !== el && o.contains(el))) continue;+ consentChars += (el.innerText || '').replace(/\s+/g, ' ').trim().length;+ }}"#,+ managers = managers_json(),+ showing = SHOWING_JS,+ )+}++/// The hide step. Idempotent: run it once before the reveal sweep and again+/// right before the capture, to catch a manager that injects its banner late.+/// Returns `{ hidden: [name], matched: { name: [selector] }, unlocked: [what] }`+/// for the managers it found showing this time.+pub fn hide_js() -> String {+ format!(+ r#"(() => {{+ const managers = {managers};+ const STYLE_ID = {style_id};+ {showing}+ const out = {{ hidden: [], matched: {{}}, unlocked: [] }};+ const present = [];+ for (const m of managers) {{+ const sels = m.roots.concat(m.backdrops).filter(s => q(s).length > 0);+ if (sels.length) present.push({{ m, sels }});+ }}+ if (!present.length) return out;+ let style = document.getElementById(STYLE_ID);+ // Measure with the hide rule off, so a banner the rule already hides (one+ // injected after the first pass) is still reported. Nothing paints between+ // disabling and re-enabling it: this runs in one task.+ if (style) style.disabled = true;+ const showingBackdrop = [];+ for (const {{ m, sels }} of present) {{+ const on = sels.filter(s => q(s).some(showing));+ if (on.length) {{+ out.hidden.push(m.name);+ out.matched[m.name] = on;+ if (on.some(s => m.backdrops.includes(s))) showingBackdrop.push(m.name);+ }}+ }}+ if (!style) {{+ style = document.createElement('style');+ style.id = STYLE_ID;+ (document.head || document.documentElement).appendChild(style);+ }}+ style.disabled = false;+ const rules = [];+ for (const {{ sels }} of present) for (const s of sels) rules.push(s + ' {{ display: none !important; }}');+ const text = rules.join('\n');+ if (style.textContent !== text) style.textContent = text;+ // A manager that sets `display` inline with !important outranks the rule.+ for (const {{ sels }} of present) for (const s of sels) for (const el of q(s)) {{+ try {{+ if (getComputedStyle(el).display !== 'none') el.style.setProperty('display', 'none', 'important');+ }} catch (e) {{}}+ }}+ // Undo the scroll lock the manager applied, and only that: its own classes+ // on <html> and <body>, and an inline overflow: hidden on either while its+ // backdrop was up (a modal consent layer locks the page that way). A+ // site's own overflow is left alone.+ const html = document.documentElement;+ const body = document.body;+ for (const {{ m }} of present) {{+ if (!out.hidden.includes(m.name)) continue;+ for (const c of m.htmlLock) if (html.classList.contains(c)) {{ html.classList.remove(c); out.unlocked.push('html.' + c); }}+ if (body) for (const c of m.bodyLock) if (body.classList.contains(c)) {{ body.classList.remove(c); out.unlocked.push('body.' + c); }}+ }}+ if (showingBackdrop.length) {{+ for (const [el, tag] of [[html, 'html'], [body, 'body']]) {{+ if (!el) continue;+ for (const p of ['overflow', 'overflow-y']) {{+ if (el.style.getPropertyValue(p) === 'hidden') {{+ el.style.removeProperty(p);+ out.unlocked.push(tag + ' style ' + p);+ }}+ }}+ }}+ }}+ return out;+}})()"#,+ managers = managers_json(),+ style_id = json!(HIDE_STYLE_ID),+ showing = SHOWING_JS,+ )+}++/// What the hide step did over a scan: the managers it hid, the selectors+/// that matched a showing element, and the scroll locks it undid.+#[derive(Debug, Clone, Default, PartialEq)]+pub struct ConsentReport {+ /// Managers whose banner or backdrop was showing and was hidden, in+ /// [`CONSENT_MANAGERS`] order.+ pub hidden: Vec<String>,+ /// Per hidden manager, the selectors that matched a showing element.+ pub matched: Vec<(String, Vec<String>)>,+ /// The scroll locks undone (`body.didomi-popup-open`, `body style overflow`).+ pub unlocked: Vec<String>,+}++impl ConsentReport {+ /// Fold one hide-step result into the report.+ pub fn merge(&mut self, v: &Value) {+ let strs = |v: Option<&Value>| -> Vec<String> {+ v.and_then(Value::as_array)+ .map(|a| a.iter().filter_map(Value::as_str).map(String::from).collect())+ .unwrap_or_default()+ };+ for name in strs(v.get("hidden")) {+ let sels = strs(v.get("matched").and_then(|m| m.get(&name)));+ match self.matched.iter_mut().find(|(n, _)| *n == name) {+ Some((_, have)) => {+ for s in sels {+ if !have.contains(&s) {+ have.push(s);+ }+ }+ }+ None => self.matched.push((name.clone(), sels)),+ }+ if !self.hidden.contains(&name) {+ self.hidden.push(name);+ }+ }+ for u in strs(v.get("unlocked")) {+ if !self.unlocked.contains(&u) {+ self.unlocked.push(u);+ }+ }+ let order = |n: &String| CONSENT_MANAGERS.iter().position(|m| m.name == n).unwrap_or(usize::MAX);+ self.hidden.sort_by_key(order);+ self.matched.sort_by_key(|(n, _)| order(n));+ }++ pub fn to_value(&self) -> Value {+ let matched: serde_json::Map<String, Value> = self+ .matched+ .iter()+ .map(|(n, s)| (n.clone(), json!(s)))+ .collect();+ json!({ "hidden": self.hidden, "matched": matched, "unlocked": self.unlocked })+ }+}++#[cfg(test)]+mod tests {+ use super::*;++ /// No selector is a bare generic word: each names its vendor, or is an id+ /// or class the vendor's own markup carries.+ #[test]+ fn selectors_are_vendor_specific() {+ let generic = ["cookie", "cookies", "consent", "banner", "gdpr", "privacy", "cookie-banner", "cookie-consent", "consent-banner", "modal", "overlay"];+ for m in CONSENT_MANAGERS {+ for s in m.roots.iter().chain(m.backdrops) {+ let bare = s.trim_start_matches(['#', '.']).to_ascii_lowercase();+ assert!(!generic.contains(&bare.as_str()), "{}: {s} is generic", m.name);+ }+ }+ }++ #[test]+ fn every_requested_vendor_is_listed() {+ for name in [+ "OneTrust", "Cookiebot", "Usercentrics", "TrustArc", "Didomi", "Quantcast Choice", "Sourcepoint",+ "Osano", "CookieYes", "Complianz", "iubenda", "Termly", "Axeptio", "Borlabs Cookie", "Klaro",+ "Cookie Notice", "Shopify",+ ] {+ assert!(CONSENT_MANAGERS.iter().any(|m| m.name == name), "{name}");+ }+ }++ #[test]+ fn report_merges_passes_in_list_order() {+ let mut r = ConsentReport::default();+ r.merge(&json!({ "hidden": ["Cookiebot"], "matched": { "Cookiebot": ["#CybotCookiebotDialog"] }, "unlocked": [] }));+ r.merge(&json!({+ "hidden": ["OneTrust", "Cookiebot"],+ "matched": { "OneTrust": ["#onetrust-consent-sdk"], "Cookiebot": ["#CybotCookiebotDialog", "#CybotCookiebotDialogBodyUnderlay"] },+ "unlocked": ["body style overflow"],+ }));+ assert_eq!(r.hidden, vec!["OneTrust", "Cookiebot"]);+ assert_eq!(+ r.to_value(),+ json!({+ "hidden": ["OneTrust", "Cookiebot"],+ "matched": {+ "OneTrust": ["#onetrust-consent-sdk"],+ "Cookiebot": ["#CybotCookiebotDialog", "#CybotCookiebotDialogBodyUnderlay"],+ },+ "unlocked": ["body style overflow"],+ })+ );+ }++ #[test]+ fn scripts_embed_every_selector() {+ let (probe, hide) = (probe_fragment(), hide_js());+ for m in CONSENT_MANAGERS {+ for s in m.roots.iter().chain(m.backdrops) {+ let quoted = serde_json::to_string(s).unwrap();+ assert!(hide.contains("ed), "{s}");+ assert!(probe.contains("ed), "{s}");+ }+ }+ }+}diff --git a/crates/browser/src/lib.rs b/crates/browser/src/lib.rsindex bbc9024c0..cdb63f9e8 100644--- a/crates/browser/src/lib.rs+++ b/crates/browser/src/lib.rs@@ -16,8 +16,10 @@//! (`createBrowserDetector()`: `waitUntil: 'load'`, `settleMs: 100`).//!//! Before any rule runs, the loaded page is classified ([`validity`]): a bot-//! challenge or an HTTP error page is refused with an error instead of being-//! scanned and reported clean.+//! challenge, an HTTP error page, or a page that is only a consent wall is+//! refused with an error instead of being scanned and reported clean. Then+//! the banners of known consent managers are hidden ([`consent`]), so every+//! pass and the screenshot see the page a visitor sees once they dismiss it.//!//! Two entry points serve measurement work rather than the CLI.//! [`detect_url_evidence`] runs the same scan and also returns what a@@ -27,6 +29,7 @@//! measured against saved pages.pub mod cdp;+pub mod consent;pub mod discovery;pub mod fullpage;pub mod screenshot_contrast;@@ -44,11 +47,12 @@ use impeccable_core::browser::snapshot::{Facts, SnapshotDom};use impeccable_core::checks::measures::{check_content_hidden_at_rest, ContentHiddenInput};use impeccable_core::findings::{try_finding, Finding};use impeccable_detect::design_system::DesignSystem;-use impeccable_detect::engines::{EngineError, ScanOptions, SharedBrowser, UrlEngine};+use impeccable_detect::engines::{EngineError, ScanOptions, SharedBrowser, UrlEngine, UrlScan};use impeccable_detect::profiler::{DetectorProfile, ProfileMeta};use serde_json::{json, Map, Value};use cdp::{Browser, CdpError, Page, Viewport};+use consent::ConsentReport;pub use fullpage::ElementShot;use validity::{DocumentResponse, PageProbe, PageValidity};@@ -101,6 +105,10 @@ impl BrowserEngine {impl UrlEngine for BrowserEngine {fn detect_url(&self, url: &str, options: &ScanOptions) -> Result<Vec<Finding>, EngineError> {+ Ok(self.detect_url_scan(url, options)?.findings)+ }++ fn detect_url_scan(&self, url: &str, options: &ScanOptions) -> Result<UrlScan, EngineError> {detect_url_impl(self, url, options, "networkidle0", 0, None)}@@ -126,6 +134,10 @@ pub struct SharedBrowserHandle<'a> {impl SharedBrowser for SharedBrowserHandle<'_> {fn detect_url(&self, url: &str, options: &ScanOptions) -> Result<Vec<Finding>, EngineError> {+ Ok(self.detect_url_scan(url, options)?.findings)+ }++ fn detect_url_scan(&self, url: &str, options: &ScanOptions) -> Result<UrlScan, EngineError> {if let Some(msg) = self.launch_error.borrow().as_ref() {return Err(EngineError::new(msg.clone()));}@@ -325,6 +337,10 @@ pub struct Evidence {/// [`Evidence::screenshot`] (past its cut or its right edge), taken with/// the element scrolled into view. See [`fullpage`].pub element_shots: Vec<ElementShot>,+ /// The consent managers the scan hid ([`consent`]), with the selectors+ /// that matched and the scroll locks undone. `None` when hiding was off+ /// ([`ScanOptions::keep_consent_banners`]) or the page was blocked.+ pub consent: Option<ConsentReport>,}/// A full-page screenshot taken after the scan. Its pixels line up with@@ -467,7 +483,7 @@ fn detect_url_impl(wait_until: &str,settle_ms: u64,external: Option<&mut Browser>,-) -> Result<Vec<Finding>, EngineError> {+) -> Result<UrlScan, EngineError> {// JS `const { href: url, credentials } = splitScanUrl(rawUrl)` (issue #657):// everything below (goto, profile targets, finding output) sees the// redacted href only.@@ -495,8 +511,9 @@ fn detect_url_impl(}};+ let mut consent = ConsentReport::default();let scanned = scan_on_browser(- browser, url, credentials, options, wait_until, settle_ms, profile, None,+ browser, url, credentials, options, wait_until, settle_ms, profile, None, &mut consent,);// finally: close page (inside scan_page) and the browser when owned.if owns_browser {@@ -504,8 +521,26 @@ fn detect_url_impl(step(profile, "load", "close-browser", url, || b.close());}}- let (findings, _) = results_to_findings(url, scanned?, options.design_system.as_deref())?;- Ok(findings)+ let (mut findings, _) = results_to_findings(url, scanned?, options.design_system.as_deref())?;+ let mut notes = Vec::new();+ if !consent.hidden.is_empty() {+ let names = json!(consent.hidden);+ for f in findings.iter_mut() {+ f.extras.insert("consentHidden".into(), names.clone());+ }+ notes.push(consent_note(url, &consent.hidden));+ }+ Ok(UrlScan { findings, notes })+}++/// The text-mode note for a scan that hid consent banners.+fn consent_note(url: &str, hidden: &[String]) -> String {+ let (names, noun) = match hidden {+ [one] => (one.clone(), "banner"),+ [rest @ .., last] => (format!("{} and {last}", rest.join(", ")), "banners"),+ [] => (String::new(), "banner"),+ };+ format!("Hid the {names} consent {noun} on {url} before scanning. Pass --no-consent-hiding to scan it.")}/// Run the URL engine's scan on a browser the caller owns and also return@@ -523,6 +558,7 @@ pub fn detect_url_evidence() -> Result<(Vec<Finding>, Evidence), EngineError> {let (url, credentials) = split_scan_url(url);let mut evidence = Evidence::default();+ let mut consent = ConsentReport::default();let results = scan_on_browser(browser,&url,@@ -532,7 +568,13 @@ pub fn detect_url_evidence(settle_ms,options.profile.as_deref(),Some((&mut evidence, request)),- )?;+ &mut consent,+ );+ let blocked = evidence.validity.as_ref().is_some_and(PageValidity::is_blocked);+ if !options.keep_consent_banners && !blocked {+ evidence.consent = Some(consent);+ }+ let results = results?;let (findings, origins) = results_to_findings(&url, results, options.design_system.as_deref())?;evidence.origins = origins;Ok((findings, evidence))@@ -691,6 +733,7 @@ fn scan_on_browser(settle_ms: u64,profile: Option<&DetectorProfile>,evidence: Option<(&mut Evidence, &EvidenceRequest)>,+ consent: &mut ConsentReport,) -> Result<Vec<RawResult>, EngineError> {let (vw, vh) = options.viewport.unwrap_or((1280, 800));let viewport = Viewport {@@ -700,7 +743,7 @@ fn scan_on_browser(let page = step(profile, "load", "new-page", url, || browser.new_page()).map_err(cdp_err);match page {Ok(page) => scan_page(- page, url, credentials, options, wait_until, settle_ms, viewport, profile, evidence,+ page, url, credentials, options, wait_until, settle_ms, viewport, profile, evidence, consent,),Err(e) => Err(e),}@@ -718,6 +761,7 @@ fn scan_page(viewport: Viewport,profile: Option<&DetectorProfile>,evidence: Option<(&mut Evidence, &EvidenceRequest)>,+ consent: &mut ConsentReport,) -> Result<Vec<RawResult>, EngineError> {let outcome = scan_page_inner(&mut page,@@ -729,6 +773,7 @@ fn scan_page(viewport,profile,evidence,+ consent,);step(profile, "load", "close-page", url, || page.close());outcome@@ -765,6 +810,7 @@ fn scan_page_inner(viewport: Viewport,profile: Option<&DetectorProfile>,mut evidence: Option<(&mut Evidence, &EvidenceRequest)>,+ consent: &mut ConsentReport,) -> Result<Vec<RawResult>, EngineError> {step(profile, "load", "set-viewport", url, || {page.set_viewport(viewport)@@ -805,6 +851,17 @@ fn scan_page_inner(};}+ // Hide known consent managers' banners and backdrops, and undo the scroll+ // lock they applied, before anything is swept or measured. Never a click+ // and never a consent choice: an injected style paints the page without+ // the manager's layer. The validity probe above ran first, so a page that+ // is only a consent wall was refused rather than scanned empty.+ let hide_consent = !options.keep_consent_banners;+ if hide_consent {+ step(profile, "load", "hide-consent", url, || hide_consent_banners(page, consent))+ .map_err(cdp_err)?;+ }+// Inject the plain-JS snapshot producer (no WebAssembly runs in the page).step(profile, "scan", "inject-snapshot-script", url, || {snapshot_engine::ensure_snapshot_js(page)@@ -823,6 +880,13 @@ fn scan_page_inner(// before the sweep hides whole pages of text from the rule pass.step(profile, "scan", "reveal-sweep", url, || reveal_sweep(page)).map_err(cdp_err)?;+ // A manager that injects its banner late (after load, or on the first+ // scroll) is hidden here, before the capture every pass reads.+ if hide_consent {+ step(profile, "scan", "hide-consent", url, || hide_consent_banners(page, consent))+ .map_err(cdp_err)?;+ }+// The one capture every pass below reads: the rule pass, the hidden-text// measure, and the visual pass share this DOM, so a hit test any of them// answers is answered for all three. The sweep leaves the page revealed and@@ -909,6 +973,10 @@ fn scan_page_inner(results.extend(visual);if let Some((ev, request)) = evidence {+ // And once more before the screenshot, so the crops match the capture.+ if hide_consent {+ let _ = hide_consent_banners(page, consent);+ }let mut selectors: Vec<String> = Vec::new();for r in &results {if let Some(s) = &r.selector {@@ -1134,6 +1202,14 @@ fn capture_post_scan(}}+/// Run the consent hide step ([`consent::hide_js`]) and fold what it hid into+/// `report`. Idempotent; each run also catches a banner injected since the last.+fn hide_consent_banners(page: &mut Page<'_>, report: &mut ConsentReport) -> Result<(), CdpError> {+ let v = page.evaluate_value(&consent::hide_js())?;+ report.merge(&v);+ Ok(())+}+/// The `measureContentHiddenAfterReveal` reveal sweep: scroll the page top to/// bottom (revealing lazy / on-scroll content), then back to the top and/// settle. The hidden-text measure then runs natively over a fresh capture.diff --git a/crates/browser/src/validity.rs b/crates/browser/src/validity.rsindex 1e8d8a8e9..43ae5e3b0 100644--- a/crates/browser/src/validity.rs+++ b/crates/browser/src/validity.rs@@ -12,6 +12,13 @@//! Header and HTTP-status signals stand alone. Titles and DOM markers only//! count on a small page, because a real page can carry a captcha widget on a//! form or be titled "Access denied" in a CMS without being a block page.+//!+//! The probe also names the known consent managers ([`crate::consent`]) whose+//! banner is showing, and how much visible text sits inside them. It runs+//! before the scan hides those banners, so a page that is nothing but a+//! consent wall (a small page whose readable text is almost all the+//! manager's) is refused as one, instead of being scanned empty and reported+//! clean.use serde_json::{json, Value};@@ -19,6 +26,12 @@ use serde_json::{json, Value};/// treated as content even when its title or a marker looks like a challenge.pub const SMALL_PAGE_CHARS: u64 = 3000;+/// A small page with a known consent manager showing is a consent wall when+/// fewer than this many visible characters lie outside the manager's roots,+/// and the manager holds at least [`CONSENT_WALL_RATIO`] times as many.+pub const CONSENT_WALL_OUTSIDE_CHARS: u64 = 100;+pub const CONSENT_WALL_RATIO: u64 = 3;+/// Titles challenge and block pages use, lowercased and trimmed. Matched by/// prefix, so "Access Denied" also covers "Access Denied - Reference #18...".const CHALLENGE_TITLE_PREFIXES: &[&str] = &[@@ -61,8 +74,9 @@ pub const CHALLENGE_MARKERS: &[(&str, &str)] = &[(".geetest_holder, #nc_1_wrapper, #aliyunCaptcha-sliding-wrapper", "slider-captcha"),];-/// The in-page probe: title, visible text length, final URL, and which-/// challenge markers are present. Read-only; returns a plain object.+/// The in-page probe: title, visible text length, final URL, which+/// challenge markers are present, and which consent managers are showing+/// with the visible text inside them. Read-only; returns a plain object.pub fn probe_js() -> String {let markers: Vec<Value> = CHALLENGE_MARKERS.iter()@@ -75,15 +89,19 @@ pub fn probe_js() -> String {for (const [selector, label] of markers) {{try {{ if (document.querySelector(selector)) found.push(label); }} catch (e) {{}}}}+ {consent}const text = (document.body && document.body.innerText) || '';return {{title: String(document.title || ''),textChars: text.replace(/\s+/g, ' ').trim().length,href: String(location.href || ''),markers: found,+ consent,+ consentChars,}};}})()"#,- markers = Value::Array(markers)+ markers = Value::Array(markers),+ consent = crate::consent::probe_fragment(),)}@@ -94,6 +112,10 @@ pub struct PageProbe {pub text_chars: u64,pub href: String,pub markers: Vec<String>,+ /// Known consent managers whose banner was showing, before any was hidden.+ pub consent: Vec<String>,+ /// Visible characters inside those managers' roots.+ pub consent_chars: u64,}impl PageProbe {@@ -107,6 +129,12 @@ impl PageProbe {.and_then(Value::as_array).map(|a| a.iter().filter_map(Value::as_str).map(String::from).collect()).unwrap_or_default(),+ consent: v+ .get("consent")+ .and_then(Value::as_array)+ .map(|a| a.iter().filter_map(Value::as_str).map(String::from).collect())+ .unwrap_or_default(),+ consent_chars: v.get("consentChars").and_then(Value::as_f64).unwrap_or(0.0).max(0.0) as u64,}}@@ -116,6 +144,8 @@ impl PageProbe {"textChars": self.text_chars,"href": self.href,"markers": self.markers,+ "consent": self.consent,+ "consentChars": self.consent_chars,})}}@@ -177,6 +207,8 @@ pub enum BlockKind {Challenge,/// The server answered with a 4xx/5xx status.HttpError,+ /// The page is a known consent manager's wall with next to no page behind it.+ ConsentWall,}impl BlockKind {@@ -184,6 +216,7 @@ impl BlockKind {match self {BlockKind::Challenge => "challenge",BlockKind::HttpError => "http-error",+ BlockKind::ConsentWall => "consent-wall",}}}@@ -225,6 +258,9 @@ impl PageValidity {BlockKind::HttpError => format!("the page returned an error ({signals}). Findings would describe the error page, so none are reported."),+ BlockKind::ConsentWall => format!(+ "the page is a consent wall, not the site ({signals}). Findings would describe the consent dialog, so none are reported."+ ),})}}@@ -280,6 +316,18 @@ pub fn classify(response: Option<&DocumentResponse>, probe: &PageProbe) -> PageVevidence: vec![format!("HTTP {status}")],};}+ if small && !probe.consent.is_empty() {+ let outside = probe.text_chars.saturating_sub(probe.consent_chars);+ if outside < CONSENT_WALL_OUTSIDE_CHARS && probe.consent_chars >= CONSENT_WALL_RATIO * outside {+ return PageValidity::Blocked {+ kind: BlockKind::ConsentWall,+ evidence: vec![+ format!("consent manager {}", probe.consent.join(", ")),+ format!("{outside} of {} visible characters outside it", probe.text_chars),+ ],+ };+ }+ }PageValidity::Ok}@@ -301,9 +349,44 @@ mod tests {text_chars,href: "https://example.com/".into(),markers: markers.iter().map(|m| m.to_string()).collect(),+ ..Default::default()}}+ #[test]+ fn a_page_that_is_only_a_consent_wall_is_refused() {+ let mut p = probe("Example", 900, &[]);+ p.consent = vec!["OneTrust".into()];+ p.consent_chars = 860;+ let v = classify(Some(&resp(200, &[])), &p);+ assert_eq!(+ v,+ PageValidity::Blocked {+ kind: BlockKind::ConsentWall,+ evidence: vec!["consent manager OneTrust".into(), "40 of 900 visible characters outside it".into()],+ }+ );+ assert!(v.error_message().unwrap().starts_with("the page is a consent wall"));+ }++ #[test]+ fn a_consent_banner_over_a_page_is_the_page() {+ // A short page under a shorter banner.+ let mut p = probe("Example", 272, &[]);+ p.consent = vec!["OneTrust".into()];+ p.consent_chars = 190;+ assert_eq!(classify(Some(&resp(200, &[])), &p), PageValidity::Ok);+ let mut p = probe("Example", 2400, &[]);+ p.consent = vec!["Cookiebot".into()];+ p.consent_chars = 700;+ assert_eq!(classify(Some(&resp(200, &[])), &p), PageValidity::Ok);+ // A large page is content whatever the banner holds.+ let mut p = probe("Example", 40000, &[]);+ p.consent = vec!["Cookiebot".into()];+ p.consent_chars = 39900;+ assert_eq!(classify(Some(&resp(200, &[])), &p), PageValidity::Ok);+ }+#[test]fn aws_waf_captcha_is_a_challenge() {// siemens.com, 2026-09-11: CloudFront answered 405 with a captcha page.diff --git a/crates/browser/tests/consent_hiding.rs b/crates/browser/tests/consent_hiding.rsnew file mode 100644index 000000000..c8710ff29--- /dev/null+++ b/crates/browser/tests/consent_hiding.rs@@ -0,0 +1,197 @@+//! Known consent managers' banners are hidden before the rule pass, against+//! an installed browser. Skips cleanly when there is none.+//!+//! - A OneTrust-shaped banner over copy and a CTA with real contrast+//! failures: with hiding (the default) the page copy and the CTA report and+//! the banner's own text does not; with `keep_consent_banners` (the CLI's+//! `--no-consent-hiding`, the engine's old behavior) the covered copy and+//! CTA go unscored and the banner text reports.+//! - A Cookiebot-shaped modal injected late, on the first scroll, with an+//! underlay and an inline scroll lock on `<body>`: caught by the hide pass+//! after the reveal sweep, recorded in the evidence, and the lock undone.+//! - A notice the site wrote itself (generic names, no vendor) stays.+//! - A page that is only a consent wall is refused as one.++use std::collections::HashMap;+use std::io::{Read, Write};+use std::net::{TcpListener, TcpStream};+use std::path::{Path, PathBuf};++use impeccable_browser::{detect_url_evidence, BrowserEngine, EvidenceRequest};+use impeccable_core::findings::Finding;+use impeccable_detect::engines::{ScanOptions, UrlEngine};++fn fixtures_dir() -> PathBuf {+ Path::new(env!("CARGO_MANIFEST_DIR")).join("../../tests/fixtures/consent")+}++fn serve() -> u16 {+ let listener = TcpListener::bind("127.0.0.1:0").expect("bind");+ let port = listener.local_addr().unwrap().port();+ std::thread::spawn(move || {+ for stream in listener.incoming().flatten() {+ std::thread::spawn(move || handle(stream));+ }+ });+ port+}++fn handle(mut stream: TcpStream) {+ let mut buf = [0u8; 8192];+ let n = stream.read(&mut buf).unwrap_or(0);+ let request = String::from_utf8_lossy(&buf[..n]);+ let path = request+ .lines()+ .next()+ .and_then(|l| l.split_whitespace().nth(1))+ .unwrap_or("/")+ .to_string();+ let body = std::fs::read(fixtures_dir().join(path.trim_start_matches('/'))).unwrap_or_default();+ let head = format!(+ "HTTP/1.0 200 OK\r\nContent-Type: text/html; charset=utf-8\r\nContent-Length: {}\r\nConnection: close\r\n\r\n",+ body.len()+ );+ let _ = stream.write_all(head.as_bytes());+ let _ = stream.write_all(&body);+}++fn engine() -> Option<BrowserEngine> {+ let env: HashMap<String, String> = std::env::vars().collect();+ if impeccable_browser::discovery::find_browser(&env).is_err() {+ eprintln!("skip: no installed browser found");+ return None;+ }+ Some(BrowserEngine::new(env))+}++fn flagged(findings: &[Finding]) -> Vec<(String, String)> {+ findings+ .iter()+ .map(|f| {+ (+ f.antipattern.clone(),+ f.extras.get("selector").and_then(|v| v.as_str()).unwrap_or("").to_string(),+ )+ })+ .collect()+}++fn has(flagged: &[(String, String)], rule: &str, selector: &str) -> bool {+ flagged.iter().any(|(r, s)| r == rule && s == selector)+}++const KEEP: ScanOptions = ScanOptions {+ inline_ignores: false,+ design_system: None,+ viewport: None,+ profile: None,+ rule_pack: None,+ keep_consent_banners: true,+};++#[test]+fn a_onetrust_banner_is_hidden_and_the_page_under_it_scored() {+ let Some(engine) = engine() else { return };+ let port = serve();+ let url = format!("http://127.0.0.1:{port}/onetrust.html");++ let scan = engine.detect_url_scan(&url, &ScanOptions::default()).expect("scan");+ let hidden = flagged(&scan.findings);+ assert!(has(&hidden, "low-contrast", "#covered-copy"), "{hidden:#?}");+ assert!(has(&hidden, "low-contrast", "#covered-cta"), "{hidden:#?}");+ assert!(!has(&hidden, "low-contrast", "#onetrust-policy-text"), "{hidden:#?}");+ // Every finding names what was hidden, and the text output says so.+ for f in &scan.findings {+ assert_eq!(f.extras.get("consentHidden"), Some(&serde_json::json!(["OneTrust"])), "{f:?}");+ }+ assert_eq!(+ scan.notes,+ vec![format!(+ "Hid the OneTrust consent banner on {url} before scanning. Pass --no-consent-hiding to scan it."+ )]+ );++ // Opted out, the banner stays: what it covers is not scored, and its own+ // text is, the way the engine scanned before hiding existed.+ let kept = engine.detect_url_scan(&url, &KEEP).expect("scan");+ let shown = flagged(&kept.findings);+ assert!(!has(&shown, "low-contrast", "#covered-copy"), "{shown:#?}");+ assert!(!has(&shown, "low-contrast", "#covered-cta"), "{shown:#?}");+ assert!(has(&shown, "low-contrast", "#onetrust-policy-text"), "{shown:#?}");+ assert!(kept.findings.iter().all(|f| f.extras.get("consentHidden").is_none()));+ assert!(kept.notes.is_empty());+}++#[test]+fn a_late_cookiebot_modal_is_caught_and_its_scroll_lock_undone() {+ let Some(engine) = engine() else { return };+ let port = serve();+ let url = format!("http://127.0.0.1:{port}/cookiebot.html");+ let mut browser = engine.launch().expect("launch");+ let (findings, evidence) =+ detect_url_evidence(&mut browser, &url, &ScanOptions::default(), "load", 100, &EvidenceRequest::default())+ .expect("scan");+ let (kept, kept_evidence) =+ detect_url_evidence(&mut browser, &url, &KEEP, "load", 100, &EvidenceRequest::default()).expect("scan");+ browser.close();++ let hidden = flagged(&findings);+ assert!(has(&hidden, "low-contrast", "#covered-copy"), "{hidden:#?}");+ assert!(has(&hidden, "low-contrast", "#covered-cta"), "{hidden:#?}");+ assert!(!has(&hidden, "low-contrast", "#CybotCookiebotDialogBodyContentText"), "{hidden:#?}");+ let consent = evidence.consent.as_ref().expect("consent report");+ assert_eq!(consent.hidden, vec!["Cookiebot"]);+ assert_eq!(+ consent.matched,+ vec![(+ "Cookiebot".to_string(),+ vec!["#CybotCookiebotDialog".to_string(), "#CybotCookiebotDialogBodyUnderlay".to_string()]+ )]+ );+ assert_eq!(consent.unlocked, vec!["body style overflow"]);+ // The validity probe ran before the dialog arrived.+ assert!(evidence.probe.as_ref().unwrap().consent.is_empty());+ // The capture every pass read has the dialog hidden, and the evidence+ // path leaves the findings untagged so they replay equal.+ assert!(evidence.scan_snapshot.as_deref().unwrap().contains("impeccable-consent-hide"));+ assert!(findings.iter().all(|f| f.extras.get("consentHidden").is_none()));++ let shown = flagged(&kept);+ assert!(!has(&shown, "low-contrast", "#covered-copy"), "{shown:#?}");+ assert!(has(&shown, "low-contrast", "#CybotCookiebotDialogBodyContentText"), "{shown:#?}");+ assert!(kept_evidence.consent.is_none());+}++#[test]+fn a_notice_the_site_wrote_itself_stays() {+ let Some(engine) = engine() else { return };+ let port = serve();+ let url = format!("http://127.0.0.1:{port}/site-notice.html");+ let scan = engine.detect_url_scan(&url, &ScanOptions::default()).expect("scan");+ let shown = flagged(&scan.findings);+ assert!(!has(&shown, "low-contrast", "#covered-copy"), "{shown:#?}");+ assert!(!has(&shown, "low-contrast", "#covered-cta"), "{shown:#?}");+ assert!(has(&shown, "low-contrast", "#notice-text"), "{shown:#?}");+ assert!(scan.findings.iter().all(|f| f.extras.get("consentHidden").is_none()));+ assert!(scan.notes.is_empty());+}++#[test]+fn a_page_that_is_only_a_consent_wall_is_refused() {+ let Some(engine) = engine() else { return };+ let port = serve();+ let url = format!("http://127.0.0.1:{port}/wall.html");+ for options in [ScanOptions::default(), KEEP] {+ let err = engine.detect_url(&url, &options).expect_err("a consent wall must not scan");+ assert!(err.message.starts_with("the page is a consent wall, not the site (consent manager OneTrust, "), "{}", err.message);+ }+ let mut browser = engine.launch().expect("launch");+ let (findings, evidence) =+ detect_url_evidence(&mut browser, &url, &ScanOptions::default(), "load", 100, &EvidenceRequest::default())+ .expect("evidence scan of a consent wall is Ok");+ browser.close();+ assert!(findings.is_empty());+ assert_eq!(evidence.validity.as_ref().unwrap().to_value()["status"], "consent-wall");+ assert_eq!(evidence.probe.as_ref().unwrap().consent, vec!["OneTrust"]);+ assert!(evidence.consent.is_none());+}diff --git a/crates/detect/src/cli.rs b/crates/detect/src/cli.rsindex a6f538582..fc786f4ae 100644--- a/crates/detect/src/cli.rs+++ b/crates/detect/src/cli.rs@@ -37,6 +37,9 @@ Options:--no-inline-ignores Do not honor in-file impeccable-disable* ignore comments--no-design-system Do not load local DESIGN.md / .impeccable/design.json context--no-advisory Suppress advisory findings entirely (e.g. em-dash overuse)+ --no-consent-hiding URL scans: keep known consent managers' banners+ (OneTrust, Cookiebot, ...) on the page instead of hiding+ them before the scan--help Show this help messageAdvisory findings:@@ -242,7 +245,8 @@ struct Ctx<'a> {/// scanned, which forces exit 1 (#711).had_operational_failure: bool,/// One line per design system that switched a check off for a scanned- /// target (a DESIGN.md that declares a purple), in first-seen order.+ /// target (a DESIGN.md that declares a purple), and per URL scan note (a+ /// consent banner the engine hid), in first-seen order.design_notes: Vec<String>,}@@ -520,6 +524,7 @@ fn detect_cli(args_in: &[String], io: &mut Io, engines: &Engines) -> Result<i32,// The `impeccable` binary installs no rule pack; a library caller that// does sets this before handing the options to an engine.rule_pack: None,+ keep_consent_banners: has(&args, "--no-consent-hiding"),};let targets: Vec<String> = expand_joined_url_targets(args.iter()@@ -704,16 +709,23 @@ fn scan_targets(ctx.base.clone()};let result = match (shared, ctx.engines.url) {- (Some(s), _) => s.detect_url(target, &url_options),- (None, Some(u)) => u.detect_url(target, &url_options),- (None, None) => crate::engines::UrlEngine::detect_url(+ (Some(s), _) => s.detect_url_scan(target, &url_options),+ (None, Some(u)) => u.detect_url_scan(target, &url_options),+ (None, None) => crate::engines::UrlEngine::detect_url_scan(&crate::engines::MissingUrlEngine,target,&url_options,),};match result {- Ok(f) => all.extend(f),+ Ok(scan) => {+ all.extend(scan.findings);+ for note in scan.notes {+ if !ctx.design_notes.contains(¬e) {+ ctx.design_notes.push(note);+ }+ }+ }Err(e) => {ctx.had_operational_failure = true;ctx.io.err(&format!("Error: {}\n", e.message));diff --git a/crates/detect/src/engines.rs b/crates/detect/src/engines.rsindex a68da684d..0379c8eaa 100644--- a/crates/detect/src/engines.rs+++ b/crates/detect/src/engines.rs@@ -27,6 +27,18 @@ pub struct ScanOptions {/// to the text engine and on to the HTML engine. `None` in the `impeccable`/// binary, which ships the built-in rules only.pub rule_pack: Option<&'static dyn RulePack>,+ /// URL scans only: leave known consent managers' banners on the page+ /// (`--no-consent-hiding`). By default the browser engine hides them+ /// before the rule pass.+ pub keep_consent_banners: bool,+}++/// A URL scan's findings plus the notes the CLI prints about how the page+/// was scanned (a consent banner the engine hid, say).+#[derive(Debug, Default)]+pub struct UrlScan {+ pub findings: Vec<Finding>,+ pub notes: Vec<String>,}/// An error an engine raises; `detectCli` reports it the way the JS surfaces@@ -64,6 +76,11 @@ pub trait HtmlEngine {pub trait UrlEngine {/// A single-URL scan (`detectUrl`: `waitUntil: 'networkidle0'`, `settleMs: 0`).fn detect_url(&self, url: &str, options: &ScanOptions) -> Result<Vec<Finding>, EngineError>;+ /// [`UrlEngine::detect_url`] plus notes for the text output. Engines with+ /// nothing to say keep the default.+ fn detect_url_scan(&self, url: &str, options: &ScanOptions) -> Result<UrlScan, EngineError> {+ Ok(UrlScan { findings: self.detect_url(url, options)?, notes: Vec::new() })+ }/// A shared-browser session for multi-URL scans (`createBrowserDetector()`:/// `waitUntil: 'load'`, `settleMs: 100`). Return `None` when the engine has/// no shared mode; `detect_url` is used per target instead.@@ -75,6 +92,10 @@ pub trait UrlEngine {/// A `createBrowserDetector()` handle: `detectUrl` per target, `close()` at the end.pub trait SharedBrowser {fn detect_url(&self, url: &str, options: &ScanOptions) -> Result<Vec<Finding>, EngineError>;+ /// [`SharedBrowser::detect_url`] plus notes, as [`UrlEngine::detect_url_scan`].+ fn detect_url_scan(&self, url: &str, options: &ScanOptions) -> Result<UrlScan, EngineError> {+ Ok(UrlScan { findings: self.detect_url(url, options)?, notes: Vec::new() })+ }fn close(&self);/// The eager half of `createBrowserDetector()`: bring the browser up now,/// so a launch failure is reported once before the loop and every URLdiff --git a/crates/hook/src/hook_lib.rs b/crates/hook/src/hook_lib.rsindex 76628c3e4..b6db5d989 100644--- a/crates/hook/src/hook_lib.rs+++ b/crates/hook/src/hook_lib.rs@@ -1631,6 +1631,7 @@ impl HookScanOptions {viewport: None,profile: None,rule_pack: None,+ keep_consent_banners: false,}}}diff --git a/docs/CLI-CONTRACT.md b/docs/CLI-CONTRACT.mdindex ec6527008..9234da819 100644--- a/docs/CLI-CONTRACT.md+++ b/docs/CLI-CONTRACT.md@@ -96,6 +96,7 @@ Notation: `stdout>` / `stderr>` are literal writes; `exit N`; template strings u| `--quiet` | text mode prints only summary line(s) to stderr || `--help` | print usage (stdout) and `exit 0` — evaluated *after* scope/viewport parsing (so a bad `--scope` still errors first) || `--no-advisory` | drop findings with `advisory === true` before output/exit-code |+| `--no-consent-hiding` | URL scans only (Rust engine): leave known consent managers' banners on the page instead of hiding them before the scan (see **Consent banners** under URL scans). No effect on file scans || `--fast` | deprecated, ignored; `stderr> Note: --fast is deprecated and ignored. The full scan is fast now and runs every rule.\n` || `--gpt`, `--gemini` | deprecated, ignored; `stderr> Note: --gpt and --gemini are deprecated and ignored. Generated-UI tells now run by default.\n` || `--no-config` | `configEnabled=false`: detectionConfig = `{ignoreRules:[],ignoreFiles:[],ignoreValues:[]}`; also disables design system and inline ignores |@@ -123,6 +124,9 @@ Options:--no-inline-ignores Do not honor in-file impeccable-disable* ignore comments--no-design-system Do not load local DESIGN.md / .impeccable/design.json context--no-advisory Suppress advisory findings entirely (e.g. em-dash overuse)+ --no-consent-hiding URL scans: keep known consent managers' banners+ (OneTrust, Cookiebot, ...) on the page instead of hiding+ them before the scan--help Show this help messageAdvisory findings:@@ -206,6 +210,7 @@ reports no findings and prints `stderr> Error: the page is ...`.- text: `stderr> formatFindings(all,false) + '\n'`.- `exit(hadOperationalFailure ? 1 : (primary.length > 0 ? 2 : 0))`.- no findings: json → `stdout> []\n`; text/quiet → nothing. `exit(hadOperationalFailure ? 1 : 0)`.+- Text mode (not `--json`, not `--quiet`) prints scan notes after the findings, or alone when there are none, one line each in first-seen order: the DESIGN.md purple note, and for a URL scan that hid consent banners `Hid the <names> consent banner(s) on <url> before scanning. Pass --no-consent-hiding to scan it.` (`<names>` joined `A, B and C`).- Exit 1 takes precedence over exit 2: findings from the targets that did scando not turn a partial scan into a complete one (#711).- Any other exit: `1` for arg errors above; uncaught exceptions propagate to `cli.js` catch (`exit 1`).@@ -248,7 +253,7 @@ Example (non-TTY):{ antipattern: id, name: ap.name, description: ap.description, severity: ap.severity || 'warning', category: ap.category || null, file: filePath, line, snippet }// plus, only when the effective severity is 'advisory': advisory: true```-Optional keys added later by engines (appended after the above): `ignoreValue` (design-system rules; browser findings with a value), `importedBy` (dir scans), `selector` and `thirdParty` (URL scans, below), `severity` may be overwritten by per-finding promotion (browser & html-patterns, e.g. pulsing dot in a header). Design-system findings are `{...finding(...), ...extras}` where extras = `{ ignoreValue }`. Static-HTML and browser findings have `line: 0`; regex findings have 1-based lines. `severity` values in registry: `'warning'` (default), `'advisory'` (many generated-UI tells and design-system-color/radius/font-size, numbered-section-labels, blinking-cursor, shape-assembled-illustration, layout-transition, bounce-easing), `'error'` (`script-error`, `content-hidden-at-rest`). Per-finding demotions to `'advisory'` in the Rust engine: `flat-type-hierarchy` when weight separates the roles (below), and a `script-error` an ad-tech script threw (URL scans). `severity` is the canonical advisory field (#709): `deriveAdvisoryFlag` stamps `advisory: true` when and only when the effective severity is `'advisory'`, so a per-finding promotion or demotion carries the flag with it, and every `severity:'advisory'` rule is partitioned out of the failure count and the exit code. `isAdvisory` accepts either `finding.advisory === true` or `finding.severity === 'advisory'`.+Optional keys added later by engines (appended after the above): `ignoreValue` (design-system rules; browser findings with a value), `importedBy` (dir scans), `selector`, `thirdParty` and `consentHidden` (URL scans, below), `severity` may be overwritten by per-finding promotion (browser & html-patterns, e.g. pulsing dot in a header). Design-system findings are `{...finding(...), ...extras}` where extras = `{ ignoreValue }`. Static-HTML and browser findings have `line: 0`; regex findings have 1-based lines. `severity` values in registry: `'warning'` (default), `'advisory'` (many generated-UI tells and design-system-color/radius/font-size, numbered-section-labels, blinking-cursor, shape-assembled-illustration, layout-transition, bounce-easing), `'error'` (`script-error`, `content-hidden-at-rest`). Per-finding demotions to `'advisory'` in the Rust engine: `flat-type-hierarchy` when weight separates the roles (below), and a `script-error` an ad-tech script threw (URL scans). `severity` is the canonical advisory field (#709): `deriveAdvisoryFlag` stamps `advisory: true` when and only when the effective severity is `'advisory'`, so a per-finding promotion or demotion carries the flag with it, and every `severity:'advisory'` rule is partitioned out of the failure count and the exit code. `isAdvisory` accepts either `finding.advisory === true` or `finding.severity === 'advisory'`.**Categories**: `category` is `'slop'` (AI tells) or `'quality'`. Category has **no effect on output**, ordering, or exit codes; it is only carried in the finding and used by `getRulesForCategory`. Registry (58 ids, in order): side-tab, border-accent-on-rounded, overused-font, flat-type-hierarchy, gradient-text, ai-color-palette, cream-palette, nested-cards, monotonous-spacing, bounce-easing, pulsing-dot, blinking-cursor, shape-assembled-illustration, dark-glow, radial-halo, radial-spotlight-glow, marquee, icon-tile-stack, italic-serif-display, hero-eyebrow-chip, kicker-above-heading, numbered-section-labels, em-dash-overuse, marketing-buzzword, aphoristic-cadence, oversized-h1, extreme-negative-tracking, broken-image, script-error, content-hidden-at-rest, edge-flush-cards, text-occlusion, first-viewport-column-overflow, gray-on-color, low-contrast, layout-transition, line-length, cramped-padding, body-text-viewport-edge, tight-leading, skipped-heading, heading-rhythm, justified-text, tiny-text, undersized-ui-text, all-caps-body, wide-tracking, text-overflow, repeated-container-text, clipped-overflow-container, design-system-font, design-system-color, design-system-radius, design-system-font-size, gpt-thin-border-wide-shadow, repeating-stripes-gradient, codex-grid-background, theater-slop-phrase. Scopes: `type` = overused-font, flat-type-hierarchy, italic-serif-display, hero-eyebrow-chip, kicker-above-heading, numbered-section-labels, oversized-h1, extreme-negative-tracking, line-length, tight-leading, skipped-heading, heading-rhythm, justified-text, tiny-text, undersized-ui-text, all-caps-body, wide-tracking, design-system-font, design-system-font-size; `layout` = nested-cards, monotonous-spacing, icon-tile-stack, content-hidden-at-rest, edge-flush-cards, text-occlusion, first-viewport-column-overflow, line-length, cramped-padding, body-text-viewport-edge, heading-rhythm, text-overflow, clipped-overflow-container. `RULE_ENGINE_SUPPORT = { regex: Set['source','page-analyzer'], 'static-html': Set['element','page'], browser: Set['element','page','layout'], visual: Set['visual-contrast'] }`.@@ -344,6 +349,8 @@ Optional keys added later by engines (appended after the above): `ignoreValue` (- **Purple headings in the brand hue** (corpus decision r3-23-ai-color-palette-brand-hue). The heading forms of `ai-color-palette` (a snippet ending ` on heading`) do not report when the heading's computed `color` is within 12 degrees of hue of a brand surface on the same page: the solid `background-color` (alpha at least 0.9, chroma at least 50, no gradient painted over it) of the logo (an element whose `id`, `class`, `alt` or `aria-label` contains `logo`; its text colour too when it has text of its own), the nav bar (`nav`, `header`, `role=navigation|banner`, at least half the viewport wide), or a band across the page (at least 90% of the viewport's width) covering a fifth of the viewport's area or more. Headings are never brand surfaces, and the gradient and neon forms keep reporting: purple that shows up only in headings and gradients is the tell. URL engine only (the static engine has no rendered page to read surfaces from).- **Contrast ratios in snippets.** Every `low-contrast` producer (the element text path shared by both engines, which covers links, spans and placeholders, the static engine's `:hover state`, and the URL engine's `browser contrast` sampling and `pixel contrast` passes, verdict and median) prints a ratio against its threshold: one decimal; two when one decimal would round a failing ratio up to the threshold; and those two cut, not rounded, when rounding them would reach it too. A ratio under the bar never prints as the bar: `4.49:1 (need 4.5:1)`, never `4.5:1` or `4.50:1`. A ratio at or above the threshold, such as a median over it, prints one decimal.- **Page validity gate.** After `goto` (and settle), before injecting anything, the engine classifies the page (`crates/browser/src/validity.rs`) from the main document's final CDP response and an in-page probe (title, visible text length, final URL, challenge-widget markers). Challenge: an `x-amzn-waf-action` header, `cf-mitigated: challenge`, a final URL on a challenge-only host (`perfdrive.com`, `captcha-delivery.com`), or, on a page with at most 3000 characters of visible text, a challenge title prefix ("Just a moment", "Attention Required! | Cloudflare", "Human Verification", "Access Denied", "Radware Bot Manager", "Captcha", ...) or a full-page widget marker (Cloudflare challenge form, PerimeterX, DataDome, Imperva, Akamai, AWS WAF, slider captchas). HTTP error: a final status >= 400 with no challenge signal. A blocked page throws `the page is a bot challenge, not the site (<signals>). Findings would describe the challenge page, so none are reported.` or `the page returned an error (HTTP <status>). Findings would describe the error page, so none are reported.`, which the CLI prints as `Error: ...` and counts as an operational failure (exit 1). A `file://` load has no response, so only the probe signals apply.+ Consent wall: a page with at most 3000 characters of visible text where a known consent manager (next item) is showing, fewer than 100 visible characters lie outside its roots, and the manager holds at least three times as many. It throws `the page is a consent wall, not the site (consent manager <names>, <n> of <total> visible characters outside it). Findings would describe the consent dialog, so none are reported.` The probe runs before any banner is hidden, and the gate applies with `--no-consent-hiding` too. The probe object (evidence) carries `consent` (the names of the managers showing) and `consentChars`.+ - **Consent banners** (Rust engine). A consent banner covers copy a visitor reads once they dismiss it: text under it was skipped as covered or scored against the banner, and the banner's own text was scored as the site's. After the validity gate and again after the reveal sweep (so a banner injected after load or on the first scroll is caught before the capture), the engine hides the roots and backdrops of the consent managers in `crates/browser/src/consent.rs`: OneTrust, Cookiebot, Usercentrics, TrustArc, Didomi, Quantcast Choice, Sourcepoint, Osano, the open-source Cookie Consent library, CookieYes, Complianz, iubenda, Termly, Axeptio, Borlabs Cookie, Klaro, Cookie Notice, Shopify's privacy banner, and Google Funding Choices. Selectors are the vendor's own ids and classes, never a generic word, so a notice a site wrote for itself stays on the page and is scanned. Hiding is one injected `<style id="impeccable-consent-hide">` of `display: none !important` rules (plus an inline `display: none !important` on a matched element whose own inline style outranks the rule); nothing is clicked and no cookie or consent state is set. The scroll lock is undone only where the manager applied it: its own lock classes on `<html>` / `<body>` (Didomi `didomi-popup-open`, Sourcepoint `sp-message-open`) are removed, and an inline `overflow` / `overflow-y: hidden` on `<html>` or `<body>` is removed only while that manager's backdrop was showing. Every pass, the hit tests, and the evidence screenshot see the page without the banner (a last hide runs before the screenshot). Findings from a scan that hid a showing banner carry `consentHidden: ["<name>", ...]` (after `thirdParty`), and text mode prints the note above. `--no-consent-hiding` turns all of it off. The evidence API (`detect_url_evidence`) leaves the findings untagged, so they replay equal, and records `Evidence.consent`: `{ hidden, matched: { <name>: [selectors] }, unlocked }`. The static (file) engine is unaffected.- **What the visual pass refuses to read.** The JS reported whatever its sampling produced; the engine says nothing where the reading is not the text's own background. The candidate collector applies the element pass's text gates before a candidate takes one of the `maxCandidates` slots, is sampled, or is scrolled into view: text with no letter and no digit (`◯`, `{ }`, `/`) as well as emoji-only text; a disabled control (`[disabled]`, `[aria-disabled="true"]`); a computed font size under 1px; a `color` at alpha 0.02 or less, or a transparent `-webkit-text-fill-color`, unless the element clips its own background to its text; and an element the painted-at-capture predicate (`crates/core/src/browser/painted.rs`, text gate) says is not painted, such as a tab-strip cell past its clipping edge or a carousel slide parked beside the page. A background image read as a surface has to be under the text: an image drawn `no-repeat` (from the computed `background` shorthand's first layer) whose painted rect, at a `background-size` the capture can place (pixels, percentages, `cover`, or any size once the image's intrinsic size is loaded), covers neither the candidate's text box nor its own box (`body` and `html` are asked only about the text) ends the walk `background image does not cover the text` (`stop`), whether or not the pass could load the file. An icon sprite framing a count and a mark beside a button label are refused this way; a repeating tile and a placement the capture cannot state are read as before. In the stack walk (`impeccable_core::browser::visual`): a translucent surface no longer restarts the walk at its own parent (which re-entered the stack above the node it came from and composited that surface over itself until its alpha read as opaque, and which skipped siblings painted between the surface and that parent) — the walk keeps descending the one `elementsFromPoint` stack, collecting translucent surfaces until an opaque one grounds them, then composites them back in order (topmost surface still names the method, `...+alpha`); a walk that reaches the end of the stack with nothing opaque is unresolved rather than reporting the last translucent color as a surface. A gradient answers analytically only when its stops agree: any stop below 0.95 alpha (a scrim, a glow, a `from-x/10` wash composites differently at every point of the box) or two opaque stops more than 2× apart in contrast make it `gradient stops disagree`, and an `svg` in the stack makes it `<tag> paint`; both end the walk (`stop`) rather than letting the nodes under them answer for the text, so the candidate falls to the screenshot pass. In the screenshot flow: a candidate whose reasons include `background-clip text`, `filter`, or `backdrop filter` is refused before the two screenshots are taken; the verdict is the median over the *glyph cores* (channel delta ≥ 90% of the strongest delta in the box, ≥ 8 of them; when fewer than 8 pixels reach 90%, as on small or thin text, the pixels from 75% up) rather than the tenth percentile over every changed pixel, which antialiased edges drive to 1:1; and the pass reports nothing when the diff is not a glyph over its background — more than 55% of the clip changed (the page repainted), more than a quarter of the changed pixels moved the opposite way from the rest (text mid-animation leaves its old position and its new one in the same diff), most fully painted pixels are not the color the text declares (`preferRenderedForeground` aside, where the painted value *is* the claim), the surface under the glyphs stands 2:1 or further from the surface beside them in the same box (the page paints its own text twice, so hiding one copy leaves the other where the glyphs were), or the median of every measured pixel is more than 3× the verdict (the sample is two populations, not one surface). The snippet shape is unchanged. `median` in it is the median over the same glyph cores the verdict reads, so it prints the verdict's number and never reads below it (it used to be the median over every changed pixel, edges included, which printed verdicts above their own median such as `pixel contrast 3.5:1 median 1.7:1`). The median over every changed pixel still decides the bimodal refusal above, but it is not printed.- **Viewport edges and overflow.** `body-text-viewport-edge` reports a gutter under 16px, or under 12px when `innerWidth` is 480px or less. A paragraph whose measured text runs past a side of the viewport (the distance rounds below 0) reports no gutter on that side; it still reports a gutter from 0px to the floor on the other side (`(left 8px)`). Those paragraphs, through the same gates plus the Text paint gate and inline ignores, report once per page instead: one `body-text-viewport-edge` finding attributed to the page (`selector` `body`, in `pageLevel`) on the side the furthest text reaches. The message follows what the page does. It reads `text runs past the <side> edge of the <vw>px viewport and is cut off: <name> reaches <d>px past it, with text in <n> block(s)` when the text is cut off: the viewport clips x overflow (the root's `overflow-x`, or body's when the root's is `visible`, at `hidden` or `clip`), the side is not the one the page scrolls to (right, or left under `direction: rtl`), the root's recorded `scrollWidth` does not exceed its `clientWidth` by more than 1px, or for every paragraph on that side a box at `overflow-x: hidden` or `clip` (the paragraph or an ancestor below the body, with its own edge on that side inside the viewport) is passed by the text. `<name>` is then the box reaching furthest among the paragraphs and their ancestors. Otherwise it reads `page scrolls sideways at <vw>px: <name> reaches <d>px past the <side> edge, and text in <n> block(s) runs past it`, where `<name>` is the box reaching furthest past that side among those no ancestor below the root clips or scrolls on x and not `position: fixed`, and no further than the page scrolls (ties go to the outer box). When the engine cannot tell (nothing it can see clips the text and the root recorded no `scrollWidth`) the sideways wording stands and `<name>` is the box reaching furthest among the paragraphs and their ancestors. In both wordings the paragraph itself is named when its text reaches further than any such box. `<name>` is the element's `class_selector`, except that a `div` with no class is named `div#<id>`, else `div in <tag>#<id>` or `div in <tag>.<class>` (at most three classes) after its nearest ancestor below the body with an id or a class, else `div ("<text>")` with up to 40 characters of its text, cut at a word and ended with `…` when cut, double quotes in the text written as `'`. `text-overflow` reports a spill only when it does harm: a box at `overflow-x: hidden` or `clip` (the element itself or an ancestor below the body, with area) is passed by the spill's reach, the spill reaches within a quarter em of the viewport's side or past it, or the spilled part comes within a quarter em of another element's text or painted box on the element's lines (not an ancestor or descendant, not a box that holds the element's whole box, and not a decoration layer: an absolutely or fixed positioned box with no text, other than a replaced element or an `svg`, that is 2px thick or less or paints only a plain fill, with no background image or border, at alpha times opacity under 0.25). The reach is the painted extent, or the scroll extent where that is taken as read; text that runs past its box into free space reports nothing.- `createBrowserDetector(options)`: shared browser, defaults `waitUntil:'load'`, `settleMs:100`, `viewport 1280x800`; `close()` closes only an owned browser.diff --git a/tests/fixtures/consent/cookiebot.html b/tests/fixtures/consent/cookiebot.htmlnew file mode 100644index 000000000..41f4bc6be--- /dev/null+++ b/tests/fixtures/consent/cookiebot.html@@ -0,0 +1,53 @@+<!DOCTYPE html>+<html lang="en">+<head>+ <meta charset="UTF-8">+ <meta name="viewport" content="width=device-width, initial-scale=1.0">+ <title>Consent hiding: a late Cookiebot-shaped dialog</title>+ <style>+ /* A Cookiebot-shaped dialog (its ids, not its script) the page injects+ late, on its first scroll, with the underlay Cookiebot lays behind a+ modal and the inline overflow: hidden a modal consent layer puts on+ <body>. The URL engine's second hide pass, after the reveal sweep,+ catches it: the copy under it reports, the dialog's own faint text does+ not, and the scroll lock is undone. Pinned by+ crates/browser/tests/consent_hiding.rs. */+ * { box-sizing: border-box; }+ body { font: 16px/1.5 system-ui, sans-serif; margin: 0; padding: 40px; color: #111; background: #fff; }+ .section { height: 900px; }+ .faint { position: absolute; top: 360px; left: 380px; width: 520px; margin: 0; font-size: 14px; line-height: 28px; color: #aaaaaa; }+ .cta { position: absolute; top: 420px; left: 380px; display: inline-block; padding: 8px 16px; border-radius: 6px;+ background: #ff7145; color: #ffffff; font-size: 15px; font-weight: 500; text-decoration: none; }+ #CybotCookiebotDialogBodyUnderlay { position: fixed; inset: 0; background: rgba(0, 0, 0, 0.6); z-index: 2147483630; }+ #CybotCookiebotDialog { position: fixed; top: 200px; left: 50%; width: 640px; margin-left: -320px; height: 360px;+ padding: 28px; border-radius: 8px; background: #ffffff; z-index: 2147483631; }+ #CybotCookiebotDialogBodyContentText { margin: 0 0 16px; font-size: 14px; color: #b0b0b0; }+ </style>+</head>+<body>+ <h1>A page with a late consent dialog</h1>+ <div class="section"><p>The first section.</p></div>+ <div class="section"><p>The second section.</p></div>+ <p class="faint" id="covered-copy">Faint copy the consent dialog covers.</p>+ <a href="#" class="cta" id="covered-cta">Book a demo</a>+ <script>+ // Cookiebot-style: the dialog arrives after load, here on the first scroll.+ let shown = false;+ window.addEventListener('scroll', () => {+ if (shown) return;+ shown = true;+ const underlay = document.createElement('div');+ underlay.id = 'CybotCookiebotDialogBodyUnderlay';+ const dialog = document.createElement('div');+ dialog.id = 'CybotCookiebotDialog';+ dialog.className = 'CybotCookiebotDialogActive';+ dialog.setAttribute('role', 'dialog');+ dialog.style.display = 'flex';+ dialog.innerHTML = '<div id="CybotCookiebotDialogBody"><p id="CybotCookiebotDialogBodyContentText">This website uses cookies to personalise content and to analyse our traffic.</p><button id="CybotCookiebotDialogBodyLevelButtonLevelOptinAllowAll" type="button">Allow all</button></div>';+ document.body.appendChild(underlay);+ document.body.appendChild(dialog);+ document.body.style.overflow = 'hidden';+ }, { passive: true });+ </script>+</body>+</html>diff --git a/tests/fixtures/consent/onetrust.html b/tests/fixtures/consent/onetrust.htmlnew file mode 100644index 000000000..faa13cfbe--- /dev/null+++ b/tests/fixtures/consent/onetrust.html@@ -0,0 +1,45 @@+<!DOCTYPE html>+<html lang="en">+<head>+ <meta charset="UTF-8">+ <meta name="viewport" content="width=device-width, initial-scale=1.0">+ <title>Consent hiding: a OneTrust-shaped banner</title>+ <style>+ /* A OneTrust-shaped banner (its ids and classes, not its script) fixed+ over the foot of the viewport. Under it sit a faint line of copy and a+ CTA, both real contrast failures a visitor meets once they dismiss the+ banner; inside it, the banner's own faint policy text. The URL engine+ hides the banner before the rule pass, so the page copy and CTA report+ and the policy text does not. With --no-consent-hiding the banner stays:+ the covered copy and CTA are not scored and the policy text is. Pinned+ by crates/browser/tests/consent_hiding.rs. */+ * { box-sizing: border-box; }+ body { font: 16px/1.5 system-ui, sans-serif; margin: 0; padding: 40px; color: #111; background: #fff; }+ .lead { max-width: 720px; }+ .faint { position: absolute; top: 700px; left: 80px; width: 520px; margin: 0; font-size: 14px; line-height: 28px; color: #aaaaaa; }+ .cta { position: absolute; top: 740px; left: 80px; display: inline-block; padding: 8px 16px; border-radius: 6px;+ background: #ff7145; color: #ffffff; font-size: 15px; font-weight: 500; text-decoration: none; }+ #onetrust-banner-sdk { position: fixed; left: 0; right: 0; bottom: 0; height: 170px; padding: 24px 40px;+ background: #ffffff; border-top: 1px solid #d0d7de; box-shadow: 0 -4px 16px rgba(0, 0, 0, 0.12); z-index: 2147483645; }+ #onetrust-policy-text { margin: 0 0 12px; max-width: 760px; font-size: 14px; color: #b0b0b0; }+ #onetrust-accept-btn-handler { padding: 8px 16px; border: 0; border-radius: 4px; background: #1f2937; color: #fff; font-size: 14px; }+ </style>+</head>+<body>+ <h1>A page under a OneTrust banner</h1>+ <p class="lead">The copy near the top of the page is readable and nothing covers it. A visitor reads it with the banner up,+ and reads the rest of the page once they have answered it.</p>+ <p class="faint" id="covered-copy">Faint copy the consent banner covers at load.</p>+ <a href="#" class="cta" id="covered-cta">Start free trial</a>++ <div id="onetrust-consent-sdk">+ <div class="onetrust-pc-dark-filter ot-hide ot-fade-in" style="display: none;"></div>+ <div id="onetrust-banner-sdk" class="otFlat bottom" role="region" aria-label="Cookie banner">+ <div id="onetrust-policy">+ <p id="onetrust-policy-text">We use cookies to measure visits and to improve the site. You can change your choices at any time.</p>+ </div>+ <button id="onetrust-accept-btn-handler" type="button">Accept all</button>+ </div>+ </div>+</body>+</html>diff --git a/tests/fixtures/consent/site-notice.html b/tests/fixtures/consent/site-notice.htmlnew file mode 100644index 000000000..7fe5eb3e6--- /dev/null+++ b/tests/fixtures/consent/site-notice.html@@ -0,0 +1,31 @@+<!DOCTYPE html>+<html lang="en">+<head>+ <meta charset="UTF-8">+ <meta name="viewport" content="width=device-width, initial-scale=1.0">+ <title>Consent hiding: a notice the site wrote itself</title>+ <style>+ /* A cookie notice the site wrote itself: generic class names ("cookie",+ "consent", "banner"), no known vendor. It is part of the site, so the+ URL engine leaves it on the page: the copy it covers is not scored and+ its own faint text is. Pinned by crates/browser/tests/consent_hiding.rs. */+ * { box-sizing: border-box; }+ body { font: 16px/1.5 system-ui, sans-serif; margin: 0; padding: 40px; color: #111; background: #fff; }+ .faint { position: absolute; top: 700px; left: 80px; width: 520px; margin: 0; font-size: 14px; line-height: 28px; color: #aaaaaa; }+ .cta { position: absolute; top: 740px; left: 80px; display: inline-block; padding: 8px 16px; border-radius: 6px;+ background: #ff7145; color: #ffffff; font-size: 15px; font-weight: 500; text-decoration: none; }+ .cookie-banner { position: fixed; left: 0; right: 0; bottom: 0; height: 170px; padding: 24px 40px;+ background: #ffffff; border-top: 1px solid #d0d7de; z-index: 50; }+ .cookie-banner p { margin: 0 0 12px; max-width: 760px; font-size: 14px; color: #b0b0b0; }+ </style>+</head>+<body>+ <h1>A page under the site's own cookie notice</h1>+ <p class="faint" id="covered-copy">Faint copy the site's notice covers.</p>+ <a href="#" class="cta" id="covered-cta">Start free trial</a>+ <div class="cookie-banner" id="cookie-consent" data-cookie-consent="true">+ <p id="notice-text">We use cookies to keep you signed in and to count visits.</p>+ <button type="button">Accept</button>+ </div>+</body>+</html>diff --git a/tests/fixtures/consent/wall.html b/tests/fixtures/consent/wall.htmlnew file mode 100644index 000000000..9b63037e9--- /dev/null+++ b/tests/fixtures/consent/wall.html@@ -0,0 +1,25 @@+<!DOCTYPE html>+<html lang="en">+<head>+ <meta charset="UTF-8">+ <meta name="viewport" content="width=device-width, initial-scale=1.0">+ <title>Consent hiding: a page that is only a consent wall</title>+ <style>+ /* A page whose only readable text is a OneTrust-shaped consent dialog.+ Hiding it would leave an empty page to report clean, so the validity+ gate refuses it as a consent wall. Pinned by+ crates/browser/tests/consent_hiding.rs. */+ body { font: 16px/1.5 system-ui, sans-serif; margin: 0; background: #f3f4f6; }+ #onetrust-pc-sdk { position: fixed; top: 80px; left: 50%; width: 640px; margin-left: -320px; padding: 32px; background: #fff; }+ </style>+</head>+<body>+ <div id="onetrust-consent-sdk">+ <div id="onetrust-pc-sdk" role="dialog" aria-label="Privacy preferences">+ <h2>Your privacy choices</h2>+ <p>We and our partners store and access information on your device, such as cookies, and process personal data such as unique identifiers and browsing data, to personalise content and advertising, to measure the performance of content and advertising, and to develop and improve our products. You can accept all of these purposes, reject them, or choose which ones you allow. Your choices apply to this site only and you can change them at any time from the privacy link in the footer.</p>+ <button type="button">Accept all</button> <button type="button">Reject all</button> <button type="button">Manage choices</button>+ </div>+ </div>+</body>+</html>diff --git a/tests/oracle/golden/detect-help.json b/tests/oracle/golden/detect-help.jsonindex 00b3c4bdb..65fe63e23 100644--- a/tests/oracle/golden/detect-help.json+++ b/tests/oracle/golden/detect-help.json@@ -1,5 +1,5 @@{- "stdout": "Usage: impeccable detect [options] [file-or-dir-or-url...]\n\nScan files or URLs for UI anti-patterns and design quality issues.\n\nOptions:\n --json Output results as JSON\n --quiet In text mode, only print the final findings count\n --scope <name> Only report rules in the given design domain\n (type, layout). Comma-separated.\n --viewport <WxH> Browser viewport for URL scans (default 1280x800),\n e.g. --viewport 390x844 for a mobile-width pass\n --no-config Do not apply project config, detector ignores, inline\n ignore comments, or DESIGN.md\n --no-inline-ignores Do not honor in-file impeccable-disable* ignore comments\n --no-design-system Do not load local DESIGN.md / .impeccable/design.json context\n --no-advisory Suppress advisory findings entirely (e.g. em-dash overuse)\n --help Show this help message\n\nAdvisory findings:\n Some rules are advisory: detected and listed in a separate section, but never\n counted as failures and never changing the exit code. They stay out of the\n failure count so they never block automation. --no-advisory hides them.\n\nOutput streams:\n Human-readable findings go to stderr so stdout stays available for structured\n output. Use --json for JSON on stdout, or redirect text with 2> findings.txt.\n\nExit status:\n 0 Scan completed with no primary findings (advisories may still be listed)\n 1 At least one requested target could not be scanned\n 2 Scan completed with primary findings\n Operational failure takes precedence when a multi-target scan is partial.\n\nProject config:\n Respects .impeccable/config.json and .impeccable/config.local.json detector\n settings: detector.ignoreRules, detector.ignoreFiles, detector.ignoreValues,\n and detector.designSystem.enabled.\n\nInline ignores:\n In-file comments waive a finding where it lives and travel with the file:\n <!-- impeccable-disable overused-font -- exported brand doc -->\n .brand { font-family: Inter } /* impeccable-disable-line overused-font */\n // impeccable-disable-next-line bounce-easing: intentional bounce\n impeccable-disable applies to the whole file; -line / -next-line are scoped.\n List one or more rule ids (comma-separated), or omit them / use * for all.\n\nDetection modes:\n HTML files Static HTML/CSS analysis (default, catches linked CSS)\n Non-HTML files Regex pattern matching (CSS, JSX, TSX, etc.)\n URLs Puppeteer full browser rendering (auto-detected;\n http(s):// and file:// URLs; accessible linked CSS included)\n\nExamples:\n impeccable detect src/\n impeccable detect index.html\n impeccable detect https://example.com\n impeccable detect --json .\n impeccable detect --no-config src/\n",+ "stdout": "Usage: impeccable detect [options] [file-or-dir-or-url...]\n\nScan files or URLs for UI anti-patterns and design quality issues.\n\nOptions:\n --json Output results as JSON\n --quiet In text mode, only print the final findings count\n --scope <name> Only report rules in the given design domain\n (type, layout). Comma-separated.\n --viewport <WxH> Browser viewport for URL scans (default 1280x800),\n e.g. --viewport 390x844 for a mobile-width pass\n --no-config Do not apply project config, detector ignores, inline\n ignore comments, or DESIGN.md\n --no-inline-ignores Do not honor in-file impeccable-disable* ignore comments\n --no-design-system Do not load local DESIGN.md / .impeccable/design.json context\n --no-advisory Suppress advisory findings entirely (e.g. em-dash overuse)\n --no-consent-hiding URL scans: keep known consent managers' banners\n (OneTrust, Cookiebot, ...) on the page instead of hiding\n them before the scan\n --help Show this help message\n\nAdvisory findings:\n Some rules are advisory: detected and listed in a separate section, but never\n counted as failures and never changing the exit code. They stay out of the\n failure count so they never block automation. --no-advisory hides them.\n\nOutput streams:\n Human-readable findings go to stderr so stdout stays available for structured\n output. Use --json for JSON on stdout, or redirect text with 2> findings.txt.\n\nExit status:\n 0 Scan completed with no primary findings (advisories may still be listed)\n 1 At least one requested target could not be scanned\n 2 Scan completed with primary findings\n Operational failure takes precedence when a multi-target scan is partial.\n\nProject config:\n Respects .impeccable/config.json and .impeccable/config.local.json detector\n settings: detector.ignoreRules, detector.ignoreFiles, detector.ignoreValues,\n and detector.designSystem.enabled.\n\nInline ignores:\n In-file comments waive a finding where it lives and travel with the file:\n <!-- impeccable-disable overused-font -- exported brand doc -->\n .brand { font-family: Inter } /* impeccable-disable-line overused-font */\n // impeccable-disable-next-line bounce-easing: intentional bounce\n impeccable-disable applies to the whole file; -line / -next-line are scoped.\n List one or more rule ids (comma-separated), or omit them / use * for all.\n\nDetection modes:\n HTML files Static HTML/CSS analysis (default, catches linked CSS)\n Non-HTML files Regex pattern matching (CSS, JSX, TSX, etc.)\n URLs Puppeteer full browser rendering (auto-detected;\n http(s):// and file:// URLs; accessible linked CSS included)\n\nExamples:\n impeccable detect src/\n impeccable detect index.html\n impeccable detect https://example.com\n impeccable detect --json .\n impeccable detect --no-config src/\n","stderr": "","exit": 0,"signal": null,