-
Notifications
You must be signed in to change notification settings - Fork 205
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into feature/scripting-yaml-config
# Conflicts: # .gitignore
- Loading branch information
Showing
12 changed files
with
201 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,4 +8,4 @@ bin/ | |
.settings/ | ||
.env | ||
.DS_Store | ||
*.iml | ||
*.iml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
FROM openjdk:11.0.10-jdk-slim | ||
FROM openjdk:11.0-jdk-slim | ||
|
||
RUN mkdir /javavulny /app | ||
COPY . /javavulny/ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
# HawkScan Scanning in Azure Pipelines | ||
# This is a demonstration of running JavaSpringVulny (a web applications) in azure-pipelines (a cicd pipeline) with the StackHawk extension (DAST testing) | ||
# https://marketplace.visualstudio.com/items?itemName=StackHawk.stackhawk-extensions | ||
# https://github.com/kaakaww/javaspringvulny | ||
# https://aka.ms/yaml | ||
|
||
# matrix builds for different build systems | ||
# use `condition: eq(variables['imageName'], 'ubuntu-latest')` property to filter tasks for specific operating systems | ||
strategy: | ||
matrix: | ||
windows-msi: | ||
imageName: "windows-latest" | ||
installerType: "msi" | ||
windows-zip: | ||
imageName: "windows-latest" | ||
installerType: "zip" | ||
linux-zip: | ||
imageName: "ubuntu-latest" | ||
installerType: "zip" | ||
windows-auto: | ||
imageName: "windows-latest" | ||
installerType: "auto" | ||
linux-auto: | ||
imageName: "ubuntu-latest" | ||
installerType: "auto" | ||
|
||
pool: | ||
vmImage: $(imageName) | ||
|
||
trigger: | ||
- main | ||
|
||
steps: | ||
- checkout: self | ||
|
||
- script: echo Azure Pipelines build for $(imageName)! | ||
displayName: "🦅 $(imageName)" | ||
|
||
# install the latest version of hawkscan | ||
- task: HawkScanInstall@1 | ||
inputs: | ||
version: "latest" | ||
installerType: "$(installerType)" | ||
|
||
# docker-compose starts the postgres database on linux os's, not on windows | ||
- task: DockerCompose@0 | ||
displayName: Start JavaSpringVulny on linux with docker-compose | ||
condition: eq(variables['imageName'], 'ubuntu-latest') | ||
inputs: | ||
containerregistrytype: "Azure Container Registry" | ||
dockerComposeFile: docker-compose.yml | ||
action: Run services | ||
|
||
# specific path replacement for in-memory database on windows in azure-pipelines | ||
- powershell: | | ||
$file = 'src/main/resources/application.properties' | ||
$find = 'spring.datasource.url=jdbc:h2:file:${PWD}/db/vulny;' | ||
$replace = "spring.datasource.url=jdbc:h2:file:D:\\a\\1\\db\\vulny;" | ||
(Get-Content $file).replace($find, $replace) | Set-Content $file | ||
condition: eq(variables['imageName'], 'windows-latest') | ||
displayName: Configure JavaSpringVulny for windows | ||
# azure pipelines default jdk is 8, so we upgrade to 11 to run JavaSpringVulny | ||
# the hawkscan msi bundles java with it, so this step isn't necesarry for running HawkScan | ||
- task: JavaToolInstaller@0 | ||
inputs: | ||
versionSpec: "11" | ||
jdkArchitectureOption: "x64" | ||
jdkSourceOption: "PreInstalled" | ||
|
||
# start javaspringVulny in the background | ||
- powershell: | | ||
start-process ./gradlew.bat bootRun | ||
displayName: Start JavaSpringVulny on windows with gradle in the background | ||
condition: eq(variables['imageName'], 'windows-latest') | ||
# run hawkscan with the StackHawk Azure Extension | ||
- task: RunHawkScan@1 | ||
inputs: | ||
configFile: "stackhawk.yml" | ||
version: "latest" | ||
env: | ||
HAWK_API_KEY: $(HAWK_API_KEY) # use variables in the azure devops ui to configure secrets and env vars | ||
APP_ENV: $(imageName) | ||
APP_ID: $(APP_ID) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
#!/usr/bin/env bash | ||
|
||
# Request login (XLOGINID) and session (JSESSIONID) cookies from server | ||
curl -k -c cookie-jar.txt https://localhost:9000/login-code | ||
# Set local JSESSIONID variable to the JSESSIONID cookie | ||
JSESSIONID=$(awk 'match($0, /JSESSIONID.*/){print substr($0, RSTART + 11, RLENGTH)}' cookie-jar.txt ) | ||
# Set local XLOGINID variable to the XLOGINID cookie | ||
XLOGINID=$(awk 'match($0, /XLOGINID.*/){print substr($0, RSTART + 9, RLENGTH)}' cookie-jar.txt) | ||
# Request page with XLOGINID and JSESSIONID cookies and extract the _csrf token | ||
CSRF=$(curl -k -b cookie-jar.txt \ | ||
https://localhost:9000/login-form-multi | awk 'match($0,/_csrf".*/) { print substr($0, RSTART+14, RLENGTH -17)}') | ||
# Log into the mutli cooke endpoint using XLOGINID and JSESSIONID cookies and username/password | ||
curl -v -k \ | ||
-d "_csrf=${CSRF}&loginCode=${XLOGINID}&username=user&password=password&remember=on" \ | ||
-b cookie-jar.txt \ | ||
-H "Content-Type: application/x-www-form-urlencoded" \ | ||
"https://localhost:9000/login-form-multi" | ||
|
||
# Run HawkScan injecting local variables as environment variables | ||
hawk scan -e JSESSIONID=${JSESSIONID} -e XLOGINID=${XLOGINID} ./stackhawk.d/stackhawk-multi-cookie-auth.yml | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
|
||
spring.datasource.url=jdbc:h2:file:D:\\a\\1\\db\\vulny;DB_CLOSE_ON_EXIT=FALSE;AUTO_RECONNECT=TRUE |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
app: | ||
applicationId: ${APP_ID:test-app} | ||
env: ${APP_ENV:Multi Cookie Auth} | ||
openApiConf: | ||
path: /openapi | ||
host: ${HOST:https://localhost:9000} | ||
excludePaths: | ||
- "/logout" | ||
- "/login-form-multi" | ||
- "/login-code" | ||
authentication: | ||
external: | ||
values: | ||
- type: COOKIE | ||
value: | ||
name: "XLOGINID" | ||
val: ${XLOGINID} | ||
- type: COOKIE | ||
value: | ||
name: "JSESSIONID" | ||
val: ${JSESSIONID} | ||
testPath: | ||
path: /login-multi-check | ||
success: ".*200.*" | ||
loggedInIndicator: "\\QSign Out\\E" | ||
loggedOutIndicator: ".*Location:.*/login.*" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters