Skip to content

Commit

Permalink
Merge pull request #36 from stacscan/darkarnium/python3.11
Browse files Browse the repository at this point in the history
Deprecate Ubuntu 18.04. Add Ubuntu 22.04
  • Loading branch information
darkarnium committed Apr 29, 2023
2 parents d6f71cf + a5c1082 commit 0912963
Show file tree
Hide file tree
Showing 12 changed files with 183 additions and 122 deletions.
File renamed without changes.
34 changes: 10 additions & 24 deletions .github/workflows/check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ on:

jobs:
check:
strategy:
matrix:
python: ['3.9', '3.10', '3.11']

runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
Expand All @@ -16,38 +20,20 @@ jobs:
sudo apt update
sudo apt install -y libarchive13 libarchive-dev
- name: Configure Python 3.9
uses: actions/setup-python@v2
with:
python-version: 3.9

- name: Install Tox
run: |
python -m pip install --upgrade pip wheel setuptools
pip install tox
- name: Run Linter (3.9)
run: |
tox -e py39-lint
- name: Run Tests (3.9)
run: |
tox -e py39-test
- name: Configure Python 3.8
- name: Configure Python (${{ matrix.python }})
uses: actions/setup-python@v2
with:
python-version: 3.8
python-version: ${{ matrix.python }}

- name: Install Tox
run: |
python -m pip install --upgrade pip wheel setuptools
pip install tox
- name: Run Linter (3.8)
- name: Run Linters (${{ matrix.python }})
run: |
tox -e py38-lint
tox -e linters
- name: Run Tests (3.8)
- name: Run Tests (${{ matrix.python }})
run: |
tox -e py38-test
tox -e py3
13 changes: 3 additions & 10 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-20.04, ubuntu-18.04, macos-10.15, macos-11, macos-12]
os: [ubuntu-22.04, ubuntu-20.04, macos-10.15, macos-11, macos-12]

steps:
- uses: actions/checkout@v2
Expand All @@ -27,23 +27,16 @@ jobs:
run: brew install libarchive

- name: Install cibuildwheel
run: python -m pip install cibuildwheel==2.7.0
run: python -m pip install cibuildwheel==2.12.3

- name: Build wheels (macOS)
run: python -m cibuildwheel --output-dir wheelhouse
if: startsWith(matrix.os, 'macos-')
env:
CIBW_BEFORE_BUILD: pip install pybind11
CIBW_ENVIRONMENT: >
CPPFLAGS="-std=c++11 -I$(find `brew --cellar libarchive` -name include -type d)" \
LDFLAGS="-L$(find `brew --cellar libarchive` -name include -type d)" \
PKG_CONFIG="$(find `brew --cellar libarchive` -name pkgconfig -type d)"

- name: Build wheels (Ubuntu)
run: python -m cibuildwheel --output-dir wheelhouse
if: startsWith(matrix.os, 'ubuntu-')
env:
CIBW_BEFORE_BUILD: pip install pybind11
CIBW_BEFORE_ALL_LINUX: >
curl -sOL https://github.com/libarchive/libarchive/releases/download/v3.6.1/libarchive-3.6.1.tar.gz &&
tar -zxvf libarchive-3.6.1.tar.gz &&
Expand All @@ -64,7 +57,7 @@ jobs:
- name: Configure Python
uses: actions/setup-python@v2
with:
python-version: 3.9
python-version: 3.11

- name: Build Python sdist
run: |
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/publish_to_testing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-20.04, ubuntu-18.04, macos-10.15, macos-11, macos-12]
os: [ubuntu-22.04, ubuntu-20.04, macos-10.15, macos-11, macos-12]

steps:
- uses: actions/checkout@v2
Expand All @@ -37,7 +37,7 @@ jobs:
stacs/scan/__about__.py
- name: Install cibuildwheel
run: python -m pip install cibuildwheel==2.7.0
run: python -m pip install cibuildwheel==2.12.3

- name: Build wheels (macOS)
run: python -m cibuildwheel --output-dir wheelhouse
Expand Down Expand Up @@ -74,7 +74,7 @@ jobs:
- name: Configure Python
uses: actions/setup-python@v2
with:
python-version: 3.9
python-version: 3.11

# This is rather unpleasant and the package versioning should be adjusted to
# allow snapshot build numbers to be injected via setuptools, etc.
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/update.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
- name: Configure Python
uses: actions/setup-python@v2
with:
python-version: 3.9
python-version: 3.11

- name: Extract version
run: |
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[![Shield](https://img.shields.io/github/workflow/status/stacscan/stacs/Check?label=Tests&style=flat-square)](https://github.com/stacscan/stacs/actions?workflow=Check)
[![Shield](https://img.shields.io/github/workflow/status/stacscan/stacs/Publish?label=Deploy&style=flat-square)](https://github.com/stacscan/stacs/actions?workflow=Publish)
[![Shield](https://img.shields.io/github/actions/workflow/status/stacscan/stacs/check.yml?label=Tests&style=flat-square)](https://github.com/stacscan/stacs/actions?workflow=Check)
[![Shield](https://img.shields.io/github/actions/workflow/status/stacscan/stacs/publish.yml?label=Deploy&style=flat-square)](https://github.com/stacscan/stacs/actions?workflow=Publish)
[![Shield](https://img.shields.io/docker/pulls/stacscan/stacs?style=flat-square)](https://hub.docker.com/r/stacscan/stacs)
[![Shield](https://img.shields.io/docker/image-size/stacscan/stacs?style=flat-square)](https://hub.docker.com/r/stacscan/stacs/tags?page=1&ordering=last_updated)
[![Shield](https://img.shields.io/twitter/follow/stacscan?style=flat-square)](https://twitter.com/stacscan)
Expand Down
131 changes: 131 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
[build-system]
requires = ["setuptools", "setuptools-scm", "pybind11"]
build-backend = "setuptools.build_meta"

[project]
name = "stacs"
readme = "README.md"
description = "Static Token And Credential Scanner."
requires-python = ">=3.8"
dynamic = ["version"]
authors = [{name = "Peter Adkins"}]
license = {text = "BSD-3-Clause"}
classifiers = [
"Programming Language :: Python :: 3.8",
"Natural Language :: English",
]
dependencies = [
"click>=8.1.0,<9.0",
"yara-python>=4.2.0,<5.0",
"pydantic>=1.10.0,<2.0",
"colorama>=0.4.0,<1.0",
"zstandard>=0.18.0,<1.0",
]

[project.optional-dependencies]
tests = [
"black",
"coverage",
"ruff",
"types-setuptools",
"mypy",
"pip-tools",
"mock",
"pytest",
"pytest-cov",
"responses",
"tox",
"ipython",
]

[tool.setuptools.dynamic]
version = {attr = "stacs.scan.__about__.__version__"}

[tool.setuptools.packages.find]
where = ["."]
include = ["stacs.*"]

[project.scripts]
stacs = "stacs.scan.entrypoint.cli:main"

[tool.ruff]
line-length = 88
extend-select = [
"B", # flake8-bugbear
"I", # isort
]
ignore = [
"B904",
"I001",
"B005",
]

[tool.mypy]
files = [
"./stacs/**/*.py",
"./tests/**/*.py"
]
allow_redefinition = false
check_untyped_defs = true
disallow_any_generics = true
disallow_untyped_calls = false
ignore_errors = false
ignore_missing_imports = true
implicit_reexport = false
local_partial_types = true
strict_optional = true
strict_equality = true
no_implicit_optional = true
warn_no_return = true
warn_unused_ignores = true
warn_redundant_casts = true
warn_unused_configs = true
warn_unreachable = true

[tool.pytest.ini_options]
junit_family = "xunit2"
norecursedirs = ".*"
self-contained-html = true
testpaths = [
"tests"
]
addopts = """
--strict
--tb=auto
--cov=stacs
--cov-report=term-missing:skip-covered
--cov-branch
-p no:doctest
-p no:warnings
-s
"""

[tool.tox]
legacy_tox_ini = """
[tox]
envlist = linters,py3
[testenv]
pip_version = pip
extras = tests
commands = pytest -c pyproject.toml
srcs = stacs
[testenv:linters]
basepython = python3
usedevelop = true
commands =
{[testenv:ruff]commands}
[testenv:ruff]
basepython = python3
skip_install = true
commands =
ruff check {[testenv]srcs}
[testenv:mypy]
basepython3 = python3
skip_install = true
commands =
- mypy --config-file pyproject.toml {[testenv]srcs}
"""
1 change: 0 additions & 1 deletion requirements.txt

This file was deleted.

15 changes: 0 additions & 15 deletions setup.cfg

This file was deleted.

83 changes: 32 additions & 51 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,29 +1,12 @@
"""STACS Setup.
SPDX-License-Identifier: BSD-3-Clause
"""
"""Setup required for pybind11 built native code only."""

import os
import platform
import subprocess
from typing import List

try:
from pybind11.setup_helpers import Pybind11Extension
except ImportError:
from setuptools import Extension as Pybind11Extension

from setuptools import find_namespace_packages, setup

# Explicitly pull in the contents of our package's __about__ file due to constraints on
# the previous STACS structure.
__uri__ = None
__title__ = None
__author__ = None
__version__ = None

path = os.path.dirname(os.path.abspath(__file__))
exec(open(os.path.join(path, "stacs/scan/__about__.py")).read())

# For PyPi to use the contents of README.md
long_description = open(os.path.join(path, "README.md")).read()
from pybind11.setup_helpers import Pybind11Extension
from setuptools import setup

ext_modules = [
Pybind11Extension(
Expand All @@ -33,32 +16,30 @@
),
]

setup(
name=__title__,
description="Static Token And Credential Scanner.",
packages=find_namespace_packages(include=["stacs.*"]),
long_description=long_description,
long_description_content_type="text/markdown",
url=__uri__,
version=__version__,
ext_modules=ext_modules,
setup_requires=[
"pybind11",
],
extras_require={
"development": [
"tox",
"black",
"flake8",
"isort",
"pybind11",

def run(command: List[str]):
"""Run a command, returning the output as a string or an exception on failure."""
result = subprocess.run(command, capture_output=True, check=True)
return str(result.stdout, "utf-8").strip()


# macOS requires a bit of special handling to ensure that the - likely - brew installed
# libarchive is discoverable. The macOS built-in libarchive is no good, as it's too
# old.
if platform.system() == "Darwin":
libarchive = run(["brew", "--cellar", "libarchive"])
libarchive_headers = run(["find", libarchive, "-name", "include", "-type", "d"])
libarchive_pkgconfig = run(["find", libarchive, "-name", "pkgconfig", "-type", "d"])

# Setup the environment for the build.
os.environ["LDFLAGS"] = f"-L{libarchive_headers}"
os.environ["PKG_CONFIG"] = libarchive_pkgconfig
os.environ["CPPFLAGS"] = " ".join(
[
os.environ.get("CPPFLAGS", ""),
"-std=c++11",
f"-I{libarchive_headers}",
]
},
install_requires=[
"click>=8.1.0,<9.0",
"yara-python>=4.2.0,<5.0",
"pydantic>=1.10.0,<2.0",
"colorama>=0.4.0,<1.0",
"zstandard>=0.18.0,<1.0",
],
)
)

setup(ext_modules=ext_modules, packages=[])
2 changes: 1 addition & 1 deletion stacs/scan/__about__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

__title__ = "stacs"
__summary__ = "Static Token And Credential Scanner."
__version__ = "0.4.15"
__version__ = "0.5.0"
__author__ = "Peter Adkins"
__uri__ = "https://www.github.com/stacscan/stacs/"
__license__ = "BSD-3-Clause"
Loading

0 comments on commit 0912963

Please sign in to comment.