Skip to content

Commit 83f7a3b

Browse files
authored
Support for mobb project name (#19)
* Update action.yml
1 parent 01704a5 commit 83f7a3b

3 files changed

Lines changed: 68 additions & 3 deletions

File tree

README.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,19 @@ This action posts the code and a SAST report to the Mobb vulnerability analysis
1616

1717
**Required** The GitHub api token to use with the action. Usually available as `${{ secrets.GITHUB_TOKEN }}`.
1818

19+
## `mobb-project-name`
20+
21+
**Optional** The Mobb Project Name where the fix analysis will be stored. If this is not specified, it will the analysis will default into the "My first project".
22+
23+
## `auto-pr`
24+
25+
**Optional** `true` or `false`. Enables Automatic Pull Request for fresh fixes.
26+
27+
## `commit-directly`
28+
29+
**Optional** `true` or `false`. This requires `auto-pr` to be set to `true`. Once set, Fixes will be committed directly to the source branch.
30+
31+
1932
## Outputs
2033

2134
## `fix-report-url`

action.yml

Lines changed: 38 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,16 @@ inputs:
1313
github-token:
1414
description: "GitaHub Token"
1515
required: true
16+
mobb-project-name:
17+
description: "Mobb Project Name"
18+
required: false
19+
auto-pr:
20+
description: "Auto-PR flag"
21+
required: false
22+
commit-directly:
23+
description: "Commit Directly flag, this requires Auto-PR flag to be set. Once enabled, Mobb will commit the fixes directly to the branch"
24+
required: false
25+
1626
outputs:
1727
fix-report-url:
1828
description: "Mobb fix report URL"
@@ -28,18 +38,44 @@ runs:
2838
REPO=$(git remote get-url origin)
2939
REPO=${REPO%".git"}
3040
BRANCH=${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}
31-
OUT=$(npx --yes mobbdev@latest analyze --ci -r $REPO --ref $BRANCH --api-key ${{ inputs.api-key }} -f ${{ inputs.report-file }})
41+
42+
MobbExecString="npx --yes mobbdev@latest analyze --ci -r $REPO --ref $BRANCH --api-key ${{ inputs.api-key }} -f ${{ inputs.report-file }}"
43+
44+
# Check if mobb-project-name exists and append it
45+
if [ -n "${{ inputs.mobb-project-name }}" ]; then
46+
echo "mobb-project-name specified: ${{ inputs.mobb-project-name }}"
47+
MobbExecString+=" --mobb-project-name \"${{ inputs.mobb-project-name }}\""
48+
fi
49+
50+
# Check if auto-pr flag is set append it
51+
if [ "${{ inputs.auto-pr }}" == "true" ]; then
52+
echo "Auto-PR flag is set"
53+
MobbExecString+=" --auto-pr"
54+
fi
55+
56+
# Check if commit-directly flag is set append it to the Mobb CLI command
57+
if [ "${{ inputs.commit-directly }}" == "true" ]; then
58+
echo "Commit Directly flag is set"
59+
MobbExecString+=" --commit-directly"
60+
fi
61+
62+
# Output the final command string for debugging and execute it
63+
echo "Mobb Command: $MobbExecString"
64+
OUT=$(eval $MobbExecString)
65+
3266
RETVAL=$?
3367
if [ $RETVAL -ne 0 ]; then
3468
exit $RETVAL
3569
fi
3670
OUT=$(echo $OUT | tr '\n' ' ')
3771
echo "fix-report-url=$OUT" >> $GITHUB_OUTPUT
72+
echo "Mobb URL: $OUT"
73+
3874
shell: bash -l {0}
3975
- uses: Sibz/github-status-action@v1
4076
with:
4177
authToken: ${{ inputs.github-token }}
4278
context: "Mobb fix report link"
4379
state: "success"
4480
target_url: ${{ steps.run-npx-mobb-dev.outputs.fix-report-url }}
45-
sha: ${{github.event.pull_request.head.sha || github.sha}}
81+
sha: ${{github.event.pull_request.head.sha || github.sha}}

review/action.yml

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ inputs:
1616
scanner:
1717
description: "SAST scanner(codeql, snyk, checkmarx, fortify)"
1818
required: true
19+
mobb-project-name:
20+
description: "Mobb Project Name"
21+
required: false
1922
outputs:
2023
fix-report-url:
2124
description: "Mobb fix report URL"
@@ -57,14 +60,27 @@ runs:
5760
COMMIT_HASH=$(git rev-parse $GITHUB_HEAD_REF)
5861
PR_NUMBER=${{ github.event.pull_request.number }}
5962
VUL_FILE_PATH=results/$(basename ${{ inputs.report-file }})
60-
OUT=$(npx --yes mobbdev@latest review -r $REPO --ref $GITHUB_HEAD_REF --ch $COMMIT_HASH --api-key ${{ inputs.api-key }} -f $VUL_FILE_PATH --pr $PR_NUMBER --github-token ${{ inputs.github-token }} --scanner $SCANNER -p .)
63+
MobbExecString="npx --yes mobbdev@latest review -r $REPO --ref $GITHUB_HEAD_REF --ch $COMMIT_HASH --api-key ${{ inputs.api-key }} -f $VUL_FILE_PATH --pr $PR_NUMBER --github-token ${{ inputs.github-token }} --scanner $SCANNER -p ."
64+
65+
# Check if mobb-project-name exists and append it
66+
if [ -n "${{ inputs.mobb-project-name }}" ]; then
67+
echo "mobb-project-name specified: ${{ inputs.mobb-project-name }}"
68+
MobbExecString+=" --mobb-project-name \"${{ inputs.mobb-project-name }}\""
69+
fi
70+
71+
# Output the final command string for debugging
72+
echo "Mobb Command: $MobbExecString"
73+
OUT=$(eval $MobbExecString)
74+
6175
RETVAL=$?
6276
if [ $RETVAL -ne 0 ]; then
6377
exit $RETVAL
6478
fi
6579
OUT=$(echo $OUT | tr '\n' ' ')
6680
6781
echo "fix-report-url=$OUT" >> $GITHUB_OUTPUT
82+
echo "Mobb URL: $OUT"
83+
6884
shell: bash -l {0}
6985

7086
- uses: Sibz/github-status-action@v1

0 commit comments

Comments
 (0)