diff --git a/.github/actions/find/README.md b/.github/actions/find/README.md index 0a0be1f..651babf 100644 --- a/.github/actions/find/README.md +++ b/.github/actions/find/README.md @@ -35,6 +35,10 @@ configuration option. [`colorScheme`](https://playwright.dev/docs/api/class-browser#browser-new-context-option-color-scheme) configuration option. +#### `ignore_https_errors` + +**Optional** Bool - whether to ignore HTTPS errors when scanning URLs with self-signed certificates. + #### `include_screenshots` **Optional** Bool - whether to capture screenshots of scanned pages and include links to them in the issue diff --git a/.github/actions/find/action.yml b/.github/actions/find/action.yml index 6662d86..9edff45 100644 --- a/.github/actions/find/action.yml +++ b/.github/actions/find/action.yml @@ -25,6 +25,11 @@ inputs: color_scheme: description: 'Playwright colorScheme setting: https://playwright.dev/docs/api/class-browser#browser-new-context-option-color-scheme' required: false + ignore_https_errors: + description: 'Whether to ignore HTTPS errors when scanning URLs with self-signed certificates' + required: false + default: 'false' + outputs: findings_file: description: 'Path to a JSON file containing the list of potential accessibility gaps' diff --git a/.github/actions/find/src/findForUrl.ts b/.github/actions/find/src/findForUrl.ts index 14c4e30..ebbf0b5 100644 --- a/.github/actions/find/src/findForUrl.ts +++ b/.github/actions/find/src/findForUrl.ts @@ -23,6 +23,7 @@ export async function findForUrl( includeScreenshots: boolean = false, reducedMotion?: ReducedMotionPreference, colorScheme?: ColorSchemePreference, + ignoreHttpsErrors: boolean = false, ): Promise { const {url, excludeSelectors, waitForSelectors} = urlConfig const browser = await playwright.chromium.launch({ @@ -33,6 +34,7 @@ export async function findForUrl( ...(authContext?.toPlaywrightBrowserContextOptions() ?? {}), ...(reducedMotion ? {reducedMotion} : {}), ...(colorScheme ? {colorScheme} : {}), + ...(ignoreHttpsErrors ? {ignoreHTTPSErrors: true} : {}), } let context: playwright.BrowserContext | undefined try { diff --git a/.github/actions/find/src/index.ts b/.github/actions/find/src/index.ts index 138307c..836161a 100644 --- a/.github/actions/find/src/index.ts +++ b/.github/actions/find/src/index.ts @@ -11,6 +11,7 @@ export default async function () { const urls = loadUrls({urlConfigs}) const reducedMotion = loadReducedMotion() const colorScheme = loadColorScheme() + const ignoreHttpsErrors = loadIgnoreHttpsErrors() const actualUrls = urlConfigs || urls || [] @@ -22,7 +23,14 @@ export default async function () { for (const urlConfig of actualUrls) { const {url} = urlConfig core.info(`Preparing to scan ${url}`) - const findingsForUrl = await findForUrl(urlConfig, authContext, includeScreenshots, reducedMotion, colorScheme) + const findingsForUrl = await findForUrl( + urlConfig, + authContext, + includeScreenshots, + reducedMotion, + colorScheme, + ignoreHttpsErrors, + ) if (findingsForUrl.length === 0) { core.info(`No accessibility gaps were found on ${url}`) continue @@ -108,3 +116,7 @@ function loadColorScheme() { return colorSchemeInput as ColorSchemePreference } + +function loadIgnoreHttpsErrors() { + return core.getInput('ignore_https_errors', {required: false}).toLowerCase() === 'true' +} diff --git a/.github/actions/find/tests/findForUrl.test.ts b/.github/actions/find/tests/findForUrl.test.ts index a8de52e..387e236 100644 --- a/.github/actions/find/tests/findForUrl.test.ts +++ b/.github/actions/find/tests/findForUrl.test.ts @@ -392,4 +392,35 @@ describe('findForUrl', () => { expect(await categoryFor(['wcag2a', 'experimental'])).toBe('experimental') }) }) + + describe('when ignoreHttpsErrors is enabled', () => { + it('forwards ignoreHTTPSErrors to the browser context', async () => { + actionInput = '' + clearAll() + + await findForUrl({url: 'test.com'}, undefined, false, undefined, undefined, true) + + expect(playwrightMocks.browserNewContext).toHaveBeenCalledWith({ignoreHTTPSErrors: true}) + }) + }) + + describe('when ignoreHttpsErrors is not enabled', () => { + it('does not forward ignoreHTTPSErrors by default', async () => { + actionInput = '' + clearAll() + + await findForUrl({url: 'test.com'}) + + expect(playwrightMocks.browserNewContext).toHaveBeenCalledWith({}) + }) + + it('does not forward ignoreHTTPSErrors when explicitly disabled', async () => { + actionInput = '' + clearAll() + + await findForUrl({url: 'test.com'}, undefined, false, undefined, undefined, false) + + expect(playwrightMocks.browserNewContext).toHaveBeenCalledWith({}) + }) + }) }) diff --git a/README.md b/README.md index 5fac654..f374ec4 100644 --- a/README.md +++ b/README.md @@ -61,6 +61,7 @@ jobs: # dry_run: false # Optional: Set to true to scan and log what would be filed without creating/closing issues or writing the cache # reduced_motion: no-preference # Optional: Playwright reduced motion configuration option # color_scheme: light # Optional: Playwright color scheme configuration option + # ignore_https_errors: false # Optional: Set to true to ignore HTTPS errors when scanning URLs with self-signed certificates # scans: '["axe","accesslint","reflow-scan"]' # Optional: An array of scans (or plugins) to be performed. Built-in engines are 'axe' and 'accesslint'; any other entry is a plugin name. If not provided, only Axe will be performed. # url_configs: '[{"url":"https://example.com","excludeSelectors":["iframe","#widget"],"waitForSelectors":["#app","[data-ready]"]}]' # Optional: Per-URL config with CSS selectors to exclude from Axe or wait for before scanning. When provided, takes precedence over 'urls'. ``` @@ -137,6 +138,7 @@ Trigger the workflow manually or automatically based on your configuration. The | `file_experimental_issues` | No | Whether to file issues for experimental findings (checks that are not yet stable). Set to `false` to suppress new experimental issues; existing ones are left untouched. Default: `true` | `false` | | `reduced_motion` | No | Playwright `reducedMotion` setting for scan contexts. Allowed values: `reduce`, `no-preference` | `reduce` | | `color_scheme` | No | Playwright `colorScheme` setting for scan contexts. Allowed values: `light`, `dark`, `no-preference` | `dark` | +| `ignore_https_errors` | No | Whether to ignore HTTPS errors when scanning URLs with self-signed certificates. Default: `false` | `true` | | `scans` | No | An array of scans (or plugins) to be performed. Built-in engines are `axe` and `accesslint`; any other entry is treated as a plugin name. If not provided, only Axe will be performed. | `'["axe", "accesslint", ...other plugins]'` | | `dry_run` | No | When `true`, scan and log the issues that _would_ be filed without opening, closing, reopening, or assigning any issues — and without writing to the `gh-cache` branch. Useful for safely previewing results. Default: `false` | `true` | | `url_configs` | No | A stringified JSON array of URL config objects. Each object must have a `url` field and may have `excludeSelectors` (selectors to exclude from Axe) and `waitForSelectors` (selectors that must become visible within 30 seconds before scanning). When provided, takes precedence over the `urls` input. | `'[{"url":"https://example.com","excludeSelectors":["iframe","#widget"],"waitForSelectors":["#app"]}]'` | diff --git a/action.yml b/action.yml index 56b4160..525d021 100644 --- a/action.yml +++ b/action.yml @@ -63,6 +63,10 @@ inputs: color_scheme: description: 'Playwright colorScheme setting: https://playwright.dev/docs/api/class-browser#browser-new-context-option-color-scheme' required: false + ignore_https_errors: + description: 'Whether to ignore HTTPS errors when scanning URLs with self-signed certificates' + required: false + default: 'false' scans: description: "Stringified JSON array of scans to perform. Core engines and local plugins use string names. Allowlisted NPM plugins use an object with 'name', 'package', and optional 'version'. If not provided, only Axe will be performed" required: false @@ -133,6 +137,7 @@ runs: include_screenshots: ${{ inputs.include_screenshots }} reduced_motion: ${{ inputs.reduced_motion }} color_scheme: ${{ inputs.color_scheme }} + ignore_https_errors: ${{ inputs.ignore_https_errors }} scans: ${{ inputs.scans }} - name: File id: file