Skip to content

Commit 8fe4f49

Browse files
committed
Add pre-commit checks
1 parent 8ed0f4c commit 8fe4f49

13 files changed

+58
-17
lines changed

.gitattributes

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@
55
*.py text
66

77
# Every shell file must be cloned with LF line ending
8-
*.sh text eol=lf
8+
*.sh text eol=lf

.github/ISSUE_TEMPLATE/bug_report.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ body:
88
attributes:
99
value: |
1010
Verification before publication:
11-
12-
- You are creating a bug report in the Exegol **WRAPPER** repository (the exegol command)!
11+
12+
- You are creating a bug report in the Exegol **WRAPPER** repository (the exegol command)!
1313
> If your problem concerns the environment, tools or other elements specific to the Exegol **IMAGE**, please open your issue on the [Exegol-images](https://github.com/ThePorgs/Exegol-images) repository.
1414
- Check that there is not already a issue for the **same** problem.
1515
- Some problems are already well known and can be found in the **documentation** or on the Exegol **Discord**.

.github/ISSUE_TEMPLATE/feature_request.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ body:
88
value: |
99
Verification before publication:
1010
11-
- You are creating a feature request in the Exegol **WRAPPER** repository (the exegol command)!
11+
- You are creating a feature request in the Exegol **WRAPPER** repository (the exegol command)!
1212
> If your request concerns the exegol environment, tools or other elements specific to the Exegol **IMAGE**, please open your issue on the [Exegol-images](https://github.com/ThePorgs/Exegol-images) repository.
1313
- Check that there is not already your feature request on the Exegol **roadmap** (can be consulted in the **documentation** or on the Exegol **Discord**)
1414

.github/workflows/entrypoint_prerelease.yml

-1
Original file line numberDiff line numberDiff line change
@@ -40,4 +40,3 @@ jobs:
4040
name: Python tests and checks
4141
needs: preprod_test
4242
uses: ./.github/workflows/sub_testing.yml
43-

.github/workflows/sub_testing.yml

+2
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ jobs:
2323
run: pdm run -v mypy ./exegol.py --ignore-missing-imports --check-untyped-defs --pretty # TODO add --disallow-untyped-defs
2424
- name: Find spawn.sh script version
2525
run: egrep '^# Spawn Version:[0-9ab]+$' ./exegol/utils/imgsync/spawn.sh | cut -d ':' -f2
26+
- name: Pre-commit checks
27+
run: pdm run -v pre-commit run --all-files --hook-stage pre-commit
2628

2729
compatibility:
2830
name: Compatibility checks

.pre-commit-config.yaml

+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# See https://pre-commit.com for more information
2+
# See https://pre-commit.com/hooks.html for more hooks
3+
default_install_hook_types: [ pre-commit, pre-push ]
4+
repos:
5+
- repo: https://github.com/pre-commit/pre-commit-hooks
6+
rev: v5.0.0
7+
hooks:
8+
- id: trailing-whitespace
9+
exclude: 'exegol/config/UserConfig.py'
10+
- id: end-of-file-fixer
11+
- id: check-yaml
12+
- id: check-toml
13+
- id: check-shebang-scripts-are-executable
14+
- id: check-case-conflict
15+
- id: name-tests-test
16+
- id: check-illegal-windows-names
17+
- id: mixed-line-ending
18+
args:
19+
- --fix=lf
20+
- id: check-added-large-files
21+
args:
22+
- --maxkb=200 # Max 200kb file can be added
23+
- repo: https://github.com/pre-commit/pygrep-hooks
24+
rev: v1.10.0
25+
hooks:
26+
- id: python-no-eval
27+
- id: python-use-type-annotations
28+
- repo: https://github.com/shellcheck-py/shellcheck-py
29+
rev: v0.10.0.1
30+
hooks:
31+
- id: shellcheck
32+
- repo: https://github.com/pre-commit/mirrors-mypy
33+
rev: 'v1.15.0'
34+
hooks:
35+
- id: mypy
36+
stages: [pre-push]
37+
additional_dependencies: ["types-PyYAML", "types-requests", "types-tzlocal"]
38+
exclude: "exegol.py"
39+
args:
40+
- --ignore-missing-imports
41+
- --check-untyped-defs
42+
- --pretty

CONTRIBUTING.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ Check the full contributors (up-to-date) documentation here: https://exegol.read
77
- the `Exegol` repository includes the exegol.py wrapper code base, and features a `exegol-docker-build` submodule tracking [Exegol-images](https://github.com/ThePorgs/Exegol-images).
88
- changes to the images/dockerfiles/tools/installs must be done on the [Exegol-images](https://github.com/ThePorgs/Exegol-images) repo.
99
- by default, the wrapper pulls the latest DockerHub pre-built image for the install and updates
10-
- DockerHub automatic builds are configured as follows
11-
- `nightly` image is built using the base Dockerfile whenever a commit is made on [Exegol-images](https://github.com/ThePorgs/Exegol-images) `dev` branch.
10+
- DockerHub automatic builds are configured as follows
11+
- `nightly` image is built using the base Dockerfile whenever a commit is made on [Exegol-images](https://github.com/ThePorgs/Exegol-images) `dev` branch.
1212
- `full` image is built using the base Dockerfile whenever a new tag is pushed on [Exegol-images](https://github.com/ThePorgs/Exegol-images).
1313
- `ad`, `osint`, `web` and `light` images are built using specific Dockerfiles whenever a new tag is pushed on [Exegol-images](https://github.com/ThePorgs/Exegol-images).
1414
- if you want to locally build your image with your changes, run `exegol install local`. If you have local changes to the dockerfiles, they won't be overwritten.

README.md

-1
Original file line numberDiff line numberDiff line change
@@ -58,4 +58,3 @@ Below are some bullet points to better understand how Exegol works
5858
</div>
5959

6060
Dramelac and I work at [Capgemini](https://www.capgemini.com/) and we thank them for believing in the project since day 1, and for allowing us to have this personal initiative keep going.
61-

exegol/config/DataCache.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ class DataCache(DataFileUtils, metaclass=MetaSingleton):
1818
last_version: STR
1919
}
2020
}
21-
images:
21+
images:
2222
metadata: {
2323
last_check: DATE
2424
}

exegol/config/UserConfig.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -70,22 +70,22 @@ def _build_file_content(self) -> str:
7070
enable_exegol_resources: {self.enable_exegol_resources}
7171
7272
# Change the configuration of the shell logging functionality
73-
shell_logging:
73+
shell_logging:
7474
#Choice of the method used to record the sessions (script or asciinema)
7575
logging_method: {self.shell_logging_method}
7676
7777
# Enable automatic compression of log files (with gzip)
7878
enable_log_compression: {self.shell_logging_compress}
79-
79+
8080
# Configure your Exegol Desktop
8181
desktop:
8282
# Enables or not the desktop mode by default
8383
# If this attribute is set to True, then using the CLI --desktop option will be inverted and will DISABLE the feature
8484
enabled_by_default: {self.desktop_default_enable}
85-
85+
8686
# Default desktop protocol,can be "http", or "vnc" (additional protocols to come in the future, check online documentation for updates).
8787
default_protocol: {self.desktop_default_proto}
88-
88+
8989
# Desktop service is exposed on localhost by default. If set to true, services will be exposed on localhost (127.0.0.1) otherwise it will be exposed on 0.0.0.0. This setting can be overwritten with --desktop-config
9090
localhost_by_default: {self.desktop_default_localhost}
9191

exegol/model/ExegolContainer.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -370,7 +370,7 @@ def __applyX11ACLs(self) -> None:
370370
return
371371

372372
# If the left part of the display variable is "localhost", x11 socket is exposed only on loopback and remote access is used
373-
# If the container is not in host mode, it won't be able to reach the loopback interface of the host
373+
# If the container is not in host mode, it won't be able to reach the loopback interface of the host
374374
if display_host == "localhost" and self.config.getNetworkMode() != "host":
375375
logger.warning("X11 forwarding won't work on a bridged container unless you specify \"X11UseLocalhost no\" in your host sshd_config")
376376
logger.warning("[red]Be aware[/red] changing \"X11UseLocalhost\" value can [red]expose your device[/red], correct firewalling is [red]required[/red]")

exegol/utils/imgsync/entrypoint.sh

+2-3
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,8 @@ function endless() {
3333
finish
3434
# Entrypoint for the container, in order to have a process hanging, to keep the container alive
3535
# Alternative to running bash/zsh/whatever as entrypoint, which is longer to start and to stop and to very clean
36-
# shellcheck disable=SC2162
3736
mkfifo -m 000 /tmp/.entrypoint # Create an empty fifo for sleep by read.
38-
read <> /tmp/.entrypoint # read from /tmp/.entrypoint => endlessly wait without sub-process or need for TTY option
37+
read -r <> /tmp/.entrypoint # read from /tmp/.entrypoint => endlessly wait without sub-process or need for TTY option
3938
}
4039

4140
function shutdown() {
@@ -68,7 +67,7 @@ function _resolv_docker_host() {
6867
# Add docker internal host resolution to the hosts file to preserve access to the X server
6968
echo "$DOCKER_IP host.docker.internal" >>/etc/hosts
7069
# If the container share the host networks, no need to add a static mapping
71-
ip route list match "$DOCKER_IP" table all | grep -v default || ip route add "$DOCKER_IP/32" $(ip route list | grep default | head -n1 | grep -Eo '(via [0-9]+\.[0-9]+\.[0-9]+\.[0-9]+ )?dev [a-zA-Z0-9]+') || echo '[W]Exegol cannot add a static route to resolv your host X11 server. GUI applications may not work.'
70+
ip route list match "$DOCKER_IP" table all | grep -v default || ip route add "$DOCKER_IP/32" "$(ip route list | grep default | head -n1 | grep -Eo '(via [0-9]+\.[0-9]+\.[0-9]+\.[0-9]+ )?dev [a-zA-Z0-9]+')" || echo '[W]Exegol cannot add a static route to resolv your host X11 server. GUI applications may not work.'
7271
fi
7372
}
7473

File renamed without changes.

0 commit comments

Comments
 (0)