Skip to content

Commit c0bf323

Browse files
committed
Introduce AI-Assisted requirements
AI-Assisted: no
1 parent d535501 commit c0bf323

3 files changed

Lines changed: 85 additions & 17 deletions

File tree

.config/ci/check_commits.sh

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
#!/bin/bash
2+
3+
# SPDX-License-Identifier: GPL-2.0-only
4+
5+
# Check all commits in the PR have the "AI-Assisted" tag
6+
# We copy Wireshark's contributing guide, thanks to them for the idea !
7+
# This script is inspired by https://gitlab.com/wireshark/wireshark/-/blob/master/.gitlab-ci.yml
8+
9+
if [ -z "$GITHUB_HEAD_REF" ]; then
10+
echo "Not a Github PR."
11+
exit 0
12+
fi
13+
14+
commits=$(git rev-list --no-merges "$GITHUB_BASE_REF".."$GITHUB_REF")
15+
if [ -z "$commits" ]; then
16+
echo "No commit to check in PR. OK."
17+
exit 0
18+
fi
19+
20+
missing=0
21+
for c in $commits; do
22+
if ! git log -1 --format=%B "$c" | grep -qi '^AI-Assisted:'; then
23+
echo -e "ERROR: Commit \033[0;33m$c\033[0m is missing the 'AI-Assisted: yes|no [tool(s)]' trailer."
24+
missing=1
25+
fi
26+
done
27+
28+
if [ $missing -eq 1 ]; then
29+
echo
30+
echo -e "\033[0;31mPlease add the 'AI-Assisted' trailer to commit messages !\033[0m"
31+
echo "See the contribution guide at: https://github.com/secdev/scapy/blob/master/CONTRIBUTING.md"
32+
else
33+
echo "All checked commits include the AI-Assisted trailer."
34+
fi

.github/workflows/unittests.yml

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,28 @@ permissions:
1616
contents: read
1717

1818
jobs:
19+
commit:
20+
name: Check the validity of the commits
21+
runs-on: ubuntu-latest
22+
# We follow the same contributing patterns as Wireshark. Thanks to
23+
# https://gitlab.com/wireshark/wireshark/-/blob/master/.gitlab-ci.yml
24+
steps:
25+
- name: Checkout Scapy
26+
uses: actions/checkout@v4
27+
- name: AI trailer reminder
28+
run: bash ./.config/ci/check_commits.sh
29+
spdx:
30+
name: Check SPDX identifiers (Licensing)
31+
runs-on: ubuntu-latest
32+
steps:
33+
- name: Checkout Scapy
34+
uses: actions/checkout@v4
35+
- name: Launch script
36+
run: bash scapy/tools/check_spdx.sh
1937
health:
2038
name: Code health check
2139
runs-on: ubuntu-latest
40+
needs: [commit, spdx]
2241
steps:
2342
- name: Checkout Scapy
2443
uses: actions/checkout@v4
@@ -40,6 +59,7 @@ jobs:
4059
# 'runs-on' and 'python-version' should match the ones defined in .readthedocs.yml
4160
name: Build doc
4261
runs-on: ubuntu-22.04
62+
needs: [commit, spdx]
4363
steps:
4464
- name: Checkout Scapy
4565
uses: actions/checkout@v4
@@ -51,17 +71,10 @@ jobs:
5171
run: pip install tox
5272
- name: Build docs
5373
run: tox -e docs
54-
spdx:
55-
name: Check SPDX identifiers
56-
runs-on: ubuntu-latest
57-
steps:
58-
- name: Checkout Scapy
59-
uses: actions/checkout@v4
60-
- name: Launch script
61-
run: bash scapy/tools/check_spdx.sh
6274
mypy:
6375
name: Type hints check
6476
runs-on: ubuntu-latest
77+
needs: [commit, spdx]
6578
steps:
6679
- name: Checkout Scapy
6780
uses: actions/checkout@v4
@@ -77,6 +90,7 @@ jobs:
7790
utscapy:
7891
name: ${{ matrix.os }} ${{ matrix.installmode }} ${{ matrix.python }} ${{ matrix.mode }} ${{ matrix.flags }}
7992
runs-on: ${{ matrix.os }}
93+
needs: [commit, spdx]
8094
timeout-minutes: 20
8195
continue-on-error: ${{ matrix.allow-failure == 'true' }}
8296
strategy:
@@ -175,6 +189,7 @@ jobs:
175189
cryptography:
176190
name: pyca/cryptography test
177191
runs-on: ubuntu-latest
192+
needs: [commit, spdx]
178193
steps:
179194
- name: Checkout repository
180195
uses: actions/checkout@v4
@@ -195,6 +210,7 @@ jobs:
195210
analyze:
196211
name: CodeQL analysis
197212
runs-on: ubuntu-latest
213+
needs: [commit, spdx]
198214
permissions:
199215
security-events: write
200216
steps:

CONTRIBUTING.md

Lines changed: 27 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,14 @@ submitting an issue.
4040
If you're not sure whether a behavior is a bug or not, submit an issue
4141
and ask, don't be shy!
4242

43+
### AI-assisted reports
44+
45+
<!-- Wireshark has greate AI guidelines ! Let's not reinvent the wheel -->
46+
<!-- https://gitlab.com/wireshark/wireshark/-/blob/master/doc/wsug_src/wsug_introduction.adoc -->
47+
48+
If you use AI tools to help find or draft a bug report, please mention that and make sure you have personally verified the steps and details before submitting.
49+
Purely AI-generated reports are not supported and might be closed; a quick human check keeps triage efficient for everyone.
50+
4351
### Enhancements / feature requests
4452

4553
If you want a feature in Scapy, but cannot implement it yourself or
@@ -53,6 +61,18 @@ of function calls, packet creations, etc.).
5361

5462
### Coding style & conventions
5563

64+
- All commits should include the `AI-Assisted: (yes/no) [tool]` tag. This is used to disclose the AI tools that are used when authoring. You must check the commits you produce, or your PR might be closed. The tag may look like such:
65+
66+
```
67+
AI-Assisted: yes (Claude Opus 4.7)
68+
```
69+
or
70+
71+
```
72+
AI-Assisted: no
73+
```
74+
This guideline is adapted with thanks to [Wireshark's AI usage statement](https://www.wireshark.org/docs/wsdg_html_chunked/ChSrcContribute.html).
75+
5676
- The code should be PEP-8 compliant; you can check your code with
5777
[pep8](https://pypi.python.org/pypi/pep8) and the command `tox -e flake8`
5878
@@ -63,20 +83,18 @@ of function calls, packet creations, etc.).
6383
- [Google Python Style Guide](https://google.github.io/styleguide/pyguide.html)
6484
is a nice read!
6585
66-
- Avoid creating unnecessary `list` objects, particularly if they
67-
can be huge (e.g., when possible, use `for line in fdesc` instead of
68-
`for line in fdesc.readlines()`; more generally prefer generators over
69-
lists).
70-
7186
### Tests
7287
73-
Please consider adding tests for your new features or that trigger the
74-
bug you are fixing. This will prevent a regression from being
75-
unnoticed. Do not use the variable `_` in your tests, as it could break them.
88+
We require adding tests for all new features or bug fixes, or a justification as to why they are not relevant. We know it's annoying, but Scapy is all about parsing and dissecting weird protocols us maintainers will never encounter. Having good tests is the only way to keep the code maintainable.
89+
90+
- If you are fixing a bug, provide a one-liner that reproduced the bug you are fixing.
91+
- If you are introducing dissectors, provide at least a very simple "dissect" / "build" of real packets with simple assertions.
92+
- Tests can be very simple. It's much better to have dumb tests that break when one does changes than no tests.
93+
- Do not use the variable `_` in your tests, as it could break them.
7694
7795
If you find yourself in a situation where your tests locally succeed but
7896
fail if executed on the CI, try to enable the debugging option for the
79-
dissector by setting `conf.debug_dissector = 1`.
97+
dissector by setting `conf.debug_dissector = 1`. In doubt, feel free to ask maintainers for help.
8098
8199
### New protocols
82100

0 commit comments

Comments
 (0)