1
1
name : DAST_Scan_Nuclei
2
-
2
+
3
3
env :
4
4
NODEJS_VERSION : v18.18.2
5
-
5
+
6
6
on :
7
7
push :
8
8
branches : [main, dev]
9
-
9
+
10
10
pull_request :
11
11
branches : [main, dev]
12
-
12
+
13
13
jobs :
14
14
nuclei-scan :
15
15
runs-on : ubuntu-22.04
@@ -25,30 +25,30 @@ jobs:
25
25
libvcx \
26
26
indy-cli \
27
27
&& sudo rm -f /etc/apt/sources.list.d/sovrin.list*
28
-
28
+
29
29
- name : Set up NodeJS ${{ env.NODEJS_VERSION }}
30
30
31
31
with :
32
32
node-version : ${{ env.NODEJS_VERSION }}
33
-
33
+
34
34
- name : Install jq
35
35
run : sudo apt update && sudo apt install -y jq
36
-
36
+
37
37
- name : Verify jq
38
38
run : jq --version
39
-
39
+
40
40
41
-
41
+
42
42
43
43
with :
44
44
go-version : 1.23
45
-
45
+
46
46
-
run :
go install -v github.com/projectdiscovery/nuclei/v3/cmd/[email protected]
47
-
47
+
48
48
- run : nuclei --version
49
-
49
+
50
50
- run : npm run configure
51
-
51
+
52
52
- name : Create URLs file for Nuclei
53
53
run : |
54
54
echo https://localhost:4000/ > urls.txt
@@ -73,58 +73,91 @@ jobs:
73
73
echo https://localhost:4000/api/v1/plugins/@hyperledger/cactus-plugin-ledger-connector-besu/get-prometheus-exporter-metrics
74
74
echo https://localhost:4000/api/v1/plugins/@hyperledger/cactus-plugin-ledger-connector-besu/get-besu-record
75
75
} >> urls.txt
76
-
76
+
77
77
- run : yarn generate-api-server-config
78
-
79
- - run : jq '.authorizationProtocol = "NONE"' .config.json > .config2.json && mv .config2.json .config.json
80
-
78
+
81
79
# Delete the first and the second items in the array (remove keychain and manual consortium plugins)
82
80
- run : jq 'del(.plugins[0,1])' .config.json > .config2.json && mv .config2.json .config.json
83
-
81
+
84
82
- name : Install Keychain manual plugin into the API server
85
83
run : jq '.plugins += [{ "packageName":"@hyperledger/cactus-plugin-keychain-memory","type":"org.hyperledger.cactus.plugin_import_type.LOCAL","action":"org.hyperledger.cactus.plugin_import_action.INSTALL","options":{"packageSrc":"/home/runner/work/cacti/cacti/packages/cactus-plugin-keychain-memory/","instanceId":"0daacd05-d1cd-4eab-9332-4ad1aff4b909","keychainId":"d29d728e-eaa0-4e2d-b187-d132242b0d9a"}}]' .config.json > .config2.json && mv .config2.json .config.json
86
-
84
+
87
85
- name : Install Fabric connector into the API server
88
86
run: jq '.plugins += [{ "packageName":"@hyperledger/cactus-plugin-ledger-connector-fabric", "type":"org.hyperledger.cactus.plugin_import_type.LOCAL", "action":"org.hyperledger.cactus.plugin_import_action.INSTALL", "options":{ "packageSrc":"/home/runner/work/cacti/cacti/packages/cactus-plugin-ledger-connector-fabric/", "instanceId":"some-unique-fabric-connector-instance-id", "peerBinary":"/fabric-samples/bin/peer", "connectionProfile":"{}", "dockerBinary":"usr/local/bin/docker","cliContainerEnv":{"CORE_PEER_LOCALMSPID":"Org1MSP","CORE_PEER_ADDRESS":"peer0.org1.example.com:7051","CORE_PEER_MSPCONFIGPATH":"/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/users/
[email protected] /msp","CORE_PEER_TLS_ROOTCERT_FILE":"/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/ca.crt","ORDERER_TLS_ROOTCERT_FILE":"/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem"},"discoveryOptions":{"enabled":true,"asLocalhost":true}}}] ' .config.json > .config2.json && mv .config2.json .config.json
89
-
87
+
90
88
- name : Install Besu connector into the API server
91
89
run : jq '.plugins += [{"packageName":"@hyperledger/cactus-plugin-ledger-connector-besu","type":"org.hyperledger.cactus.plugin_import_type.LOCAL","action":"org.hyperledger.cactus.plugin_import_action.INSTALL","options":{"packageSrc":"/home/runner/work/cacti/cacti/packages/cactus-plugin-ledger-connector-besu/", "rpcApiHttpHost":"http://127.0.0.1:8545", "rpcApiWsHost":"ws://127.0.0.1:8546", "instanceId":"some-unique-besu-connector-instance-id"}}]' .config.json > .config2.json && mv .config2.json .config.json
92
-
90
+
93
91
- name : Run Besu all-in-one image
94
92
run : |
95
93
docker run -d -p 0.0.0.0:8545:8545/tcp -p 0.0.0.0:8546:8546/tcp -p 0.0.0.0:8888:8888/tcp -p 0.0.0.0:9001:9001/tcp -p 0.0.0.0:9545:9545/tcp ghcr.io/hyperledger/cactus-besu-all-in-one:v2.0.0-rc.7
96
94
until curl --fail -X POST --data '{"jsonrpc":"2.0","method":"eth_chainId","params":[],"id":1}' localhost:8545; do sleep 5; done
97
-
95
+
98
96
- name : Print API Server Config File - ./.config.json
99
97
run : cat .config.json
100
-
98
+
101
99
- name : Print Nuclei Config File - ./.nuclei-config.yaml
102
100
run : cat .nuclei-config.yaml
103
-
101
+
104
102
- name : Print Nuclei URL List File - ./urls.txt
105
103
run : cat urls.txt
106
104
105
+ - name : Generate Audience and Issuer
106
+ id : generate_ids
107
+ run : |
108
+ echo "audience=$(uuidgen)" >> "$GITHUB_ENV"
109
+ echo "issuer=$(uuidgen)" >> "$GITHUB_ENV"
110
+
111
+ - name : Generate RSA Keys
112
+ run : |
113
+ openssl genpkey -algorithm RSA -out private_key.pem -pkeyopt rsa_keygen_bits:2048
114
+ openssl rsa -in private_key.pem -pubout -out public_key.pem
115
+
116
+ - name : Display Results
117
+ run : |
118
+ echo "Audience: ${{ env.audience }}"
119
+ echo "Issuer: ${{ env.issuer }}"
120
+ echo "Public Key:"
121
+ cat public_key.pem
122
+ echo "Private Key:"
123
+ cat private_key.pem
124
+
125
+ - run : jq '.expressJwtOptions.secret = "-----BEGIN PUBLIC KEY-----\n$(cat public_key.pem)\n-----END PUBLIC KEY-----" |
126
+ .expressJwtOptions.algorithms = ["RS256"] |
127
+ .expressJwtOptions.issuer = "${{ env.issuer }}" |
128
+ .expressJwtOptions.audience = "${{ env.audience }}"' .config.json > .config2.json && mv .config2.json .config.json
129
+
130
+ - name : Generate Auth Bearer Token
131
+ run : |
132
+ HEADER_B64=$(echo '{"alg":"RS256"}' | openssl base64 -e -A | tr -d '=' | tr '/+' '_-')
133
+ PAYLOAD_B64=$(echo '{"scope":"read:health","iss":"${{ env.issuer }}","aud":"${{ env.audience }}"}' | openssl base64 -e -A | tr -d '=' | tr '/+' '_-')
134
+
135
+ SIGNATURE=$(echo -n "$HEADER_B64.$PAYLOAD_B64" | openssl dgst -sha256 -sign private_key.pem | openssl base64 -e -A | tr -d '=' | tr '/+' '_-')
136
+ JWT="$HEADER_B64.$PAYLOAD_B64.$SIGNATURE"
137
+ echo "dast_jwt=$JWT" >> "$GITHUB_ENV"
138
+
107
139
- name : Start API Server & Run DAST
108
140
uses :
BerniWittmann/[email protected]
109
141
env :
110
- # Needed because the wait-on syntax otherwise keeps thinking that
111
- # there is a problem due to our self signed certificates on the
112
- # test instance of the API server
113
- NODE_TLS_REJECT_UNAUTHORIZED : 0
142
+ # Needed because the wait-on syntax otherwise keeps thinking that
143
+ # there is a problem due to our self signed certificates on the
144
+ # test instance of the API server
145
+ NODE_TLS_REJECT_UNAUTHORIZED : 0
114
146
with :
115
147
build : yarn --version
116
148
start : yarn start:api-server
117
149
command : " nuclei -version"
118
150
command-windows : echo "The project build is not supported on the Windows operating system. Please use Linux or macOS"
119
- wait-on : " https://localhost:4000/api/v1/api-server/healthcheck"
120
151
# wait for 10 minutes for the server to respond
121
152
wait-on-timeout : 120
122
-
153
+ wait-on-command : |
154
+ curl -X GET https://localhost:4000/api/v1/api-server/healthcheck -k -H "Authorization: Bearer ${{ env.dast_jwt }}"
155
+
123
156
- name : Run the dast nuclei scan
124
157
run : " nuclei -list=urls.txt -dast -severity=high,critical -sarif-export ~/nuclei.sarif -output=nuclei.log"
125
-
158
+
126
159
- name : GitHub Workflow artifacts
127
160
128
161
with :
129
162
name : nuclei.log
130
- path : nuclei.log
163
+ path : nuclei.log
0 commit comments