diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 5f45e81..1e6e2af 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -29,7 +29,7 @@ jobs: sudo apt-get update - name: Git LFS Pull for deployment - run: | + run: | echo "Pulling all Git LFS" git lfs pull -I **/challenges/**/ansible/**/* diff --git a/.gitignore b/.gitignore index d41f21e..c380743 100644 --- a/.gitignore +++ b/.gitignore @@ -19,4 +19,4 @@ challenges/*/terraform/versions.tf .vscode/ .idea -stats.html \ No newline at end of file +stats.html diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000..f31d5f6 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,21 @@ +repos: + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: v6.0.0 + hooks: + - id: end-of-file-fixer + - id: trailing-whitespace + + - repo: local + hooks: + - id: format + name: Format + entry: ruff format + language: python + pass_filenames: false + additional_dependencies: [ruff] + - id: fix-imports + name: Fix imports + entry: ruff check --fix --show-fixes + language: python + pass_filenames: false + additional_dependencies: [ruff] diff --git a/README.md b/README.md index 5ad2cb3..dd13b39 100644 --- a/README.md +++ b/README.md @@ -32,7 +32,7 @@ tree until it finds `challenges/` and `.deploy` directories, which is the root o ```raw my-ctf/ ├── challenges/ # Directory containing all the tracks -│ ├── track1/ # Directory for a specific track that contains N flags. +│ ├── track1/ # Directory for a specific track that contains N flags. │ │ ├── track.yaml # Main file that describes the track │ │ ├── files/ # Directory that contains all the files available for download in the track │ │ │ ├── somefile.zip diff --git a/challenges/mock-track-apache-php/ansible/challenge/index.php b/challenges/mock-track-apache-php/ansible/challenge/index.php index 6232b39..a5c00f6 100644 --- a/challenges/mock-track-apache-php/ansible/challenge/index.php +++ b/challenges/mock-track-apache-php/ansible/challenge/index.php @@ -1,2 +1,2 @@ - \ No newline at end of file + diff --git a/challenges/mock-track-apache-php/posts/mock-track-apache-php-flag1.yaml b/challenges/mock-track-apache-php/posts/mock-track-apache-php-flag1.yaml index 130fb98..16ff10c 100644 --- a/challenges/mock-track-apache-php/posts/mock-track-apache-php-flag1.yaml +++ b/challenges/mock-track-apache-php/posts/mock-track-apache-php-flag1.yaml @@ -7,4 +7,4 @@ api: user: nsec title: "Mock Track Apache PHP" body: |- - Mock Track Apache PHP body. \ No newline at end of file + Mock Track Apache PHP body. diff --git a/challenges/mock-track-apache-php/posts/mock-track-apache-php.yaml b/challenges/mock-track-apache-php/posts/mock-track-apache-php.yaml index e23c59c..2cb6b27 100644 --- a/challenges/mock-track-apache-php/posts/mock-track-apache-php.yaml +++ b/challenges/mock-track-apache-php/posts/mock-track-apache-php.yaml @@ -3,4 +3,4 @@ api: user: nsec title: "Mock Track Apache PHP body." body: |- - Mock Track Apache PHP body. \ No newline at end of file + Mock Track Apache PHP body. diff --git a/challenges/mock-track-files-only/posts/mock-track-files-only-flag1.yaml b/challenges/mock-track-files-only/posts/mock-track-files-only-flag1.yaml index 55181c7..351cd63 100644 --- a/challenges/mock-track-files-only/posts/mock-track-files-only-flag1.yaml +++ b/challenges/mock-track-files-only/posts/mock-track-files-only-flag1.yaml @@ -7,4 +7,4 @@ api: user: nsec title: "Mock Track Files Only" body: |- - Mock Track Files Only body \ No newline at end of file + Mock Track Files Only body diff --git a/challenges/mock-track-files-only/posts/mock-track-files-only.yaml b/challenges/mock-track-files-only/posts/mock-track-files-only.yaml index 2702141..9ea33ac 100644 --- a/challenges/mock-track-files-only/posts/mock-track-files-only.yaml +++ b/challenges/mock-track-files-only/posts/mock-track-files-only.yaml @@ -3,4 +3,4 @@ api: user: nsec title: "Mock Track Files Only" body: |- - Mock Track Files Only body \ No newline at end of file + Mock Track Files Only body diff --git a/challenges/mock-track-python-service/posts/mock-track-python-service-flag1.yaml b/challenges/mock-track-python-service/posts/mock-track-python-service-flag1.yaml index 2bd32db..caa3a75 100644 --- a/challenges/mock-track-python-service/posts/mock-track-python-service-flag1.yaml +++ b/challenges/mock-track-python-service/posts/mock-track-python-service-flag1.yaml @@ -7,4 +7,4 @@ api: user: nsec title: "Mock Track Python Service" body: |- - Mock Track Python Service body \ No newline at end of file + Mock Track Python Service body diff --git a/challenges/mock-track-python-service/posts/mock-track-python-service-flag2.yaml b/challenges/mock-track-python-service/posts/mock-track-python-service-flag2.yaml index 2d06687..cfc5f15 100644 --- a/challenges/mock-track-python-service/posts/mock-track-python-service-flag2.yaml +++ b/challenges/mock-track-python-service/posts/mock-track-python-service-flag2.yaml @@ -7,4 +7,4 @@ api: user: nsec title: "Mock Track Python Service" body: |- - Mock Track Python Service body \ No newline at end of file + Mock Track Python Service body diff --git a/challenges/mock-track-python-service/posts/mock-track-python-service.yaml b/challenges/mock-track-python-service/posts/mock-track-python-service.yaml index 516957b..4809ddc 100644 --- a/challenges/mock-track-python-service/posts/mock-track-python-service.yaml +++ b/challenges/mock-track-python-service/posts/mock-track-python-service.yaml @@ -4,4 +4,4 @@ api: user: nsec title: "Mock Track Python Service" body: |- - Mock Track Python Service body \ No newline at end of file + Mock Track Python Service body diff --git a/challenges/mock-track-python-service/track.yaml b/challenges/mock-track-python-service/track.yaml index b05dcb5..4b3cae2 100644 --- a/challenges/mock-track-python-service/track.yaml +++ b/challenges/mock-track-python-service/track.yaml @@ -28,4 +28,4 @@ services: instance: mock-track-python-service address: '9000:d37e:c40b:b29a:216:3eff:fe09:23ea' port: 5000 - check: http \ No newline at end of file + check: http diff --git a/ctf/templates/init/.deploy/common/dns.tf b/ctf/templates/init/.deploy/common/dns.tf index 47524d7..63ee9a6 100644 --- a/ctf/templates/init/.deploy/common/dns.tf +++ b/ctf/templates/init/.deploy/common/dns.tf @@ -7,4 +7,4 @@ resource "incus_network_zone" "this" { output "ctf_dns_network_zone" { value = incus_network_zone.this.name -} \ No newline at end of file +} diff --git a/ctf/templates/init/.devcontainer/devcontainer.json b/ctf/templates/init/.devcontainer/devcontainer.json index 8b748cf..a80dbf8 100644 --- a/ctf/templates/init/.devcontainer/devcontainer.json +++ b/ctf/templates/init/.devcontainer/devcontainer.json @@ -15,4 +15,4 @@ "--volume", "/dev:/dev", "--volume", "/lib/modules:/lib/modules:ro" ] -} \ No newline at end of file +} diff --git a/ctf/templates/init/.vscode/extensions.json b/ctf/templates/init/.vscode/extensions.json index fb6942c..9f1bac1 100644 --- a/ctf/templates/init/.vscode/extensions.json +++ b/ctf/templates/init/.vscode/extensions.json @@ -5,4 +5,4 @@ "github.codespaces", "redhat.ansible" ] -} \ No newline at end of file +} diff --git a/ctf/templates/init/.vscode/settings.json b/ctf/templates/init/.vscode/settings.json index 5f71f0b..63a1b0b 100644 --- a/ctf/templates/init/.vscode/settings.json +++ b/ctf/templates/init/.vscode/settings.json @@ -6,4 +6,4 @@ "schemas/track.yaml.json": "challenges/*/track.yaml", "schemas/post.json": "challenges/*/posts/*.yaml" } -} \ No newline at end of file +} diff --git a/ctf/templates/init/README.md b/ctf/templates/init/README.md index 05fd1ce..ec96661 100644 --- a/ctf/templates/init/README.md +++ b/ctf/templates/init/README.md @@ -288,4 +288,4 @@ flags: ui_gif: my-awesome-gif.gif ``` -2. If you are choosing to use a custom sound and not defaults ones in the `ctf` track folder, you must add them in `challenges/my-awesome-track/files/askgod/(sounds|gifs)/`. Example: `challenges/my-awesome-track/files/askgod/sounds/my-awesome-sound.mp3`. \ No newline at end of file +2. If you are choosing to use a custom sound and not defaults ones in the `ctf` track folder, you must add them in `challenges/my-awesome-track/files/askgod/(sounds|gifs)/`. Example: `challenges/my-awesome-track/files/askgod/sounds/my-awesome-sound.mp3`. diff --git a/ctf/templates/init/schemas/post.json b/ctf/templates/init/schemas/post.json index f548068..5d466d9 100644 --- a/ctf/templates/init/schemas/post.json +++ b/ctf/templates/init/schemas/post.json @@ -140,4 +140,4 @@ } } } -} \ No newline at end of file +} diff --git a/ctf/templates/init/setup-codespace b/ctf/templates/init/setup-codespace index c0742b3..febf8d9 100644 --- a/ctf/templates/init/setup-codespace +++ b/ctf/templates/init/setup-codespace @@ -41,4 +41,4 @@ sudo zfs set sync=disabled default echo "==> Installing ctf tool" pip install -e . -echo "==> You're all done, you can now run \"ctf deploy\"" \ No newline at end of file +echo "==> You're all done, you can now run \"ctf deploy\"" diff --git a/ctf/templates/new/common/README.md.j2 b/ctf/templates/new/common/README.md.j2 index 9deed62..506d6b5 100644 --- a/ctf/templates/new/common/README.md.j2 +++ b/ctf/templates/new/common/README.md.j2 @@ -12,4 +12,4 @@ TODO CHANGE_ME: This track incorporates as the control center of a satelite movi ### Flag 1 -TODO CHANGE_ME: This is a walkthrough of how to get the first flag. \ No newline at end of file +TODO CHANGE_ME: This is a walkthrough of how to get the first flag. diff --git a/ctf/templates/new/common/inventory.j2 b/ctf/templates/new/common/inventory.j2 index 8c4eda7..fd2796b 100644 --- a/ctf/templates/new/common/inventory.j2 +++ b/ctf/templates/new/common/inventory.j2 @@ -41,4 +41,4 @@ windows: vars: # This variable is used to tell Ansible that the hosts are Windows hosts and require a PowerShell shell. ansible_shell_type: powershell -{% endif %} \ No newline at end of file +{% endif %} diff --git a/ctf/templates/new/windows-vm/deploy.yaml.j2 b/ctf/templates/new/windows-vm/deploy.yaml.j2 index e7d12f7..5648beb 100644 --- a/ctf/templates/new/windows-vm/deploy.yaml.j2 +++ b/ctf/templates/new/windows-vm/deploy.yaml.j2 @@ -16,7 +16,7 @@ value: "{{ '{{ item.flag }}' }}" ansible.builtin.set_fact: track_flags: "{{ '{{ track_flags | default({}) | combine({key: value}) }}' }}" - + - name: "Running free form: directly with the executable (PowerShell)" ansible.builtin.raw: | powershell -c $systeminfo = Get-ComputerInfo diff --git a/ctf/utils.py b/ctf/utils.py index 0a51e0d..ad78440 100644 --- a/ctf/utils.py +++ b/ctf/utils.py @@ -150,7 +150,7 @@ def create_terraform_modules_file(remote: str, production: bool = False): {% if production %}deploy = "production"{% endif %} {% if remote %}incus_remote = "{{ remote }}"{% endif %} } - + """ ) ) diff --git a/pyproject.toml b/pyproject.toml index 2f17097..23fdf3b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -27,7 +27,13 @@ classifiers = [ ] [project.optional-dependencies] -workflow = ["pybadges", "matplotlib", "standard-imghdr ; python_version >= \"3.13\""] +dev = ["pre-commit", "ruff"] +workflow = [ + "pybadges", + "matplotlib", + "standard-imghdr ; python_version >= \"3.13\"", + "ctf-script[dev]" +] [project.scripts] ctf = "ctf.__main__:main"