Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exegol 4.2.0 #152

Merged
merged 92 commits into from
May 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
92 commits
Select commit Hold shift + click to select a range
3bdcdba
Adding BH Europe 2022 Arsenal shield
ShutdownRepo Dec 10, 2022
fd21f8d
Add completion action
Dramelac Dec 22, 2022
248f7ce
Fix parameters name
Dramelac Dec 22, 2022
d718d76
Handle no image available for selection and dirty submodules
Dramelac Jan 4, 2023
a42f346
Add the ability to create a specific workspace folder on host + chang…
Dramelac Jan 4, 2023
3770389
Create pypi publish pipeline
Dramelac Feb 10, 2023
5a81895
Run test for prod deploy only
Dramelac Feb 10, 2023
179d26c
Add build number to the package version for nightly build
Dramelac Feb 10, 2023
804a351
Fix env syntax
Dramelac Feb 10, 2023
03863ac
Fix cleaning
Dramelac Feb 10, 2023
c409ccb
Change build version format
Dramelac Feb 10, 2023
e646df6
Revert custom version number
Dramelac Feb 10, 2023
edd6396
Add todo
Dramelac Feb 10, 2023
6c7efb3
Update capability list
Dramelac Feb 14, 2023
3181c80
Add custom hostname feature
Dramelac Feb 14, 2023
bd95896
Test new pipeline test
Dramelac Feb 19, 2023
234da73
Improve testing & fix type errors
Dramelac Feb 20, 2023
7673dde
Add compatibility check
Dramelac Feb 20, 2023
72cc179
Fix pipeline requirements
Dramelac Feb 20, 2023
c5b9135
Debug pipeline mode
Dramelac Feb 20, 2023
99b03fa
Fix version number str
Dramelac Feb 20, 2023
d7b0a67
Temp fix for mypy win32 parser
Dramelac Feb 20, 2023
4e439fe
Update workflows
Dramelac Feb 20, 2023
cac31c0
Merge branch 'cicd' into dev
Dramelac Feb 20, 2023
1ea423f
Update nightly trigger
Dramelac Feb 20, 2023
d3fe820
Update pipeline trigger
Dramelac Feb 23, 2023
1470177
Merge remote-tracking branch 'origin/dev' into completion
Dramelac Feb 23, 2023
5823db1
Fix hostname type
Dramelac Feb 23, 2023
7b58e75
Merge branch 'dev' into completion
Dramelac Feb 23, 2023
7cb0636
Testing new workflows
ShutdownRepo Feb 9, 2023
fc29b76
Updating workflows
ShutdownRepo Feb 18, 2023
195fb0f
Renaming workflows for better harmony across pipelines
ShutdownRepo Feb 23, 2023
0139259
switching v3 to v4 for actions/setup-python
ShutdownRepo Feb 23, 2023
6009392
forgot a v3 leftover
ShutdownRepo Feb 23, 2023
0fcb643
setting concurrency for external PR workflows
ShutdownRepo Feb 23, 2023
0c3c908
Renaming external PR workflows
ShutdownRepo Feb 26, 2023
c945d22
Test workflow trigger with *.py files
Dramelac Feb 27, 2023
5a9d209
Merge branch 'dev' into completion
Dramelac Feb 27, 2023
40a46c8
PoC argcompleter
Dramelac Feb 27, 2023
a8ab948
Adding todo to pipeline
ShutdownRepo Feb 28, 2023
e22b96a
Fixing arch color for container info
ShutdownRepo Feb 28, 2023
ed30f8d
Adding ability to comment containers
ShutdownRepo Feb 28, 2023
5c1f424
Filter unused labels
Dramelac Feb 28, 2023
7a19372
Fix typo
Dramelac Feb 28, 2023
42ebdbc
Add ContainerCompleter + ImageCompleter
Dramelac Mar 1, 2023
2b3adb1
Add some completer
Dramelac Mar 1, 2023
45d9e42
Fix VoidCompleter + Hybrid select
Dramelac Mar 8, 2023
6110c71
Opti argparse completer
Dramelac Mar 9, 2023
3df1535
Fix exec complete order
Dramelac Mar 9, 2023
e3461a2
Adding PR guidance
ShutdownRepo Mar 3, 2023
5f9533b
Added a warning message if DISPLAY env is not set on host
Mar 18, 2023
900d790
Remove X11 socket volume on Mac
Dramelac Apr 3, 2023
577b123
Detect orbstack as Mac docker engine
Dramelac Apr 3, 2023
1c893de
Remove /tmp docker desktop check
Dramelac Apr 3, 2023
4c28809
Remove shared resources check without docker desktop
Dramelac Apr 3, 2023
3199355
Fix etc volume sharing with orbstack
Dramelac Apr 3, 2023
5129f00
Orbstack dont support /etc volume
Dramelac Apr 3, 2023
be20de0
Handle cancellation from raw volume input
Dramelac Apr 3, 2023
2c4a0b4
Update readme documentation links
Dramelac Apr 3, 2023
49882cb
Fix old image without digest as updatable
Dramelac Apr 4, 2023
7efdb6f
Update log message
Dramelac Apr 4, 2023
2894106
Merge branch 'dev' into completion
Dramelac Apr 5, 2023
00b5462
Create DataFileUtils and refacto configs
Dramelac Apr 9, 2023
352168b
Upgrade dependencies version
Dramelac Apr 9, 2023
4af0ae4
Create new data cache system + new completer
Dramelac Apr 22, 2023
17c94c7
Fix model type getter
Dramelac Apr 22, 2023
0d479f4
Fix mypy errors
Dramelac Apr 23, 2023
cdd6edd
Update pypi CI parameters
Dramelac Apr 23, 2023
e01b49b
New dev beta version
Dramelac Apr 23, 2023
017265d
Add timeout for image caching
Dramelac Apr 24, 2023
314eb35
Add restart action
Dramelac Apr 24, 2023
41e72f4
Fixing fzf missing aliases and cicd tests
ShutdownRepo Apr 26, 2023
479e3d0
Fix directory completer + add void to comments
Dramelac Apr 28, 2023
7d21822
Handle json error decode
Dramelac Apr 28, 2023
d89fdb1
Fix image upgrade loading
Dramelac May 2, 2023
0630fe3
Fix exegol-resource installation
Dramelac May 2, 2023
2a8d839
Add TUI progress bar for git clone operation
Dramelac May 4, 2023
f8b73bf
Add TUI progress bar for single git submodule
Dramelac May 4, 2023
9e8e342
Autocompletion not case sensitive
Dramelac May 6, 2023
83b1bd4
Fix mypy errors
Dramelac May 6, 2023
4ed7056
Update start example description
Dramelac May 6, 2023
0c023f6
Add py 3.11 label
Dramelac May 6, 2023
7766c29
Fix image status after update
Dramelac May 7, 2023
a664e7f
Add pip upgrade warning
Dramelac May 8, 2023
affbb0f
Add commit id to the version in dev mode
Dramelac May 8, 2023
a6ef857
Remove old completion action
Dramelac May 8, 2023
1deb5c9
Remove newline
Dramelac May 8, 2023
0fd6b3c
Update new version
Dramelac May 8, 2023
b3d733c
Update image source submodule
Dramelac May 10, 2023
b339ae8
Adding BHA23 shield
ShutdownRepo May 10, 2023
f4468b6
Adding hrefs to BH badges
ShutdownRepo May 10, 2023
9ecc4fd
Adding target and rel attrs to hrefs
ShutdownRepo May 10, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Description

> A description of your PR, what it brings or corrects.
> A description of your PR, what it brings or corrects. Don't forget to configure your PR to the dev branch (cf. https://exegol.readthedocs.io/en/latest/community/contributors.html)

# Related issues

Expand Down
38 changes: 38 additions & 0 deletions .github/workflows/entrypoint_nightly.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: Nightly build

on:
push:
branches:
- "dev"
paths:
- "**.py"

jobs:
test:
name: Python tests and checks
uses: ./.github/workflows/sub_testing.yml

build-n-publish:
name: Build and publish Python 🐍 distributions to TestPyPI 📦
runs-on: ubuntu-latest
needs: test
steps:
- uses: actions/checkout@master
with:
submodules: true
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.10"
- name: Install requirements
run: python -m pip install --user build
- name: Cleaning
run : python setup.py clean
- name: Build Exegol
run: python -m build --sdist --outdir dist/ .
- name: Publish distribution 📦 to Test PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
password: ${{ secrets.TEST_PYPI_API_TOKEN }}
repository-url: https://test.pypi.org/legacy/
skip-existing: true
33 changes: 33 additions & 0 deletions .github/workflows/entrypoint_prerelease.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: Pre-release PR

on:
pull_request:
branches:
- "master"
paths-ignore:
- ".github/**"
- "**.md"

jobs:
test:
name: Python tests and checks
uses: ./.github/workflows/sub_testing.yml

build:
name: Build Python 🐍 distributions
runs-on: ubuntu-latest
needs: test
steps:
- uses: actions/checkout@master
with:
submodules: true
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.10"
- name: Install requirements
run: python -m pip install --user build
- name: Cleaning
run : python setup.py clean test
- name: Build Exegol
run: python -m build --sdist --outdir dist/ .
52 changes: 52 additions & 0 deletions .github/workflows/entrypoint_pull_request.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
name: Ext. PR tests & int. branches pushes

# for external contribution pull requests,
# and internal pushes to specific branches (!= dev)

on:
pull_request:
branches-ignore:
- "master"
paths-ignore:
- ".github/**"
- "**.md"
push:
branches-ignore:
- "dev"
paths-ignore:
- ".github/**"
- "**.md"

# todo add whitelist paths like entrypoint_nightly.yml

# creating a separate concurrency group for each PR
# so that our "PR checks" are always running for the latest commit in the PR
# and as PRs are updated we want to make sure "in progress" jobs are killed so we don't waste resources
concurrency:
group: ${{ github.ref }}
cancel-in-progress: true


jobs:
test:
name: Python tests and checks
uses: ./.github/workflows/sub_testing.yml

build:
name: Build Python 🐍 distributions
runs-on: ubuntu-latest
needs: test
steps:
- uses: actions/checkout@master
with:
submodules: true
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.10"
- name: Install requirements
run: python -m pip install --user build
- name: Cleaning
run : python setup.py clean
- name: Build Exegol
run: python -m build --sdist --outdir dist/ .
40 changes: 40 additions & 0 deletions .github/workflows/entrypoint_release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: Release

on:
push:
tags:
- '*'

jobs:
test:
name: Python tests and checks
uses: ./.github/workflows/sub_testing.yml

build-n-publish:
name: Build and publish Python 🐍 distributions to PyPI 📦
runs-on: ubuntu-latest
needs: test
steps:
- uses: actions/checkout@master
with:
submodules: true
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.10"
- name: Install requirements
run: python -m pip install --user build
- name: Run package unitest
run : python setup.py clean test
- name: Build Exegol release
run: python -m build --sdist --outdir dist/ .
- name: Publish distribution 📦 to Test PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
password: ${{ secrets.TEST_PYPI_API_TOKEN }}
repository_url: https://test.pypi.org/legacy/
skip_existing: true
- name: Publish distribution 📦 to PyPI (prod)
uses: pypa/gh-action-pypi-publish@release/v1
with:
password: ${{ secrets.PYPI_API_TOKEN }}
43 changes: 43 additions & 0 deletions .github/workflows/sub_testing.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: Testing

on:
workflow_call:

jobs:
testing:
name: Code testing
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
with:
submodules: false
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.10"
- name: Install requirements
run: python -m pip install --user mypy types-requests types-PyYAML
- name: Run code analysis
run: mypy ./exegol/ --ignore-missing-imports --check-untyped-defs --pretty # TODO add --disallow-untyped-defs

compatibility:
name: Compatibility checks
runs-on: ubuntu-latest
needs: testing
strategy:
fail-fast: false
matrix:
version: ["3.7", "3.8", "3.9", "3.10", "3.11"]
os: [win32, linux, darwin]
steps:
- uses: actions/checkout@master
with:
submodules: false
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.10"
- name: Install requirements
run: python -m pip install --user mypy types-requests types-PyYAML
- name: Check python compatibility for ${{ matrix.os }}/${{ matrix.version }}
run: mypy ./exegol.py --ignore-missing-imports --check-untyped-defs --python-version ${{ matrix.version }} --platform ${{ matrix.os }}
23 changes: 16 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<div align="center">
<img alt="exegol logo" width="600" src="https://raw.githubusercontent.com/ThePorgs/Exegol-docs/main/.assets/rounded_social_preview.png">
<img alt="latest commit on master" width="600" src="https://raw.githubusercontent.com/ThePorgs/Exegol-docs/main/.assets/rounded_social_preview.png">
<br><br>
<a href="https://pypi.org/project/Exegol" title=""><img src="https://img.shields.io/pypi/v/Exegol?color=informational" alt="pip package version"></a>
<a target="_blank" rel="noopener noreferrer" href="https://pypi.org/project/Exegol" title=""><img src="https://img.shields.io/pypi/v/Exegol?color=informational" alt="pip package version"></a>
<img alt="Python3.7" src="https://img.shields.io/badge/Python-3.7+-informational">
<a href="https://pepy.tech/project/exegol" title=""><img src="https://static.pepy.tech/personalized-badge/exegol?period=total&units=international_system&left_color=grey&right_color=brightgreen&left_text=Downloads" alt="pip stats"></a>
<a target="_blank" rel="noopener noreferrer" href="https://pepy.tech/project/exegol" title=""><img src="https://static.pepy.tech/personalized-badge/exegol?period=total&units=international_system&left_color=grey&right_color=brightgreen&left_text=Downloads" alt="pip stats"></a>
<br><br>
<img alt="latest commit on master" src="https://img.shields.io/github/last-commit/ThePorgs/Exegol/master?label=latest%20release">
<img alt="latest commit on dev" src="https://img.shields.io/github/last-commit/ThePorgs/Exegol/dev?label=latest%20dev">
Expand All @@ -15,10 +15,17 @@
<img alt="amd64" src="https://img.shields.io/badge/amd64%20(x86__64)-supported-success">
<img alt="arm64" src="https://img.shields.io/badge/arm64%20(aarch64)-supported-success">
<br><br>
<a href="https://twitter.com/intent/follow?screen_name=_nwodtuhs" title="Follow"><img src="https://img.shields.io/twitter/follow/_nwodtuhs?label=Shutdown&style=social" alt="Twitter Shutdown"></a>
<a href="https://twitter.com/intent/follow?screen_name=Dramelac_" title="Follow"><img src="https://img.shields.io/twitter/follow/Dramelac_?label=Dramelac&style=social" alt="Twitter Dramelac"></a>
<a target="_blank" rel="noopener noreferrer" href="https://twitter.com/intent/follow?screen_name=_nwodtuhs" title="Follow"><img src="https://img.shields.io/twitter/follow/_nwodtuhs?label=Shutdown&style=social" alt="Twitter Shutdown"></a>
<a target="_blank" rel="noopener noreferrer" href="https://twitter.com/intent/follow?screen_name=Dramelac_" title="Follow"><img src="https://img.shields.io/twitter/follow/Dramelac_?label=Dramelac&style=social" alt="Twitter Dramelac"></a>
<br>
<a target="_blank" rel="noopener noreferrer" href="https://www.blackhat.com/eu-22/arsenal/schedule/index.html#exegol-29180" title="Schedule">
<img alt="Black Hat Europe 2022" src="https://img.shields.io/badge/Black%20Hat%20Arsenal-Europe%202022-blueviolet">
</a>
<a target="_blank" rel="noopener noreferrer" href="https://www.blackhat.com/asia-23/arsenal/schedule/#exegol-professional-hacking-setup-30815" title="Schedule">
<img alt="Black Hat Asia 2023" src="https://img.shields.io/badge/Black%20Hat%20Arsenal-Asia%202023-blueviolet">
</a>
<br><br>
<a href="https://discord.gg/cXThyp7D6P" title="Join us on Discord"><img src="https://raw.githubusercontent.com/ThePorgs/Exegol-docs/main/.assets/discord_join_us.png" width="150" alt="Join us on Discord"></a>
<a target="_blank" rel="noopener noreferrer" href="https://discord.gg/cXThyp7D6P" title="Join us on Discord"><img src="https://raw.githubusercontent.com/ThePorgs/Exegol-docs/main/.assets/discord_join_us.png" width="150" alt="Join us on Discord"></a>
<br><br>
</div>

Expand All @@ -27,7 +34,9 @@

# Getting started

You can refer to the [Exegol documentations](https://exegol.readthedocs.io/).
You can refer to the [Exegol documentations](https://exegol.readthedocs.io/en/latest/getting-started/install.html).

> Full documentation homepage: https://exegol.rtfd.io/.

## Project structure

Expand Down
2 changes: 1 addition & 1 deletion exegol-docker-build
Submodule exegol-docker-build updated 98 files
+1 −1 .github/ISSUE_TEMPLATE/bug_report.yml
+4 −4 .github/ISSUE_TEMPLATE/config.yml
+1 −1 .github/ISSUE_TEMPLATE/feature_request.yml
+1 −1 .github/PULL_REQUEST_TEMPLATE.md
+0 −20 .github/workflows/PR_dev.yml
+0 −35 .github/workflows/PR_main.yml
+0 −21 .github/workflows/ad_release.yml
+0 −285 .github/workflows/building.yml
+1 −0 .github/workflows/diagrams.drawio
+128 −0 .github/workflows/entrypoint_nightly.yml
+132 −0 .github/workflows/entrypoint_preprod_ad.yml
+132 −0 .github/workflows/entrypoint_preprod_full.yml
+132 −0 .github/workflows/entrypoint_preprod_light.yml
+132 −0 .github/workflows/entrypoint_preprod_osint.yml
+132 −0 .github/workflows/entrypoint_preprod_web.yml
+81 −0 .github/workflows/entrypoint_pull_request.yml
+42 −0 .github/workflows/entrypoint_release.yml
+0 −96 .github/workflows/full_build.yml
+0 −21 .github/workflows/full_release.yml
+0 −21 .github/workflows/light_release.yml
+0 −20 .github/workflows/nigthly.yml
+0 −21 .github/workflows/osint_release.yml
+0 −35 .github/workflows/release.yml
+84 −0 .github/workflows/sub_build.yml
+145 −0 .github/workflows/sub_build_belt.yml
+39 −0 .github/workflows/sub_push.yml
+47 −0 .github/workflows/sub_release_manifest.yml
+44 −0 .github/workflows/sub_test.yml
+0 −38 .github/workflows/testing.yml
+0 −21 .github/workflows/web_release.yml
+1 −1 CONTRIBUTING.md
+1 −1 Dockerfile
+1 −1 README.md
+1 −1 ad.dockerfile
+12 −10 debug.dockerfile
+1 −1 light.dockerfile
+1 −1 osint.dockerfile
+8 −0 sources/bloodhound/customqueries.json
+0 −27 sources/exegol/build_pipeline_tests/ingest_tests.py
+85 −0 sources/exegol/build_pipeline_tests/run_tests.py
+22 −1 sources/exegol/load_supported_setups.sh
+3 −0 sources/exegol/skel/firefox/addons.txt
+1 −1 sources/exegol/skel/supported_setups.md
+ sources/firefox/places.sqlite
+2 −0 sources/firefox/requirements.txt
+216 −0 sources/firefox/setup.py
+113 −0 sources/firefox/user-setup.py
+765 −105 sources/install.sh
+2 −1 sources/zsh/aliases
+1 −0 sources/zsh/aliases.d/PassTheCert
+0 −1 sources/zsh/aliases.d/byp4xx
+1 −1 sources/zsh/aliases.d/ghidra
+1 −0 sources/zsh/aliases.d/kraken
+0 −1 sources/zsh/aliases.d/ldapsearch-ad
+3 −0 sources/zsh/aliases.d/neo4j
+1 −0 sources/zsh/aliases.d/php_filter_chain_generator
+7 −0 sources/zsh/aliases.d/pth-tools
+1 −1 sources/zsh/aliases.d/smbmap
+2 −0 sources/zsh/aliases.d/smuggler
+1 −0 sources/zsh/aliases.d/soapui
+1 −0 sources/zsh/aliases.d/tailscale
+0 −2 sources/zsh/aliases.d/volatility
+2 −0 sources/zsh/aliases.d/volatility2
+2 −0 sources/zsh/aliases.d/volatility3
+2 −0 sources/zsh/history.d/bqm
+1 −0 sources/zsh/history.d/brakeman
+6 −0 sources/zsh/history.d/ctf-party
+1 −1 sources/zsh/history.d/dnsutils
+4 −0 sources/zsh/history.d/dnsx
+1 −0 sources/zsh/history.d/exif
+1 −0 sources/zsh/history.d/exiv2
+2 −0 sources/zsh/history.d/fdisk
+1 −0 sources/zsh/history.d/goldencopy
+4 −0 sources/zsh/history.d/haiti
+1 −0 sources/zsh/history.d/hexedit
+1 −1 sources/zsh/history.d/impacket
+2 −0 sources/zsh/history.d/jadx
+1 −0 sources/zsh/history.d/kraken
+3 −3 sources/zsh/history.d/krbrelayx
+4 −1 sources/zsh/history.d/ldapsearch
+2 −0 sources/zsh/history.d/ldeep
+2 −0 sources/zsh/history.d/netdiscover
+4 −0 sources/zsh/history.d/notify
+1 −0 sources/zsh/history.d/objection
+1 −1 sources/zsh/history.d/pywsus
+1 −0 sources/zsh/history.d/rusthound
+1 −0 sources/zsh/history.d/semgrep
+1 −1 sources/zsh/history.d/shellerator
+4 −0 sources/zsh/history.d/shuffledns
+3 −3 sources/zsh/history.d/smtp-user-enum
+1 −0 sources/zsh/history.d/smuggler
+6 −1 sources/zsh/history.d/subfinder
+1 −0 sources/zsh/history.d/swaks
+2 −0 sources/zsh/history.d/tailscale
+1 −0 sources/zsh/history.d/testdisk
+11 −0 sources/zsh/history.d/tls-map
+15 −0 sources/zsh/history.d/volatility3
+1 −1 web.dockerfile
1 change: 1 addition & 0 deletions exegol.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# PYTHON_ARGCOMPLETE_OK
from exegol.manager.ExegolController import main


Expand Down
2 changes: 1 addition & 1 deletion exegol/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from exegol.utils.ConstantConfig import ConstantConfig
from exegol.config.ConstantConfig import ConstantConfig

__version__ = ConstantConfig.version
__title__ = "exegol"
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
class ConstantConfig:
"""Constant parameters information"""
# Exegol Version
version: str = "4.1.1"
version: str = "4.2.0"

# Exegol documentation link
documentation: str = "https://exegol.rtfd.io/"
Expand Down
64 changes: 64 additions & 0 deletions exegol/config/DataCache.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
import json

from exegol.model.CacheModels import *
from exegol.utils.DataFileUtils import DataFileUtils
from exegol.utils.MetaSingleton import MetaSingleton


class DataCache(DataFileUtils, metaclass=MetaSingleton):
"""This class allows loading cached information defined configurations

Exemple of data:
{
wrapper: {
update: {
metadata: {
last_check DATE
}
last_version: STR
}
}
images:
metadata: {
last_check: DATE
}
data: [
{
name: STR (tag name)
last_version: STR (x.y.z|commit_id)
type: STR (local|remote)
}
]
}
"""

def __init__(self):
# Cache data
self.__cache_data = CacheDB()

# Config file options
super().__init__(".datacache", "json")

def _process_data(self):
if len(self._raw_data) >= 2:
self.__cache_data.load(**self._raw_data)

def _build_file_content(self) -> str:
return json.dumps(self.__cache_data, cls=self.ObjectJSONEncoder)

def save_updates(self):
self._create_config_file()

def get_wrapper_data(self) -> WrapperCacheModel:
"""Get Wrapper information from cache"""
return self.__cache_data.wrapper

def get_images_data(self) -> ImagesCacheModel:
"""Get Images information from cache"""
return self.__cache_data.images

def update_image_cache(self, images: List):
"""Refresh image cache data"""
cache_images = [ImageCacheModel(img.getName(), img.getLatestVersion(), img.getLatestRemoteId(), "local" if img.isLocal() else "remote") for img in images]
self.__cache_data.images = ImagesCacheModel(cache_images)
self.save_updates()
Loading