Skip to content

Commit a08a12d

Browse files
committed
fix for entrypoint, added entrypoint-test job
1 parent 3dfe730 commit a08a12d

File tree

5 files changed

+81
-14
lines changed

5 files changed

+81
-14
lines changed

.github/workflows/entrypoints.yml

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
---
2+
3+
name: Test Entrypoints
4+
5+
on:
6+
workflow_dispatch:
7+
push:
8+
branches: [latest]
9+
paths:
10+
- '**.py'
11+
- '.github/workflows/entrypoints.yml'
12+
- 'requirements.txt'
13+
- 'requirements_build.txt'
14+
pull_request:
15+
branches: [latest]
16+
paths:
17+
- '**.py'
18+
- '.github/workflows/entrypoints.yml'
19+
- 'requirements.txt'
20+
- 'requirements_build.txt'
21+
jobs:
22+
test:
23+
runs-on: ubuntu-latest
24+
timeout-minutes: 2
25+
defaults:
26+
run:
27+
shell: bash
28+
29+
steps:
30+
- name: Checkout
31+
uses: actions/checkout@v3
32+
with:
33+
ref: ${{ github.ref }}
34+
35+
- name: Install python
36+
uses: actions/setup-python@v4
37+
with:
38+
python-version: '3.11'
39+
40+
- name: Install dependencies
41+
run: |
42+
pip install -r requirements_build.txt >/dev/null
43+
pip install -r requirements.txt >/dev/null
44+
45+
- name: Testing to install as PIP-Module
46+
run: |
47+
PATH_REPO="$(pwd)"
48+
PATH_VENV="/tmp/ftf_venv"
49+
python3 -m virtualenv "$PATH_VENV" > /dev/null
50+
cd /tmp
51+
PYTHONPATH=''
52+
source "${PATH_VENV}/bin/activate"
53+
python3 -m pip install -e "$PATH_REPO" > /dev/null
54+
55+
- name: Testing to execute entrypoints
56+
run: |
57+
PATH_VENV="/tmp/ftf_venv"
58+
source "${PATH_VENV}/bin/activate"
59+
60+
ftf-ci --help >/dev/null
61+
ftf-cli --help >/dev/null
62+
ftf-shell --help >/dev/null

README.md

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
[![Lint](https://github.com/O-X-L/firewall-testing-framework/actions/workflows/lint.yml/badge.svg?branch=latest)](https://github.com/O-X-L/firewall-testing-framework/actions/workflows/lint.yml)
44
[![Test](https://github.com/O-X-L/firewall-testing-framework/actions/workflows/test.yml/badge.svg?branch=latest)](https://github.com/O-X-L/firewall-testing-framework/actions/workflows/test.yml)
5+
[![Test Entrypoints](https://github.com/O-X-L/firewall-testing-framework/actions/workflows/entrypoints.yml/badge.svg?branch=latest)](https://github.com/O-X-L/firewall-testing-framework/actions/workflows/entrypoints.yml)
56

67
A framework for **testing and troubleshooting firewall rulesets**.
78

@@ -31,31 +32,32 @@ ftf-cli --firewall-system 'linux_netfilter' \
3132
> 🛈 ROUTER: Packet inbound-interface: wan
3233
> 🛈 ROUTER: Packet inbound-route: 0.0.0.0/0, gw 10.255.255.254, metric 600, scope remote
3334
> 🛈 FIREWALL: Processing Chain: Table nat ip4 | Chain PREROUTING ip4 nat
34-
> 🛈 FIREWALL: > Chain PREROUTING | Rule 0
35+
> 🛈 FIREWALL: > Chain PREROUTING | Rule 0 | Match => jump
3536
> 🛈 FIREWALL: > Chain PREROUTING | Sub-Chain: DOCKER
3637
> 🛈 FIREWALL: > Chain DOCKER | Rule 0
3738
> 🛈 FIREWALL: > Chain DOCKER | Rule 1
3839
> 🛈 ROUTER: Packet outbound-interface: docker0
3940
> 🛈 ROUTER: Packet outbound-route: 172.17.0.0/16, scope link
4041
> 🛈 FIREWALL: Processing Chain: Table filter ip4 | Chain FORWARD ip4 filter
41-
> 🛈 FIREWALL: > Chain FORWARD | Rule 0
42+
> 🛈 FIREWALL: > Chain FORWARD | Rule 0 | Match => jump
4243
> 🛈 FIREWALL: > Chain FORWARD | Sub-Chain: DOCKER-USER
43-
> 🛈 FIREWALL: > Chain DOCKER-USER | Rule 0
44-
> 🛈 FIREWALL: > Chain FORWARD | Rule 1
44+
> 🛈 FIREWALL: > Chain DOCKER-USER | Rule 0 | Match => return
45+
> 🛈 FIREWALL: > Chain FORWARD | Rule 1 | Match => jump
4546
> 🛈 FIREWALL: > Chain FORWARD | Sub-Chain: DOCKER-FORWARD
46-
> 🛈 FIREWALL: > Chain DOCKER-FORWARD | Rule 0
47+
> 🛈 FIREWALL: > Chain DOCKER-FORWARD | Rule 0 | Match => jump
4748
> 🛈 FIREWALL: > Chain DOCKER-FORWARD | Sub-Chain: DOCKER-CT
48-
> 🛈 FIREWALL: > Chain DOCKER-CT | Rule 0
49-
> 🛈 FIREWALL: > Chain DOCKER-FORWARD | Rule 1
49+
> 🛈 FIREWALL: > Chain DOCKER-CT | Rule 0 | Match => accept
50+
> 🛈 FIREWALL: > Chain DOCKER-FORWARD | Rule 1 | Match => jump
5051
> 🛈 FIREWALL: > Chain DOCKER-FORWARD | Sub-Chain: DOCKER-ISOLATION-STAGE-1
5152
> 🛈 FIREWALL: > Chain DOCKER-ISOLATION-STAGE-1 | Rule 0
52-
> 🛈 FIREWALL: > Chain DOCKER-FORWARD | Rule 2
53+
> 🛈 FIREWALL: > Chain DOCKER-FORWARD | Rule 2 | Match => jump
5354
> 🛈 FIREWALL: > Chain DOCKER-FORWARD | Sub-Chain: DOCKER-BRIDGE
54-
> 🛈 FIREWALL: > Chain DOCKER-BRIDGE | Rule 0
55+
> 🛈 FIREWALL: > Chain DOCKER-BRIDGE | Rule 0 | Match => jump
5556
> 🛈 FIREWALL: > Chain DOCKER-BRIDGE | Sub-Chain: DOCKER
5657
> 🛈 FIREWALL: > Chain DOCKER | Rule 0
57-
> 🛈 FIREWALL: > Chain DOCKER | Rule 1
58+
> 🛈 FIREWALL: > Chain DOCKER | Rule 1 | Match => drop
5859
> ✖ FIREWALL: Packet blocked by rule: {'action': 'drop', 'seq': 1, 'raw': Rule: #22 | Matches: [ni_in != ['docker0'], ni_out == ['docker0']]}
60+
5961
```
6062

6163
----

pyproject.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ requires = ["setuptools >= 61.0"]
33
build-backend = "setuptools.build_meta"
44

55
[project]
6-
name = "ftf"
6+
name = "firewall-test"
77
authors = [
88
{name = "Rath Pascal", email = "[email protected]"},
99
]
@@ -30,6 +30,7 @@ version = {file = ["VERSION"]}
3030

3131
[tool.setuptools.packages.find]
3232
where = ["src"]
33+
exclude = ["*_test.py"]
3334

3435
[tool.setuptools.package-data]
3536
"*" = ["*.txt"]

scripts/build.sh

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,9 @@ cd /tmp
2525
PYTHONPATH=''
2626
source "${PATH_VENV}/bin/activate"
2727
python3 -m pip install -e "$PATH_REPO" > /dev/null
28-
firewall-test-ci --help >/dev/null
28+
ftf-ci --help >/dev/null
29+
ftf-cli --help >/dev/null
30+
ftf-shell --help >/dev/null
2931
deactivate
3032
echo ' => OK'
3133

src/firewall_test/cli.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,11 +76,11 @@ def main():
7676
environ.setdefault(ENV_VERBOSITY, args.verbosity)
7777
environ.setdefault(ENV_LOG_COLOR, '0' if args.no_color else '1')
7878

79-
if args.proto_l4 in ['tcp', 'udp']:
79+
if args.proto in ['tcp', 'udp']:
8080
packet = PacketTCPUDP(
8181
src=args.src_ip,
8282
dst=args.dst_ip,
83-
proto_l4=args.proto_l4,
83+
proto_l4=args.proto,
8484
)
8585

8686
else:

0 commit comments

Comments
 (0)