Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: adding a message in the PR about the fuzzers output #474

Merged
merged 2 commits into from
Jul 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 43 additions & 0 deletions .github/generate_cppcheck_report.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import sys

UPDATED_FILES = sys.argv[1:]
TABLE_HEADER = """| Filename | Line | Type | Description |
| -------- | ---- | ---- | ----------- |"""

with open("cppcheck.txt") as f:
content = f.readlines()

updated = []
anything_else = []

for line in content:
filename, row, kind, desc = line.split(":", 3)
formatted = f"| {filename} | {row} | {kind.strip()} | {desc.strip()} |"

if filename == "nofile":
continue

if filename in UPDATED_FILES:
updated.append(formatted)
else:
anything_else.append(formatted)


def make_output(data):
if data:
output = TABLE_HEADER + "\n"
output += "\n".join(data)
return output
return ""


print(f"""### CppCheck report
{make_output(updated)}
<details>
<summary>Report files about files you didn't modify in this PR</summary>
{make_output(anything_else)}
</details>
""")
12 changes: 6 additions & 6 deletions .github/launch-lizard.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,22 +32,22 @@


def make_sorted_table_lines(lines_with_ccn):
output = ""
for line in sorted(lines_with_ccn, key=lambda e: e[1], reverse=True):
output += f"| {line[0]} | {line[1]} |\n"
return output
if lines_with_ccn:
output = TABLE_HEADERS + "\n"
for line in sorted(lines_with_ccn, key=lambda e: e[1], reverse=True):
output += f"| {line[0]} | {line[1]} |\n"
return output
return ""


print(f"""### Lizard report
Listing only functions with cyclomatic complexity >= {MAX_CCN} or NLOC >= {MAX_NLOC} or parameters >= {MAX_PARAM}.
{TABLE_HEADERS}
{make_sorted_table_lines(updated)}
<details>
<summary>Report about files you didn't modify in this PR</summary>
{TABLE_HEADERS}
{make_sorted_table_lines(anything_else)}
</details>
""")
26 changes: 24 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -242,9 +242,31 @@ jobs:
-- ${BUILD_FOLDER}/arkscript @@ -L ./lib

- name: Summarize
id: summary
shell: bash
run: |
afl-whatsup -s -d output
afl-showmap -C -i output -o /dev/null -- ./${BUILD_FOLDER}/arkscript @@ -L ./lib
echo "FUZZ_SUMMARY<<EOF" >> $GITHUB_ENV
afl-whatsup -s -d output >> $GITHUB_ENV
afl-showmap -C -i output -o /dev/null -- ./${BUILD_FOLDER}/arkscript @@ -L ./lib | sed -r "s/\x1B\[([0-9]{1,3}(;[0-9]{1,2};?)?)?[mGK]//g" | grep -v Reading | grep -v Scanning >> $GITHUB_ENV
echo "EOF" >> $GITHUB_ENV

- name: Find Comment
uses: peter-evans/find-comment@v3
id: fc
with:
issue-number: ${{ github.event.pull_request.number }}
comment-author: 'github-actions[bot]'
body-includes: Fuzzing report

- name: Create or update comment
uses: peter-evans/create-or-update-comment@v4
with:
comment-id: ${{ steps.fc.outputs.comment-id }}
issue-number: ${{ github.event.pull_request.number }}
body: |
## Fuzzing report
${{ env.FUZZ_SUMMARY }}
edit-mode: replace

- name: Sort files for upload
continue-on-error: true
Expand Down
7 changes: 2 additions & 5 deletions .github/workflows/static_analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,9 @@ jobs:
-I include src \
--enable=all --inline-suppr \
--suppressions-list=cppcheck-suppressions.txt
cat cppcheck.txt | sort > cppcheck_sorted.txt
content=$(python .github/generate_cppcheck_report.py $(echo $(git diff --name-only -r HEAD^1 HEAD)))
echo "CPPCHECK_REPORT<<EOF" >> $GITHUB_ENV
echo "| Filename | Line | Type | Description |" >> $GITHUB_ENV
echo "| -------- | ---- | ---- | ----------- |" >> $GITHUB_ENV
cat cppcheck_sorted.txt | awk -F ":" '{type=$3;out=""; for (i = 4; i <= NF; i++) {out = out " " $i}; print $1 " | " $2 " |" type " |" out}' >> $GITHUB_ENV
echo "$content" >> $GITHUB_ENV
echo "EOF" >> $GITHUB_ENV
- name: Find Comment
Expand All @@ -63,6 +61,5 @@ jobs:
---
### CppCheck report
${{ env.CPPCHECK_REPORT }}
edit-mode: replace
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

# Personal utilities
warnings.log
cppcheck.txt

# ArkScript
__arkscript__/
Expand Down
Loading