Librairie d'audit d'accessibilité

This commit is contained in:
wpetit 2020-08-10 15:15:32 +02:00
parent 7f2ef25102
commit f3e5f7b9ef
4 changed files with 24 additions and 6 deletions

View File

@ -3,6 +3,7 @@ W3AF_COMMAND ?=
LIGHTHOUSE_COMMAND ?= LIGHTHOUSE_COMMAND ?=
LIGHTHOUSE_URL ?= LIGHTHOUSE_URL ?=
PA11Y_URL ?= PA11Y_URL ?=
PA11Y_REPORTER ?=
image-w3af: image-w3af:
docker build \ docker build \
@ -71,6 +72,7 @@ pa11y:
-e http_proxy=$(http_proxy) \ -e http_proxy=$(http_proxy) \
-e https_proxy=$(https_proxy) \ -e https_proxy=$(https_proxy) \
-e PA11Y_URL='$(PA11Y_URL)' \ -e PA11Y_URL='$(PA11Y_URL)' \
-e PA11Y_REPORTER='$(PA11Y_REPORTER)' \
-u $(shell id -u $(USER)):$(shell id -g $(USER)) \ -u $(shell id -u $(USER)):$(shell id -g $(USER)) \
-v "$(PWD)/data/pa11y/reports:/home/pa11y/reports" \ -v "$(PWD)/data/pa11y/reports:/home/pa11y/reports" \
$(DOCKER_ARGS) \ $(DOCKER_ARGS) \

View File

@ -35,7 +35,7 @@ RUN apk add --no-cache \
chromium \ chromium \
bash bash
RUN PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=1 npm install -g pa11y@next pa11y-reporter-html RUN PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=1 npm install -g pa11y pa11y-reporter-html@^1.0.0 pa11y-reporter-junit
RUN adduser -D pa11y RUN adduser -D pa11y

View File

@ -1,7 +1,5 @@
#!/bin/bash #!/bin/bash
set -x
envtpl -o patty.json /home/pa11y/patty.json.tmpl envtpl -o patty.json /home/pa11y/patty.json.tmpl
mkdir -p reports mkdir -p reports
@ -17,4 +15,4 @@ pa11y \
--include-warnings \ --include-warnings \
--include-notices \ --include-notices \
--reporter "${PA11Y_REPORTER}" \ --reporter "${PA11Y_REPORTER}" \
"$PA11Y_URL" > "pa11y.report.${PA11Y_REPORTER}" || exit 0 "$PA11Y_URL" || exit 0

View File

@ -1,6 +1,24 @@
def audit(url: String) { def audit(String url, Map params = [:]) {
def reporter = params.reporter ? params.reporter : 'html'
def pa11yImage = buildDockerImage()
def dockerArgs = """
-e PA11Y_REPORTER='${reporter}'
-e PA11Y_URL='${url}'
"""
pa11yImage.inside(dockerArgs) {
sh 'chown -R pa11y: ./'
def report = sh(
script: 'su pa11y - /usr/local/bin/run-audit',
returnStdout: true
)
return report
} }
}
def buildDockerImage() { def buildDockerImage() {
dir ('.pa11y') { dir ('.pa11y') {