Skip to content

Conversation

jmservera
Copy link

@jmservera jmservera commented Oct 19, 2022

An effort to generalize the action so it works with Maven, Gradle, etc. and provides a better sarif integration with GitHub. Linked to issue #1

@jmservera
Copy link
Author

I have a first version of the generalized action that works also with GitHub Security, but I only have tested it with my test project that uses Maven for the build and dependencies, and I only tested the SARIF output, but in theory it should work with any other output config.

@jmservera jmservera marked this pull request as ready for review October 20, 2022 17:51
# Download SpotBugs
wget https://github.com/spotbugs/spotbugs/releases/download/"${SPOTBUGS_VERSION}"/spotbugs-"${SPOTBUGS_VERSION}".zip
unzip spotbugs-"${SPOTBUGS_VERSION}".zip
wget -q -N https://github.com/spotbugs/spotbugs/releases/download/"${SPOTBUGS_VERSION}"/spotbugs-"${SPOTBUGS_VERSION}".zip
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change serves to avoid a too long log that is not related to the actual SAST review


# Check whether to use latest version of PMD
if [ "$SPOTBUGS_VERSION" == 'latest' ]; then
if [ "$SPOTBUGS_VERSION" == 'latest' ] || [ "$SPOTBUGS_VERSION" == "" ]; then
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This way the default behavior downloads the latest version


# Take care of parameter order, sometimes does not work if you change it

CMD="java -Xmx1900M -Dlog4j2.formatMsgNoLookups=true \
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here we start building the SpotBugs command line depending on the provided parameters

if [ "$OUTPUT_TYPE" == "sarif" ] && [ "$BASE_PATH" != "" ]; then
# prepend the pyhsical path
echo "Transform sarif file to include the physical path"
jq -c "(.runs[].results[].locations[].physicalLocation.artifactLocation.uri) |=\"$BASE_PATH\"+." resultspre.sarif > "$OUTPUT"
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is needed to provide compatibility with the GitHub SARIF parser that needs the base path as a prefix (typically src/main/java)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant