Skip to content

Commit 0f8b0c9

Browse files
author
Nils Weiss
committed
Merge branch 'master' into coap_sockets
2 parents c11be37 + 7adf2c3 commit 0f8b0c9

9 files changed

Lines changed: 256 additions & 206 deletions

File tree

.gitlab-ci.yml

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
2+
.default:
3+
image: python:3.11
4+
tags:
5+
- docker-ipv6
6+
before_script:
7+
- pip install tox
8+
9+
health:
10+
extends: .default
11+
script:
12+
- tox -e flake8
13+
- tox -e spell
14+
- tox -e twine
15+
16+
mypy:
17+
extends: .default
18+
script:
19+
- tox -e mypy
20+
21+
py311:
22+
image: dissecto/scapy-tests:latest
23+
tags:
24+
- docker-ipv6
25+
script:
26+
- ./.config/ci/test.sh 3.11 non_root
27+
28+
pypy3:
29+
image: dissecto/scapy-tests-pypy:latest
30+
tags:
31+
- docker-ipv6
32+
script:
33+
- ./.config/ci/test.sh pypy3 non_root
34+
35+
.publish:
36+
image: python:latest
37+
needs:
38+
- pypy3
39+
- py311
40+
- mypy
41+
- health
42+
tags:
43+
- docker
44+
script:
45+
- pip install build twine
46+
- python -m build
47+
- TWINE_PASSWORD=${CI_JOB_TOKEN} TWINE_USERNAME=gitlab-ci-token python -m twine upload --verbose --repository-url ${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/pypi dist/*
48+
49+
deploy:
50+
extends: .publish
51+
rules:
52+
- if: '$CI_COMMIT_TAG'
53+
when: always
54+
- when: never
55+
allow_failure: true

AGENTS.md

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# AGENTS.md
2+
3+
## Scope and source of truth
4+
- Work in the top-level tree (`/scapy`), not the vendored release snapshot (`/scapy-2.7.1.dev...`) or `build/` artifacts.
5+
- Start with `README.md`, `CONTRIBUTING.md`, `tox.ini`, and `test/run_tests` before changing behavior.
6+
7+
## Big-picture architecture
8+
- Public API aggregation is import-driven: `scapy/all.py` pulls core modules, then `scapy/layers/all.py` autoloads layer modules from `conf.load_layers` (`scapy/config.py`).
9+
- Core packet model is `Packet` (`scapy/packet.py`): layers are stacked with `/`, dissection/build behavior hangs off `fields_desc`, `payload_guess`, and `post_build`.
10+
- Layer binding is declarative and two-way via `bind_layers()` / `split_layers()` (`scapy/packet.py`); this controls both build-time field overloading and dissect-time next-layer guessing.
11+
- Runtime/CLI bootstrapping lives in `scapy/main.py` (`interact`, `load_layer`, `load_contrib`, extension loading).
12+
- Platform socket backends are selected centrally in `scapy/config.py` (`conf.use_pcap`, `conf.use_bpf`, OS-specific `scapy/arch/*`).
13+
14+
## Where to place new code
15+
- Common protocols -> `scapy/layers/`; uncommon/vendor-specific -> `scapy/contrib/` (see `CONTRIBUTING.md`).
16+
- `scapy/layers/*` must not import `scapy/contrib/*`; `contrib` may import either.
17+
- Contrib modules must declare metadata headers near the top, e.g. in `scapy/contrib/automotive/scanner/graph.py`:
18+
- `# scapy.contrib.description = ...`
19+
- `# scapy.contrib.status = ...`
20+
21+
## Developer workflows that match CI
22+
- Fast local baseline (no extra external tools): `./test/run_tests`
23+
- Direct UTScapy run with config file: `python -m scapy.tools.UTscapy -c test/configs/linux.utsc`
24+
- Lint/type/docs parity with CI: `tox -e flake8`, `tox -e mypy`, `tox -e docs`, `tox -e spell`
25+
- Full matrix behavior is driven by `.github/workflows/unittests.yml` + `.config/ci/test.sh` (keyword skips via `UT_FLAGS`, root/non-root split, OS-specific toggles).
26+
27+
## Project-specific conventions
28+
- Keep hot-path core changes lean (`scapy/packet.py`, `scapy/base_classes.py`): performance and allocation overhead matter.
29+
- Logging policy is strict (`CONTRIBUTING.md`): prefer `scapy.error.log_runtime` for runtime behavior; use `log_interactive` only for interactive-shell-only messages.
30+
- Test style is UTScapy-first (`test/*.uts`, `test/scapy/**/*.uts`): last expression decides pass/fail; keyword include/exclude (`-k` / `-K`) is heavily used.
31+
- Preserve SPDX/license headers and existing typing-comment style (`# type:`) where present.
32+
33+
## Integration points and dependencies
34+
- Optional features are capability-gated in `scapy/config.py` (notably `cryptography`, libpcap/bpf selection, extension manager `conf.exts`).
35+
- Some features depend on external binaries configured via `conf.prog` (`tcpdump`, `tshark`, `wireshark`, `dot`).
36+
- Docs and API tree are Sphinx-based (`doc/scapy/`, `tox -e docs`, `tox -e apitree`).
37+
- Test selection/behavior depends on `test/configs/*.utsc` preexec hooks (for example loading `tls` or contrib modules before campaigns).
38+

pyproject.toml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
[build-system]
2-
requires = [ "setuptools>=62.0.0" ]
2+
requires = ["setuptools>=64.0", "setuptools-scm>=8.0"]
33
build-backend = "setuptools.build_meta"
44

55
[project]
66
name = "scapy"
7-
dynamic = [ "version", "readme" ]
7+
dynamic = [ "version"]
8+
readme = "README.md"
89
authors = [
910
{ name="Philippe BIONDI" },
1011
{ name="Gabriel POTTER" },
@@ -81,8 +82,7 @@ exclude = [
8182
"doc*",
8283
]
8384

84-
[tool.setuptools.dynamic]
85-
version = { attr="scapy.VERSION" }
85+
[tool.setuptools_scm]
8686

8787
# coverage
8888

scapy/contrib/automotive/scanner/graph.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,13 @@ def add_edge(self, edge, transition_function=None):
5454
:param edge: edge from node to node
5555
:param transition_function: tuple with enter and cleanup function
5656
"""
57-
if edge[1] in self.edges[edge[0]]:
58-
# Edge already exists
59-
return
57+
try:
58+
if edge[1] in self.edges[edge[0]]:
59+
# Edge already exists
60+
return
61+
except KeyError:
62+
pass
63+
6064
self.edges[edge[0]].append(edge[1])
6165
self.weights[edge] = 1
6266
self.__transition_functions[edge] = transition_function

0 commit comments

Comments
 (0)