Skip to content

Commit 677cc06

Browse files
committed
SCAN-5649 : Add script to test container locally.
1 parent c9f043b commit 677cc06

File tree

3 files changed

+42
-1
lines changed

3 files changed

+42
-1
lines changed

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,7 @@
11
node_modules
2+
target
3+
log
4+
results.sarif
5+
scan-summary.json
6+
.contrast-scan/
27
.vscode

scripts/run-action-locally.sh

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
#!/bin/bash
2+
3+
docker run \
4+
-e INPUT_APIURL=$CONTRAST__API__URL \
5+
-e INPUT_APIUSERNAME=$CONTRAST__API__USER_NAME \
6+
-e INPUT_APIKEY=$CONTRAST__API__API_KEY \
7+
-e INPUT_APISERVICEKEY=$CONTRAST__API__SERVICE_KEY \
8+
-e INPUT_APIORGID=$CONTRAST__API__ORGANIZATION \
9+
-e INPUT_DEFAULTBRANCH=true \
10+
-e INPUT_CHECKS=false \
11+
-e INPUT_CODEQUALITY=false \
12+
-e INPUT_PATH=src \
13+
-e INPUT_LABEL="local-test" \
14+
-e INPUT_TOKEN=$GITHUB_TOKEN \
15+
-e ACTIONS_RUNTIME_TOKEN=$GITHUB_TOKEN \
16+
-e RUNNER_TEMP=/tmp \
17+
-e GITHUB_JOB="local-test" \
18+
-e GITHUB_REF="refs/local/test" \
19+
-e GITHUB_SHA=c9f043b \
20+
-e GITHUB_EVENT_NAME="local-test" \
21+
-e GITHUB_REPOSITORY=contrast-local-scan-action-test \
22+
-e GITHUB_REPOSITORY_OWNER=Contrast-Security-OSS \
23+
-e GITHUB_REPOSITORY_OWNER_ID=1 \
24+
-e GITHUB_RUN_ID=1 \
25+
-e GITHUB_RUN_NUMBER=1 \
26+
-e GITHUB_WORKSPACE=/workspace \
27+
-w /workspace \
28+
-v .:/workspace \
29+
$(docker build -q .)
30+

src/request.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,13 @@ const core = require("@actions/core");
33

44
const { apiApiKey, apiAuthHeader, apiBaseUrl } = require("./config");
55

6-
const httpClient = new httpm.HttpClient();
6+
const httpClient = new httpm.HttpClient(
7+
'contrast-local-scan-action', // Sets user-agent
8+
[],
9+
{
10+
allowRedirects: false
11+
}
12+
);
713

814
async function request(path) {
915
const response = await httpClient.getJson(`${apiBaseUrl}/${path}`, {

0 commit comments

Comments
 (0)