Skip to content

Commit ebc9d65

Browse files
committed
Applied various minor improvements
1 parent 66db63d commit ebc9d65

File tree

17 files changed

+80
-67
lines changed

17 files changed

+80
-67
lines changed

.github/workflows/pypi-publish.yml

Lines changed: 0 additions & 37 deletions
This file was deleted.

.github/workflows/python-package.yml

Lines changed: 34 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ jobs:
1919
fail-fast: false
2020
matrix:
2121
os: [ubuntu-latest]
22-
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
22+
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"]
2323
steps:
2424
- uses: actions/checkout@v3
2525
- name: Set up Python ${{ matrix.python-version }}
@@ -31,7 +31,7 @@ jobs:
3131
- name: Install ${{ env.package }}
3232
run: |
3333
python -m pip install --upgrade pip
34-
python -m pip install pytest pytest-cov pytest-pythonpath coverage
34+
python -m pip install pytest pytest-cov coverage
3535
pip install -r requirements.txt
3636
pip install .
3737
- name: Test ${{ env.package }} with pytest
@@ -47,13 +47,13 @@ jobs:
4747
- name: Set up Python ${{ matrix.python-version }}
4848
uses: actions/setup-python@v4
4949
with:
50-
python-version: "3.10"
50+
python-version: "3.12"
5151
- name: Install pandoc
5252
run: sudo apt-get install -y pandoc notification-daemon
5353
- name: Install ${{ env.package }}
5454
run: |
5555
python -m pip install --upgrade pip
56-
python -m pip install pytest pytest-cov pytest-pythonpath
56+
python -m pip install pytest pytest-cov
5757
pip install -r requirements.txt
5858
pip install .
5959
- name: Make coverage badge for ${{ env.package }}
@@ -79,3 +79,33 @@ jobs:
7979
with:
8080
github_token: ${{ secrets.github_token }}
8181
branch: ${{ github.ref }}
82+
deploy:
83+
runs-on: ubuntu-latest
84+
needs: coverage
85+
steps:
86+
- uses: actions/checkout@v3
87+
with:
88+
fetch-depth: 0
89+
- name: Check for version change
90+
uses: dorny/paths-filter@v2
91+
id: filter
92+
with:
93+
filters: |
94+
version:
95+
- '**/VERSION.txt'
96+
- if: steps.filter.outputs.version == 'true'
97+
name: Cleanup README
98+
run: |
99+
sed -ri 's/^(##*)\s*:.*:\s*/\1 /g' README.md
100+
awk '{if (match($0,"## Supporters")) exit; print}' README.md > README
101+
mv -f README README.md
102+
- if: steps.filter.outputs.version == 'true'
103+
name: Build ${{ env.package }} package
104+
run: python3 -m pip install --upgrade build && python3 -m build
105+
- if: steps.filter.outputs.version == 'true'
106+
name: Upload ${{ env.package }} to PyPi
107+
uses: pypa/gh-action-pypi-publish@release/v1
108+
with:
109+
password: ${{ secrets.PYPI_API_TOKEN }}
110+
verbose: true
111+
verify_metadata: false

pyproject.toml

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
[build-system]
2-
requires = ["setuptools>=61.0", "setuptools-scm"]
2+
requires = ["setuptools>=80.0.0", "setuptools-scm"]
33
build-backend = "setuptools.build_meta"
44

55
[tool.pytest.ini_options]
6-
pythonpath = ["src"]
6+
pythonpath = ["src", "tests"]
77

88
[tool.setuptools.dynamic]
99
version = {attr = "sploitkit.__info__.__version__"}
@@ -33,10 +33,9 @@ classifiers = [
3333
"Topic :: Software Development :: Libraries :: Python Modules",
3434
]
3535
dependencies = [
36-
"peewee>=3.17.6",
37-
"prompt_toolkit>=3.0.47",
38-
"requests",
39-
"tinyscript>=1.30.15",
36+
"peewee>=3.18.2",
37+
"prompt_toolkit>=3.0.52",
38+
"tinyscript>=1.30.28",
4039
]
4140
dynamic = ["version"]
4241

pytest.ini

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
[pytest]
2-
python_paths = src
2+
pythonpath = src tests

requirements.txt

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
peewee>=3.17.6
2-
prompt_toolkit>=3.0.47
3-
requests
4-
tinyscript>=1.30.15
1+
peewee>=3.18.2
2+
prompt_toolkit>=3.0.52
3+
tinyscript>=1.30.28

src/sploitkit/VERSION.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0.6.0
1+
0.6.1

src/sploitkit/base/commands/general.py

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ def run(self, text):
6161
class Show(Command):
6262
""" Show options, projects, modules or issues (if any) """
6363
level = "root"
64-
keys = ["files", "modules", "options", "projects"]
64+
keys = []
6565

6666
def complete_values(self, key):
6767
if key == "files":
@@ -126,16 +126,25 @@ def run(self, key, value=None):
126126
print_formatted_text(BorderlessTable(data, "Open sessions"))
127127

128128
def set_keys(self):
129+
if sum(1 for _ in self.console._files.list) > 0:
130+
self.keys.append("files")
129131
if Entity.has_issues():
130-
self.keys += ["issues"]
132+
self.keys.append("issues")
131133
else:
132134
while "issues" in self.keys:
133135
self.keys.remove("issues")
136+
if len(self.console.modules) > 0:
137+
self.keys.append("modules")
138+
if sum(1 for _ in self.config.options()) > 0:
139+
self.keys.append("options")
140+
if len(projects(self)) > 0:
141+
self.keys.append("projects")
134142
if len(self.console._sessions) > 0:
135-
self.keys += ["sessions"]
143+
self.keys.append("sessions")
136144
else:
137145
while "sessions" in self.keys:
138146
self.keys.remove("sessions")
147+
self.keys = list(set(self.keys))
139148

140149
def validate(self, key, value=None):
141150
if key not in self.keys:

src/sploitkit/base/commands/project.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# -*- coding: UTF-8 -*-
2-
from tinyscript.helpers import confirm, Path, ProjectPath
2+
from prompt_toolkit.formatted_text import ANSI
3+
from tinyscript.helpers import confirm, BorderlessTable, Path, ProjectPath
34

45
from sploitkit import *
56

@@ -118,5 +119,6 @@ class Show(Command):
118119
values = ["options"]
119120

120121
def run(self, value):
121-
print_formatted_text(BorderlessTable(self.console.__class__.options, "Console options"))
122+
#print_formatted_text(BorderlessTable(self.config, "Console options"))
123+
print_formatted_text(ANSI(str(self.config)))
122124

src/sploitkit/base/commands/utils.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,8 +126,6 @@ def run(self):
126126
if len(v) == 0:
127127
continue
128128
if isinstance(v, Iterable):
129-
if isinstance(v, dict):
130-
v = dict(**v)
131129
for l in yaml.dump(v).split("\n"):
132130
if len(l.strip()) == 0:
133131
continue

src/sploitkit/core/components/store.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# -*- coding: UTF-8 -*-
2-
from peewee import SqliteDatabase
2+
from peewee import OperationalError, SqliteDatabase
33

44

55
__all__ = ["StoragePool"]
@@ -40,9 +40,12 @@ def get(self, path, *args, **kwargs):
4040
self.__pool.append(db)
4141
for m in self.models:
4242
m.bind(db)
43-
db.create_tables(self.models, safe=True)
44-
db.close() # commit and save the created tables
45-
db.connect()
43+
try:
44+
db.create_tables(self.models, safe=True)
45+
db.close() # commit and save the created tables
46+
db.connect()
47+
except OperationalError:
48+
db._mode = "ro"
4649
return db
4750

4851
def remove(self, db):
@@ -66,6 +69,7 @@ class Store(SqliteDatabase):
6669
def __init__(self, path, *args, **kwargs):
6770
self.path = str(path) # ensure the input is str, e.g. not Path
6871
self._last_snapshot = 0
72+
self._mode = "rw"
6973
kwargs.setdefault('pragmas', {})
7074
# enable automatic VACUUM (to regularly defragment the DB)
7175
kwargs['pragmas'].setdefault('auto_vacuum', 1)

0 commit comments

Comments
 (0)