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

feat: publish as pypi package #17

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
39 changes: 39 additions & 0 deletions .github/workflows/cd.yaml
Original file line number Diff line number Diff line change
@@ -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 }}
1 change: 1 addition & 0 deletions graphw00f/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from graphw00f.main import main # noqa
4 changes: 4 additions & 0 deletions graphw00f/__main__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
from graphw00f import main

if __name__ == '__main__':
main()
File renamed without changes.
15 changes: 11 additions & 4 deletions graphw00f/helpers.py
Original file line number Diff line number Diff line change
@@ -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'
Expand All @@ -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):
Expand Down Expand Up @@ -58,7 +65,7 @@ def draw_art():
graphw00f - v{version}
The fingerprinting tool for GraphQL
Dolev Farhi <dolev@lethalbit.com>
'''.format(version=VERSION)
'''.format(version=get_version())

def possible_graphql_paths():
return [
Expand Down
28 changes: 5 additions & 23 deletions main.py → graphw00f/main.py
Original file line number Diff line number Diff line change
@@ -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():
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -150,6 +135,3 @@ def main():

print(bcolors.ENDC + '[*] Completed.')

if __name__ == '__main__':
main()

24 changes: 24 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
[tool.poetry]
name = "graphw00f"
version = "1.1.9"
description = "GraphQL Server Engine Fingerprinting utility"
authors = ["Dolev Farhi <farhi.dolev@gmail.com>"]
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"
1 change: 0 additions & 1 deletion version.py

This file was deleted.