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,93 @@ 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
+
79
+ # - run: jq '.authorizationProtocol = "NONE"' .config.json > .config2.json && mv .config2.json .config.json
80
+
81
81
# Delete the first and the second items in the array (remove keychain and manual consortium plugins)
82
82
- run : jq 'del(.plugins[0,1])' .config.json > .config2.json && mv .config2.json .config.json
83
-
83
+
84
84
- name : Install Keychain manual plugin into the API server
85
85
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
-
86
+
87
87
- name : Install Fabric connector into the API server
88
88
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
-
89
+
90
90
- name : Install Besu connector into the API server
91
91
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
-
92
+
93
93
- name : Run Besu all-in-one image
94
94
run : |
95
95
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
96
until curl --fail -X POST --data '{"jsonrpc":"2.0","method":"eth_chainId","params":[],"id":1}' localhost:8545; do sleep 5; done
97
-
97
+
98
98
- name : Print API Server Config File - ./.config.json
99
99
run : cat .config.json
100
-
100
+
101
101
- name : Print Nuclei Config File - ./.nuclei-config.yaml
102
102
run : cat .nuclei-config.yaml
103
-
103
+
104
104
- name : Print Nuclei URL List File - ./urls.txt
105
105
run : cat urls.txt
106
+ # ------------
107
+ - name : Generate Audience and Issuer
108
+ id : generate_ids
109
+ run : |
110
+ echo "audience=$(uuidgen)" >> $GITHUB_ENV
111
+ echo "issuer=$(uuidgen)" >> $GITHUB_ENV
112
+
113
+ - name : Generate RSA Keys
114
+ run : |
115
+ openssl genpkey -algorithm RSA -out private_key.pem -pkeyopt rsa_keygen_bits:2048
116
+ openssl rsa -in private_key.pem -pubout -out public_key.pem
117
+
118
+ - name : Display Results
119
+ run : |
120
+ echo "Audience: ${{ env.audience }}"
121
+ echo "Issuer: ${{ env.issuer }}"
122
+ echo "Public Key:"
123
+ cat public_key.pem
124
+ echo "Private Key:"
125
+ cat private_key.pem
126
+
127
+ - run : jq '.expressJwtOptions.secret = "-----BEGIN PUBLIC KEY-----\n$(cat public_key.pem)\n-----END PUBLIC KEY-----" |
128
+ .expressJwtOptions.algorithms = ["RS256"] |
129
+ .expressJwtOptions.issuer = "${{ env.issuer }}" |
130
+ .expressJwtOptions.audience = "${{ env.audience }}"' .config.json > .config2.json && mv .config2.json .config.json
131
+
132
+ - name : Generate Auth Bearer Token
133
+ run : |
134
+ HEADER_B64=$(echo '{"alg":"RS256"}' | openssl base64 -e -A | tr -d '=' | tr '/+' '_-')
135
+ PAYLOAD_B64=$(cat '{"scope":"read:health","iss":"${{ env.issuer }}","aud":"${{ env.audience }}"}' | openssl base64 -e -A | tr -d '=' | tr '/+' '_-')
136
+
137
+ SIGNATURE=$(echo -n "$HEADER_B64.$PAYLOAD_B64" | openssl dgst -sha256 -sign cat private_key.pem | openssl base64 -e -A | tr -d '=' | tr '/+' '_-')
138
+ JWT="$HEADER_B64.$PAYLOAD_B64.$SIGNATURE"
139
+ echo dast_jwt=$JWT >> $GITHUB_ENV
106
140
107
141
- name : Start API Server & Run DAST
108
142
uses :
BerniWittmann/[email protected]
109
143
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
144
+ # Needed because the wait-on syntax otherwise keeps thinking that
145
+ # there is a problem due to our self signed certificates on the
146
+ # test instance of the API server
147
+ NODE_TLS_REJECT_UNAUTHORIZED : 0
114
148
with :
115
149
build : yarn --version
116
150
start : yarn start:api-server
117
151
command : " nuclei -version"
118
152
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
153
# wait for 10 minutes for the server to respond
121
154
wait-on-timeout : 120
122
-
155
+ wait-on-command : |
156
+ curl -X GET https://localhost:4000/api/v1/api-server/healthcheck -k -H "Authorization: Bearer ${{ env.dast_jwt }}"
157
+
123
158
- name : Run the dast nuclei scan
124
159
run : " nuclei -list=urls.txt -dast -severity=high,critical -sarif-export ~/nuclei.sarif -output=nuclei.log"
125
-
160
+
126
161
- name : GitHub Workflow artifacts
127
162
128
163
with :
129
164
name : nuclei.log
130
- path : nuclei.log
165
+ path : nuclei.log
0 commit comments