Skip to content

Commit

Permalink
Update to new multiline syntax and recent action changes
Browse files Browse the repository at this point in the history
  • Loading branch information
elopez committed Jan 13, 2023
1 parent 8183bb8 commit 072b1fe
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 14 deletions.
13 changes: 5 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -328,10 +328,10 @@ jobs:
ignore-compile: true
```

## Example workflow: markdown report
## Example workflow: Markdown report

The following GitHub Actions workflow example will create/update pull requests
with the contents of Slither's markdown report. Useful for when [GitHub Advanced
with the contents of Slither's Markdown report. Useful for when [GitHub Advanced
Security](https://docs.github.com/en/get-started/learning-about-github/about-github-advanced-security)
(required for the SARIF feature) is unavailable.

Expand All @@ -346,23 +346,20 @@ on:
jobs:
analyze:
runs-on: ubuntu-latest
permissions:
contents: read
security-events: write
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Run Slither
uses: crytic/slither-action@main
continue-on-error: true
uses: crytic/[email protected]
id: slither
with:
node-version: 16
fail-on: none
slither-args: --checklist --markdown-root ${{ github.server_url }}/${{ github.repository }}/blob/${{ github.sha }}/
- name: Create/update checklist as PR comment
uses: actions/github-script@v5.1.0
uses: actions/github-script@v6
if: github.event_name == 'pull_request'
with:
script: |
Expand Down
12 changes: 6 additions & 6 deletions entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ get() {
env | sed -n "s/^$1=\(.*\)/\1/;T;p"
}

random_string() {
echo "$RANDOM $RANDOM $RANDOM $RANDOM $RANDOM" | md5sum | head -c 20
}

version_lte() {
printf '%s\n%s\n' "$1" "$2" | sort -C -V
}
Expand Down Expand Up @@ -265,9 +269,5 @@ else
printf "%s\n" "$SLITHERARGS" | xargs slither "$TARGET" $SARIFFLAG $IGNORECOMPILEFLAG $FAILONFLAG $CONFIGFLAG | tee "$STDOUTFILE"
fi

# https://github.community/t/set-output-truncates-multiline-strings/16852/3
STDOUT="$(< $STDOUTFILE)"
STDOUT="${STDOUT//'%'/'%25'}"
STDOUT="${STDOUT//$'\n'/'%0A'}"
STDOUT="${STDOUT//$'\r'/'%0D'}"
echo "::set-output name=stdout::$STDOUT"
DELIMITER="$(random_string)"
{ echo "stdout<<$DELIMITER"; cat "$STDOUTFILE"; echo -e "\n$DELIMITER"; } >> "$GITHUB_OUTPUT"

0 comments on commit 072b1fe

Please sign in to comment.