From 9818bdd2119fdf1110ed25457780805e2b57f64e Mon Sep 17 00:00:00 2001 From: c3b5aw Date: Thu, 6 Oct 2022 17:01:16 +0200 Subject: [PATCH 1/2] feat: publish as pypi packages --- .github/workflows/cd.yaml | 39 ++++++++++++++++++++++++++++++++++++ graphw00f/__init__.py | 1 + conf.py => graphw00f/conf.py | 0 graphw00f/helpers.py | 15 ++++++++++---- main.py => graphw00f/main.py | 26 +++++------------------- pyproject.toml | 24 ++++++++++++++++++++++ version.py | 1 - 7 files changed, 80 insertions(+), 26 deletions(-) create mode 100644 .github/workflows/cd.yaml create mode 100644 graphw00f/__init__.py rename conf.py => graphw00f/conf.py (100%) rename main.py => graphw00f/main.py (94%) create mode 100644 pyproject.toml delete mode 100644 version.py diff --git a/.github/workflows/cd.yaml b/.github/workflows/cd.yaml new file mode 100644 index 0000000..11fb78e --- /dev/null +++ b/.github/workflows/cd.yaml @@ -0,0 +1,39 @@ +name: CD + +on: + push: + tags: + - "v*" + +jobs: + release: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v3 + - name: Release + uses: softprops/action-gh-release@v1 + + pypi-push: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-python@v4 + with: + python-version: '3.7' + - name: Install dependencies + run: | + pip install poetry + - name: Setup poetry + run: | + poetry config virtualenvs.in-project true + poetry install --no-dev + - name: Build package + run: | + source .venv/bin/activate + poetry build + - name: Upload package + uses: pypa/gh-action-pypi-publish@release/v1 + with: + user: __token__ + password: ${{ secrets.PYPI_TOKEN }} \ No newline at end of file diff --git a/graphw00f/__init__.py b/graphw00f/__init__.py new file mode 100644 index 0000000..c914c14 --- /dev/null +++ b/graphw00f/__init__.py @@ -0,0 +1 @@ +from graphw00f.main import main # noqa \ No newline at end of file diff --git a/conf.py b/graphw00f/conf.py similarity index 100% rename from conf.py rename to graphw00f/conf.py diff --git a/graphw00f/helpers.py b/graphw00f/helpers.py index bc09e57..c3ec6f8 100644 --- a/graphw00f/helpers.py +++ b/graphw00f/helpers.py @@ -1,8 +1,6 @@ - +import sys import datetime import os.path -from urllib.parse import urlparse -from version import VERSION class bcolors: OKBLUE = '\033[94m' @@ -12,6 +10,15 @@ class bcolors: FAIL = '\033[91m' ENDC = '\033[0m' +def get_version(): + if sys.version_info >= (3, 8): + import importlib.metadata + return importlib.metadata.version('graphw00f') + else: + import importlib_metadata + return importlib_metadata.version('graphw00f') + + def read_custom_wordlist(location): wordlists = set() if os.path.exists(location): @@ -58,7 +65,7 @@ def draw_art(): graphw00f - v{version} The fingerprinting tool for GraphQL Dolev Farhi - '''.format(version=VERSION) + '''.format(version=get_version()) def possible_graphql_paths(): return [ diff --git a/main.py b/graphw00f/main.py similarity index 94% rename from main.py rename to graphw00f/main.py index 8ba6bd4..ac78469 100644 --- a/main.py +++ b/graphw00f/main.py @@ -1,27 +1,12 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- import sys -import conf - -from graphw00f.helpers import ( - get_time, - draw_art, - get_engines, - user_confirmed, - read_custom_wordlist, - possible_graphql_paths, - bcolors -) - -from time import sleep -from urllib.parse import urlparse from optparse import OptionParser +from urllib.parse import urlparse -from version import VERSION -from graphw00f.lib import ( - GRAPHW00F, - GraphQLDetectionFailed -) +import graphw00f.conf as conf +from graphw00f.helpers import bcolors, draw_art, get_engines, get_time, possible_graphql_paths, read_custom_wordlist, user_confirmed, get_version +from graphw00f.lib import GRAPHW00F, GraphQLDetectionFailed def main(): @@ -56,7 +41,7 @@ def main(): sys.exit(0) if options.version: - print('version:', VERSION) + print('version:', get_version()) sys.exit(0) if not options.url: @@ -152,4 +137,3 @@ def main(): if __name__ == '__main__': main() - \ No newline at end of file diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..6eecf19 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,24 @@ +[tool.poetry] +name = "graphw00f" +version = "1.1.9" +description = "GraphQL Server Engine Fingerprinting utility" +authors = ["Dolev Farhi "] +license = "BSD-3-Clause" +packages = [{ include = "graphw00f" }] +include = ["LICENSE"] +readme = "README.md" +repository = "https://github.com/dolevf/graphw00f" + +[tool.poetry.urls] +"Bug Tracker" = "https://github.com/dolevf/graphw00f/issues" + +[tool.poetry.scripts] +graphw00f = 'graphw00f:main' + +[tool.poetry.dependencies] +python = ">=3.7, <4" +requests = "^2" + +[build-system] +requires = ["poetry-core>=1.2.0"] +build-backend = "poetry.core.masonry.api" diff --git a/version.py b/version.py deleted file mode 100644 index e6acbe2..0000000 --- a/version.py +++ /dev/null @@ -1 +0,0 @@ -VERSION = '1.1.8' From aef1cda00f966e33b4dcc94a57eec5e9e2712dd7 Mon Sep 17 00:00:00 2001 From: c3b5aw Date: Thu, 6 Oct 2022 17:10:17 +0200 Subject: [PATCH 2/2] feat: add python -m --- graphw00f/__main__.py | 4 ++++ graphw00f/main.py | 2 -- 2 files changed, 4 insertions(+), 2 deletions(-) create mode 100644 graphw00f/__main__.py diff --git a/graphw00f/__main__.py b/graphw00f/__main__.py new file mode 100644 index 0000000..9ce84fe --- /dev/null +++ b/graphw00f/__main__.py @@ -0,0 +1,4 @@ +from graphw00f import main + +if __name__ == '__main__': + main() diff --git a/graphw00f/main.py b/graphw00f/main.py index ac78469..f22d873 100644 --- a/graphw00f/main.py +++ b/graphw00f/main.py @@ -135,5 +135,3 @@ def main(): print(bcolors.ENDC + '[*] Completed.') -if __name__ == '__main__': - main()