2019-04-15 18:35:34 +02:00
|
|
|
// Pipeline de construction des images Docker des services Zéphir
|
|
|
|
def call() {
|
|
|
|
pipeline {
|
|
|
|
|
|
|
|
agent {
|
|
|
|
label 'common'
|
|
|
|
}
|
|
|
|
|
|
|
|
parameters {
|
|
|
|
string(
|
2019-04-15 20:50:20 +02:00
|
|
|
name: 'targetUrl',
|
|
|
|
description: 'URL cible pour l\'audit'
|
|
|
|
)
|
|
|
|
string(
|
|
|
|
name: 'basicAuthUsername',
|
|
|
|
description: "Nom d'utilisateur pour l'authentication 'Basic Auth' (si besoin)"
|
|
|
|
)
|
|
|
|
password(
|
|
|
|
name: 'basicAuthPassword',
|
|
|
|
description: "Mot de passe pour l'authentication 'Basic Auth' (si besoin)"
|
|
|
|
)
|
|
|
|
string(
|
|
|
|
name: 'basicAuthDomain',
|
|
|
|
description: "Nom de domaine pour l'authentication 'Basic Auth' (si besoin)"
|
|
|
|
)
|
|
|
|
string(
|
|
|
|
name: 'authFormUrl',
|
|
|
|
description: "URL du formulaire d'authentication (si besoin)"
|
|
|
|
)
|
|
|
|
string(
|
|
|
|
name: 'authFormUsername',
|
|
|
|
description: "Nom d'utilisateur du formulaire d'authentication (si besoin)"
|
|
|
|
)
|
|
|
|
password(
|
|
|
|
name: 'authFormPassword',
|
|
|
|
description: "Mot de passe du formulaire d'authentication (si besoin)"
|
|
|
|
)
|
|
|
|
string(
|
|
|
|
name: 'authFormCheckUrl',
|
|
|
|
description: "URL de vérification de la réussite de l'authentication (si besoin)"
|
|
|
|
)
|
|
|
|
string(
|
|
|
|
name: 'authFormCheckString',
|
|
|
|
description: "Chaine de caractères à rechercher pour vérifier la réussite de l'authentication (si besoin)"
|
|
|
|
)
|
|
|
|
string(
|
|
|
|
name: 'authFormDataFormat',
|
|
|
|
description: "Patron de formatage des données POST du formulaire d'authentification (si besoin). Exemple: username=%U&password=%P"
|
2019-04-15 18:35:34 +02:00
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
stages {
|
|
|
|
|
|
|
|
stage("Check parameters") {
|
|
|
|
steps {
|
|
|
|
script {
|
|
|
|
if (!params.url?.trim()) {
|
2019-04-15 20:50:20 +02:00
|
|
|
error("L'URL cible n'est pas définie !")
|
2019-04-15 18:35:34 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
stage("Test URL") {
|
|
|
|
steps {
|
|
|
|
script {
|
|
|
|
def w3afImage = buildDockerImage()
|
|
|
|
def dockerArgs = """
|
2019-04-15 20:50:20 +02:00
|
|
|
-e W3AF_TARGET='${params.targetUrl}'
|
|
|
|
-e W3AF_BASIC_AUTH_USERNAME='${params.basicAuthUsername}'
|
|
|
|
-e W3AF_BASIC_AUTH_PASSWORD='${params.basicAuthPassword}'
|
|
|
|
-e W3AF_BASIC_AUTH_DOMAIN='${params.basicAuthDomain}'
|
|
|
|
-e W3AF_AUTH_FORM_URL='${params.authFormUrl}'
|
|
|
|
-e W3AF_AUTH_FORM_USERNAME='${params.authFormUsername}'
|
|
|
|
-e W3AF_AUTH_FORM_PASSWORD='${params.authFormPassword}'
|
|
|
|
-e W3AF_AUTH_FORM_CHECK_URL='${params.authFormCheckUrl}'
|
|
|
|
-e W3AF_AUTH_FORM_CHECK_STRING='${params.authFormCheckString}'
|
|
|
|
-e W3AF_AUTH_FORM_DATA_FORMAT='${params.authFormDataFormat}'
|
2019-04-15 18:35:34 +02:00
|
|
|
"""
|
|
|
|
w3afImage.inside(dockerArgs) {
|
2019-04-15 20:50:20 +02:00
|
|
|
sh 'mkdir reports'
|
|
|
|
sh 'envtpl -o audit.w3af audit.w3af.tmpl'
|
|
|
|
sh './w3af_console -y -n -s audit.w3af'
|
2019-04-15 18:35:34 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-04-15 20:50:20 +02:00
|
|
|
post {
|
|
|
|
always {
|
|
|
|
publishHTML target: [
|
|
|
|
allowMissing: true,
|
|
|
|
alwaysLinkToLastBuild: false,
|
|
|
|
keepAll: true,
|
|
|
|
reportDir: 'reports',
|
|
|
|
reportFiles: 'report.html',
|
|
|
|
reportName: "Rapport d'audit"
|
|
|
|
]
|
|
|
|
}
|
|
|
|
failure {
|
|
|
|
// wrap([$class: 'BuildUser']) {
|
|
|
|
// rocketSend (
|
|
|
|
// avatar: 'https://jenkins.cadol.es/static/b5f67753/images/headshot.png',
|
|
|
|
// message: """
|
|
|
|
// Le test de sécurité pour `${params.targetUrl}` a échoué:
|
2019-04-15 18:35:34 +02:00
|
|
|
|
2019-04-15 20:50:20 +02:00
|
|
|
// [Voir le job](${env.RUN_DISPLAY_URL})
|
2019-04-15 18:35:34 +02:00
|
|
|
|
2019-04-15 20:50:20 +02:00
|
|
|
// @${env.BUILD_USER_ID ? env.BUILD_USER_ID : 'here'}
|
|
|
|
// """.stripIndent(),
|
|
|
|
// rawMessage: true
|
|
|
|
// )
|
|
|
|
// }
|
|
|
|
}
|
|
|
|
}
|
2019-04-15 18:35:34 +02:00
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
def buildDockerImage() {
|
|
|
|
dir ('.w3af') {
|
|
|
|
def dockerfile = libraryResource 'com/cadoles/w3af/Dockerfile'
|
|
|
|
writeFile file:'Dockerfile', text:dockerfile
|
|
|
|
|
|
|
|
def audit = libraryResource 'com/cadoles/w3af/audit.w3af'
|
|
|
|
writeFile file:'audit.w3af', text:audit
|
|
|
|
|
|
|
|
def safeJobName = URLDecoder.decode(env.JOB_NAME).toLowerCase().replace('/', '-').replace(' ', '-')
|
|
|
|
def imageTag = "${safeJobName}-${env.BUILD_ID}"
|
|
|
|
return docker.build("w3af:${imageTag}", ".")
|
|
|
|
}
|
|
|
|
}
|