Skip to content

Commit d8b45b0

Browse files
authored
Merge pull request #4 from advanced-security/fix-action
Fix action
2 parents 124ee3f + 28ad40c commit d8b45b0

3 files changed

Lines changed: 21 additions & 15 deletions

File tree

README.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,20 +10,19 @@ Set up a workflow that builds your JVM language project, then run this Action on
1010

1111
First, build your Java, Scala or other JVM language project in an Actions workflow.
1212

13-
Then, set up this Action as a step in your Actions workflow, e.g. for a typical Scala project:
13+
Then, set up this Action as a step in your Actions workflow, e.g. for a typical Scala project where you have locally published a Jar file:
1414

1515
```yaml
1616
- name: Run SpotBugs with FindSecBugs
1717
uses: advanced-security/spotbugs-findsecbugs-action@v1
18-
with:
19-
spotbugs_target: 'target/scala-2.13/classes'
2018
```
2119
2220
## Inputs
2321
2422
* `spotbugs_version`: The version of SpotBugs to use. Default: `4.7.3`
2523
* `findsecbugs_version`: The version of FindSecBugs to use. Default: `1.12.0`
2624
* `spotbugs_target`: The target directory to run SpotBugs against. Default: `target/`
25+
* `spotbugs_filename_glob`: The filenames to locate for SpotBugs, e.g. *.class, *.jar. Default: `*.jar`
2726
* `upload_sarif`: Whether to upload the SARIF file to GitHub Code Scanning. Default: `true`
2827
* `java_distribution`: The Java distribution to use. Default: `microsoft`
2928
* `java_version`: The Java version to use. Default: `11`

action.yml

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,12 @@ inputs:
1616
required: false
1717
default: '1.12.0'
1818
spotbugs_target:
19-
description: 'The target to run SpotBugs against'
19+
description: 'The target directory to run SpotBugs against'
2020
required: false
2121
default: 'target/'
22+
spotbugs_filename_glob:
23+
description: 'The filenames to locate for SpotBugs, e.g. *.class, *.jar'
24+
default: '*.jar'
2225
upload_sarif:
2326
description: 'Whether to upload the SARIF file to GitHub Code Scanning'
2427
required: false
@@ -68,10 +71,11 @@ runs:
6871
cd /home/runner/work/
6972
mkdir -p 'spotbugs+'
7073
cd 'spotbugs+'
71-
wget -q https://github.com/spotbugs/spotbugs/releases/download/"${INPUT_SPOTBUGS_VERSION}"/spotbugs-"${INPUT_SPOTBUGS_VERSION}".tgz
74+
wget -q -O spotbugs-"${INPUT_SPOTBUGS_VERSION}".tgz "https://github.com/spotbugs/spotbugs/releases/download/${INPUT_SPOTBUGS_VERSION}/spotbugs-${INPUT_SPOTBUGS_VERSION}.tgz"
7275
tar -xzf spotbugs-"${INPUT_SPOTBUGS_VERSION}".tgz
7376
chmod +x spotbugs-"${INPUT_SPOTBUGS_VERSION}"/bin/spotbugs
74-
echo "Got spotbugs-${INPUT_SPOTBUGS_VERSION}.tgz"
77+
ls "spotbugs-${INPUT_SPOTBUGS_VERSION}.tgz"
78+
echo "Got spotbugs"
7579
shell: bash
7680
- name: Get FindSecBugs
7781
if: inputs.no_cache == 'true' || steps.cache-findsecbugs.outputs.cache-hit != 'true'
@@ -81,18 +85,20 @@ runs:
8185
cd /home/runner/work/
8286
mkdir -p 'findsecbugs+'
8387
cd 'findsecbugs+'
84-
wget -q https://search.maven.org/remotecontent?filepath=com/h3xstream/findsecbugs/findsecbugs-plugin/"${INPUT_FINDSECBUGS_VERSION}"/findsecbugs-plugin-"${INPUT_FINDSECBUGS_VERSION}".jar
85-
echo "Got findsecbugs-plugin-${INPUT_FINDSECBUGS_VERSION}.jar"
88+
wget -q -O "findsecbugs-plugin-${INPUT_FINDSECBUGS_VERSION}.jar" "https://search.maven.org/remotecontent?filepath=com/h3xstream/findsecbugs/findsecbugs-plugin/${INPUT_FINDSECBUGS_VERSION}/findsecbugs-plugin-${INPUT_FINDSECBUGS_VERSION}.jar"
89+
ls "findsecbugs-plugin-${INPUT_FINDSECBUGS_VERSION}.jar"
90+
echo "Got findsecbugs"
8691
shell: bash
8792
- name: Run SpotBugs
8893
env:
8994
INPUT_FINDSECBUGS_VERSION: ${{ inputs.findsecbugs_version }}
9095
INPUT_SPOTBUGS_TARGET: ${{ inputs.spotbugs_target }}
96+
INPUT_SPOTBUGS_GLOB: ${{ inputs.spotbugs_filename_glob }}
9197
SPOTBUGS_HOME: /home/runner/work/spotbugs+/spotbugs-${{ inputs.spotbugs_version }}
9298
FINDSECBUGS_HOME: /home/runner/work/findsecbugs+/
9399
run: |
94-
SPOTBUGS_FILES=$(find "${INPUT_SPOTBUGS_TARGET}" -type f -exec echo -n {} \+)
95-
"${SPOTBUGS_HOME}"/bin/spotbugs -textui -quiet -effort:max -low -bugCategories SECURITY -pluginList "${FINDSECBUGS_HOME}"/findsecbugs-plugin-"${INPUT_FINDSECBUGS_VERSION}".jar -sarif=spotbugs.sarif ${SPOTBUGS_FILES}
100+
SPOTBUGS_FILES=$(find "${INPUT_SPOTBUGS_TARGET}" -type f -name "${INPUT_SPOTBUGS_GLOB}" -exec echo -n {} \+)
101+
"${SPOTBUGS_HOME}/bin/spotbugs" -textui -quiet -effort:max -low -bugCategories SECURITY -pluginList "${FINDSECBUGS_HOME}/findsecbugs-plugin-${INPUT_FINDSECBUGS_VERSION}.jar" -sarif=spotbugs.sarif ${SPOTBUGS_FILES}
96102
shell: bash
97103
- name: Upload SARIF file
98104
if: inputs.upload_sarif == 'true'

starter-workflow.yml

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,16 @@ jobs:
2222
with:
2323
distribution: 'microsoft'
2424
java-version: 11
25-
# do your build steps. This example uses sbt
26-
- name: Compile with sbt
27-
run: sbt compile
25+
# do your build steps. This example uses sbt to create a .jar file, which will go into the target/scala-2.13 folder
26+
- name: Publish locally with sbt
27+
run: sbt publishLocal
2828
# now run SpotBugs and upload the results to Code Scanning
2929
- name: Run SpotBugs with FindSecBugs
3030
uses: advanced-security/spotbugs-findsecbugs-action@v1
3131
with:
32-
# set these appropriately for your project
33-
spotbugs_target: 'target/scala-2.13/classes' # cannot have globs
32+
# set these appropriately for your project - the defaults are shown here for context
33+
spotbugs_target: 'target/scala-2.13' # cannot have globs
34+
# spotbugs_filename_glob: '*.jar'
3435
# upload_sarif: 'true'
3536
# no_cache: 'false'
3637
# spotbugs_version: '4.7.3'

0 commit comments

Comments
 (0)