Skip to content

Commit c43e9a7

Browse files
added validate shell and PS scripts
1 parent 4020d9c commit c43e9a7

File tree

2 files changed

+66
-0
lines changed

2 files changed

+66
-0
lines changed

Validate-DefectDojo.ps1

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
param (
2+
[Parameter()]
3+
[string]$nameSuffix = "ek002",
4+
[Parameter()]
5+
[string]$deploymentName = "deploy-rg-fnapp-$nameSuffix",
6+
[Parameter()]
7+
[string]$resourceGroupName = "rg-fnapp-$nameSuffix"
8+
)
9+
10+
# echo parameters
11+
Write-Host "deploymentName: $deploymentName"
12+
Write-Host "nameSuffix: $nameSuffix"
13+
Write-Host "resourceGroupName: $resourceGroupName"

validate-defectdojo.sh

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
DEFECTDOJO_ENGAGEMENT_PERIOD=7
2+
DEFECTDOJO_URL="https://defectdojo.cad4devops.com:8443/api/v2"
3+
DEFECTDOJO_TOKEN="bba17a9471553b1702e1ab4c4bf455156ba5e7d7"
4+
github_run_id="12070601425"
5+
github_event_head_commit_message="Initial commit"
6+
github_ref="refs/heads/main"
7+
DEFECTDOJO_ENGAGEMENT_REASON="CI/CD pipeline"
8+
github_server_url="https://github.com"
9+
github_repository="devopsabcs-engineering/devsecops-workshop"
10+
DEFECTDOJO_ENGAGEMENT_THREAT_MODEL=true
11+
DEFECTDOJO_ENGAGEMENT_API_TEST=true
12+
DEFECTDOJO_ENGAGEMENT_PEN_TEST=true
13+
DEFECTDOJO_ENGAGEMENT_CHECK_LIST=true
14+
DEFECTDOJO_ENGAGEMENT_STATUS="Not Started"
15+
github_sha="4020d9cff3e64ff899913f988688b46f9c0e3ac3"
16+
DEFECTDOJO_ENGAGEMENT_DEDUPLICATION_ON_ENGAGEMENT=true
17+
DEFECTDOJO_PRODUCTID=1 # Product ID - do not forget to change this
18+
DEFECTDOJO_ENGAGEMENT_BUILD_SERVER=null
19+
DEFECTDOJO_ENGAGEMENT_SOURCE_CODE_MANAGEMENT_SERVER=null
20+
DEFECTDOJO_ENGAGEMENT_ORCHESTRATION_ENGINE=null
21+
22+
TODAY=`date +%Y-%m-%d`
23+
ENDDAY=$(date -d "+$DEFECTDOJO_ENGAGEMENT_PERIOD days" +%Y-%m-%d)
24+
ENGAGEMENTID=`curl --fail --location --request POST "$DEFECTDOJO_URL/engagements/" \
25+
--header "Authorization: Token $DEFECTDOJO_TOKEN" \
26+
--header 'Content-Type: application/json' \
27+
--data-raw "{
28+
\"tags\": [\"GITHUB\"],
29+
\"name\": \"pygoat-$github_run_id\",
30+
\"description\": \"$github_event_head_commit_message\",
31+
\"version\": \"$github_ref\",
32+
\"first_contacted\": \"${TODAY}\",
33+
\"target_start\": \"${TODAY}\",
34+
\"target_end\": \"${ENDDAY}\",
35+
\"reason\": \"$DEFECTDOJO_ENGAGEMENT_REASON\",
36+
\"tracker\": \"$github_server_url/$github_repository/\",
37+
\"threat_model\": \"$DEFECTDOJO_ENGAGEMENT_THREAT_MODEL\",
38+
\"api_test\": \"$DEFECTDOJO_ENGAGEMENT_API_TEST\",
39+
\"pen_test\": \"$DEFECTDOJO_ENGAGEMENT_PEN_TEST\",
40+
\"check_list\": \"$DEFECTDOJO_ENGAGEMENT_CHECK_LIST\",
41+
\"status\": \"$DEFECTDOJO_ENGAGEMENT_STATUS\",
42+
\"engagement_type\": \"CI/CD\",
43+
\"build_id\": \"$github_run_id\",
44+
\"commit_hash\": \"$github_sha\",
45+
\"branch_tag\": \"$github_ref\",
46+
\"deduplication_on_engagement\": \"$DEFECTDOJO_ENGAGEMENT_DEDUPLICATION_ON_ENGAGEMENT\",
47+
\"product\": \"$DEFECTDOJO_PRODUCTID\",
48+
\"source_code_management_uri\": \"$github_server_url/$github_repository\",
49+
\"build_server\": $DEFECTDOJO_ENGAGEMENT_BUILD_SERVER,
50+
\"source_code_management_server\": $DEFECTDOJO_ENGAGEMENT_SOURCE_CODE_MANAGEMENT_SERVER,
51+
\"orchestration_engine\": $DEFECTDOJO_ENGAGEMENT_ORCHESTRATION_ENGINE
52+
}" | jq -r '.id'` &&
53+
echo ${ENGAGEMENTID} > ENGAGEMENTID.env

0 commit comments

Comments
 (0)