Skip to content

Commit 2d7bd7d

Browse files
fix(dast): ccp, sshconfig missing
Primary Changes ---------------- 1. Fix the issue on plugin-ledger-connector-fabric that throws an error when there is no sshConfig available. Fixes #3671 Signed-off-by: raynato.c.pedrajeta <[email protected]>
1 parent 50d19f8 commit 2d7bd7d

File tree

2 files changed

+45
-14
lines changed

2 files changed

+45
-14
lines changed

.github/workflows/.dast-nuclei-cmd-api-server.yaml

+34-10
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ jobs:
3838
run: jq --version
3939

4040
- uses: actions/[email protected]
41-
41+
4242
- uses: actions/[email protected]
4343
with:
4444
go-version: 1.23
@@ -76,8 +76,6 @@ jobs:
7676
7777
- run: yarn generate-api-server-config
7878

79-
- run: jq '.authorizationProtocol = "NONE"' .config.json > .config2.json && mv .config2.json .config.json
80-
8179
# Delete the first and the second items in the array (remove keychain and manual consortium plugins)
8280
- run: jq 'del(.plugins[0,1])' .config.json > .config2.json && mv .config2.json .config.json
8381

@@ -104,27 +102,53 @@ jobs:
104102
- name: Print Nuclei URL List File - ./urls.txt
105103
run: cat urls.txt
106104

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+
- run: jq '.expressJwtOptions.secret = "$(cat public_key.pem)" |
117+
.expressJwtOptions.algorithms = ["RS256"] |
118+
.expressJwtOptions.issuer = "${{ env.issuer }}" |
119+
.expressJwtOptions.audience = "${{ env.audience }}"' .config.json > .config2.json && mv .config2.json .config.json
120+
121+
- name: Generate Auth Bearer Token
122+
run: |
123+
HEADER_B64=$(echo '{"alg":"RS256"}' | openssl base64 -e -A | tr -d '=' | tr '/+' '_-')
124+
PAYLOAD_B64=$(echo '{"scope":"read:health","iss":"${{ env.issuer }}","aud":"${{ env.audience }}"}' | openssl base64 -e -A | tr -d '=' | tr '/+' '_-')
125+
126+
SIGNATURE=$(echo -n "$HEADER_B64.$PAYLOAD_B64" | openssl dgst -sha256 -sign private_key.pem | openssl base64 -e -A | tr -d '=' | tr '/+' '_-')
127+
JWT="$HEADER_B64.$PAYLOAD_B64.$SIGNATURE"
128+
echo "dast_jwt=$JWT" >> "$GITHUB_ENV"
129+
107130
- name: Start API Server & Run DAST
108131
uses: BerniWittmann/[email protected]
109132
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
133+
# Needed because the wait-on syntax otherwise keeps thinking that
134+
# there is a problem due to our self signed certificates on the
135+
# test instance of the API server
136+
NODE_TLS_REJECT_UNAUTHORIZED: 0
114137
with:
115138
build: yarn --version
116139
start: yarn start:api-server
117140
command: "nuclei -version"
118141
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"
120142
# wait for 10 minutes for the server to respond
121143
wait-on-timeout: 120
122-
144+
wait-on-command: |
145+
curl -X GET https://localhost:4000/api/v1/api-server/healthcheck -k -H "Authorization: Bearer ${{ env.dast_jwt }}"
146+
123147
- name: Run the dast nuclei scan
124148
run: "nuclei -list=urls.txt -dast -severity=high,critical -sarif-export ~/nuclei.sarif -output=nuclei.log"
125149

126150
- name: GitHub Workflow artifacts
127151
uses: actions/[email protected]
128152
with:
129153
name: nuclei.log
130-
path: nuclei.log
154+
path: nuclei.log

packages/cactus-plugin-ledger-connector-fabric/src/main/typescript/plugin-ledger-connector-fabric.ts

+11-4
Original file line numberDiff line numberDiff line change
@@ -307,15 +307,22 @@ export class PluginLedgerConnectorFabric
307307
this.sshDebugOn = opts.sshDebugOn === true;
308308
if (this.opts.sshConfig) {
309309
this.sshConfig = this.opts.sshConfig;
310+
311+
if (this.sshDebugOn) {
312+
this.sshConfig = this.enableSshDebugLogs(this.sshConfig);
313+
}
310314
} else if (this.opts.sshConfigB64) {
311315
const sshConfigBuffer = Buffer.from(this.opts.sshConfigB64, "base64");
312316
const sshConfigString = sshConfigBuffer.toString("utf-8");
313317
this.sshConfig = JSON.parse(sshConfigString);
318+
319+
if (this.sshDebugOn) {
320+
this.sshConfig = this.enableSshDebugLogs(this.sshConfig);
321+
}
314322
} else {
315-
throw new Error("Cannot instantiate Fabric connector without SSH config");
316-
}
317-
if (this.sshDebugOn) {
318-
this.sshConfig = this.enableSshDebugLogs(this.sshConfig);
323+
// TODO: Temporarily commenting this code so that we do not have breaking changes, will be fixed by issue #3764
324+
// throw new Error("Cannot instantiate Fabric connector without SSH config");
325+
this.sshConfig = {};
319326
}
320327

321328
this.signCallback = opts.signCallback;

0 commit comments

Comments
 (0)