Skip to content

Commit

Permalink
Merge pull request #19 from cisagov/lineage/skeleton
Browse files Browse the repository at this point in the history
⚠️ CONFLICT! Lineage pull request for: skeleton
  • Loading branch information
dav3r committed Dec 8, 2020
2 parents 5cbb7c1 + 383aafd commit a6b08f2
Show file tree
Hide file tree
Showing 8 changed files with 182 additions and 68 deletions.
13 changes: 8 additions & 5 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
# Each line is a file pattern followed by one or more owners.

# These owners will be the default owners for everything in
# the repo. Unless a later match takes precedence,
# these owners will be requested for review when someone
# opens a pull request.
* @bjb28 @dav3r
# These owners will be the default owners for everything in the
# repo. Unless a later match takes precedence, these owners will be
# requested for review when someone opens a pull request.
* @bjb28 @dav3r @felddy @hillaryj @jsf9k @mcdonnnj

# These folks own any files in the .github directory at the root of
# the repository and any of its subdirectories.
/.github/ @dav3r @felddy @hillaryj @jsf9k @mcdonnnj
13 changes: 13 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
---

version: 2
updates:
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "weekly"

- package-ecosystem: "pip"
directory: "/"
schedule:
interval: "weekly"
52 changes: 27 additions & 25 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,26 +17,24 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
- id: setup-python
uses: actions/setup-python@v2
with:
python-version: 3.8
- name: Store installed Python version
run: |
echo "::set-env name=PY_VERSION::"\
"$(python -c "import platform;print(platform.python_version())")"
- name: Cache linting environments
uses: actions/cache@v2
python-version: 3.9
- uses: actions/cache@v2
env:
BASE_CACHE_KEY: "${{ github.job }}-${{ runner.os }}-\
py${{ steps.setup-python.outputs.python-version }}-"
with:
path: |
${{ env.PIP_CACHE_DIR }}
${{ env.PRE_COMMIT_CACHE_DIR }}
key: "lint-${{ runner.os }}-py${{ env.PY_VERSION }}-\
key: "${{ env.BASE_CACHE_KEY }}\
${{ hashFiles('**/requirements-test.txt') }}-\
${{ hashFiles('**/requirements.txt') }}-\
${{ hashFiles('**/.pre-commit-config.yaml') }}"
restore-keys: |
lint-${{ runner.os }}-py${{ env.PY_VERSION }}-
lint-${{ runner.os }}-
${{ env.BASE_CACHE_KEY }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
Expand All @@ -49,22 +47,24 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [3.6, 3.7, 3.8]
python-version: [3.6, 3.7, 3.8, 3.9]
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
- id: setup-python
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Cache testing environments
uses: actions/cache@v2
- uses: actions/cache@v2
env:
BASE_CACHE_KEY: "${{ github.job }}-${{ runner.os }}-\
py${{ steps.setup-python.outputs.python-version }}-"
with:
path: ${{ env.PIP_CACHE_DIR }}
key: "test-${{ runner.os }}-py${{ matrix.python-version }}-\
key: "${{ env.BASE_CACHE_KEY }}\
${{ hashFiles('**/requirements-test.txt') }}-\
${{ hashFiles('**/requirements.txt') }}"
restore-keys: |
test-${{ runner.os }}-py${{ matrix.python-version }}-
test-${{ runner.os }}-
${{ env.BASE_CACHE_KEY }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
Expand All @@ -83,21 +83,23 @@ jobs:
needs: [lint, test]
strategy:
matrix:
python-version: [3.6, 3.7, 3.8]
python-version: [3.6, 3.7, 3.8, 3.9]
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
- id: setup-python
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Cache building environments
uses: actions/cache@v2
- uses: actions/cache@v2
env:
BASE_CACHE_KEY: "${{ github.job }}-${{ runner.os }}-\
py${{ steps.setup-python.outputs.python-version }}-"
with:
path: ${{ env.PIP_CACHE_DIR }}
key: "build-${{ runner.os }}-py${{ matrix.python-version }}-\
key: "${{ env.BASE_CACHE_KEY }}\
${{ hashFiles('**/requirements.txt') }}"
restore-keys: |
build-${{ runner.os }}-py${{ matrix.python-version }}-
build-${{ runner.os }}-
${{ env.BASE_CACHE_KEY }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip wheel
Expand Down
76 changes: 76 additions & 0 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
---
# For most projects, this workflow file will not need changing; you simply need
# to commit it to your repository.
#
# You may wish to alter this file to override the set of languages analyzed,
# or to provide custom queries or build logic.
name: "CodeQL"

on:
push:
# Push on all branches
# branches: [develop]
pull_request:
# The branches below must be a subset of the branches above
branches: [develop]
schedule:
- cron: '0 14 * * 6'

jobs:
analyze:
name: Analyze
runs-on: ubuntu-latest

strategy:
fail-fast: false
matrix:
# Override automatic language detection by changing the below list
# Supported options are ['csharp', 'cpp', 'go', 'java', 'javascript',
# 'python']
language: ['python']
# Learn more...
# https://docs.github.com/en/github/finding-security-vulnerabilities-and-errors-in-your-code/configuring-code-scanning#overriding-automatic-language-detection

steps:
- name: Checkout repository
uses: actions/checkout@v2
with:
# We must fetch at least the immediate parents so that if this is
# a pull request then we can checkout the head.
fetch-depth: 2

# If this run was triggered by a pull request event, then checkout
# the head of the pull request instead of the merge commit.
- run: git checkout HEAD^2
if: ${{ github.event_name == 'pull_request' }}

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v1
with:
languages: ${{ matrix.language }}
# If you wish to specify custom queries, you can do so here or in a
# config file. By default, queries listed here will override any
# specified in a config file. Prefix the list here with "+" to use
# these queries and those in the config file. queries:
# ./path/to/local/query, your-org/your-repo/queries@main

# Autobuild attempts to build any compiled languages (C/C++, C#, or
# Java). If this step fails, then you should remove it and run the build
# manually (see below)
- name: Autobuild
uses: github/codeql-action/autobuild@v1

# ℹ️ Command-line programs to run using the OS shell.
# 📚 https://git.io/JvXDl

# ✏️ If the Autobuild fails above, remove it and uncomment the following
# three lines and modify them (or add more) to build your code if your
# project uses a compiled language

#- run: |
# make bootstrap
# make release

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v1
60 changes: 34 additions & 26 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,30 +26,30 @@ repos:
- --autofix
- id: requirements-txt-fixer
- id: trailing-whitespace

# Text file hooks
- repo: https://github.com/igorshubovych/markdownlint-cli
rev: v0.23.2
rev: v0.24.0
hooks:
- id: markdownlint
args:
- --config=.mdl_config.json
- repo: https://github.com/prettier/pre-commit
rev: v2.1.2
hooks:
- id: prettier
- repo: https://github.com/adrienverge/yamllint
rev: v1.24.2
rev: v1.25.0
hooks:
- id: yamllint

# Shell script hooks
- repo: https://github.com/detailyang/pre-commit-shell
rev: 1.0.5
hooks:
- id: shell-lint
- repo: https://gitlab.com/pycqa/flake8
rev: 3.8.3
hooks:
- id: flake8
additional_dependencies:
- flake8-docstrings
- repo: https://github.com/asottile/pyupgrade
rev: v2.7.2
hooks:
- id: pyupgrade

# Python hooks
# Run bandit on "tests" tree with a configuration
- repo: https://github.com/PyCQA/bandit
rev: 1.6.2
Expand All @@ -70,21 +70,35 @@ repos:
rev: 20.8b1
hooks:
- id: black
- repo: https://github.com/asottile/seed-isort-config
rev: v2.2.0
- repo: https://gitlab.com/pycqa/flake8
rev: 3.8.4
hooks:
- id: seed-isort-config
- id: flake8
additional_dependencies:
- flake8-docstrings
- repo: https://github.com/timothycrosley/isort
rev: 5.5.0
rev: 5.6.4
hooks:
- id: isort
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v0.790
hooks:
- id: mypy
- repo: https://github.com/asottile/pyupgrade
rev: v2.7.2
hooks:
- id: pyupgrade

# Ansible hooks
- repo: https://github.com/ansible/ansible-lint.git
rev: v4.3.4
rev: v4.3.5
hooks:
- id: ansible-lint
# files: molecule/default/playbook.yml

# Terraform hooks
- repo: https://github.com/antonbabenko/pre-commit-terraform.git
rev: v1.37.0
rev: v1.43.0
hooks:
- id: terraform_fmt
# There are ongoing issues with how this command works. This issue
Expand All @@ -103,15 +117,9 @@ repos:
# above have been resolved, which we hope will be with the release of
# Terraform 0.13.
# - id: terraform_validate

# Docker hooks
- repo: https://github.com/IamTheFij/docker-pre-commit
rev: v2.0.0
hooks:
- id: docker-compose-check
- repo: https://github.com/prettier/prettier
rev: 2.1.1
hooks:
- id: prettier
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v0.782
hooks:
- id: mypy
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ with the command `pca-wizard-templates --emails`.

## Contributing ##

We welcome contributions! Please see [here](CONTRIBUTING.md) for
We welcome contributions! Please see [`CONTRIBUTING.md`](CONTRIBUTING.md) for
details.

## License ##
Expand Down
2 changes: 1 addition & 1 deletion requirements-test.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
--editable .[test]
--requirement requirements.txt
-e .[test]
32 changes: 22 additions & 10 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@
"""

# Standard Python Libraries
import codecs
from glob import glob
from os.path import basename, splitext
from os.path import abspath, basename, dirname, join, splitext

# Third-Party Libraries
from setuptools import find_packages, setup
Expand All @@ -22,18 +23,28 @@ def readme():
return f.read()


def package_vars(version_file):
"""Read in and return the variables defined by the version_file."""
pkg_vars = {}
with open(version_file) as f:
exec(f.read(), pkg_vars) # nosec
return pkg_vars
# Below two methods were pulled from:
# https://packaging.python.org/guides/single-sourcing-package-version/
def read(rel_path):
"""Open a file for reading from a given relative path."""
here = abspath(dirname(__file__))
with codecs.open(join(here, rel_path), "r") as fp:
return fp.read()


def get_version(version_file):
"""Extract a version number from the given file path."""
for line in read(version_file).splitlines():
if line.startswith("__version__"):
delim = '"' if '"' in line else "'"
return line.split(delim)[1]
raise RuntimeError("Unable to find version string.")


setup(
name="gophish-tools",
# Versions should comply with PEP440
version=package_vars("src/_version.py")["__version__"],
version=get_version("src/_version.py"),
description="Helpful tools for interacting with GoPhish",
long_description=readme(),
long_description_content_type="text/markdown",
Expand Down Expand Up @@ -62,6 +73,7 @@ def package_vars(version_file):
"Programming Language :: Python :: 3.6",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
],
python_requires=">=3.6",
# What does your project relate to?
Expand All @@ -82,15 +94,15 @@ def package_vars(version_file):
],
extras_require={
"test": [
"pre-commit",
"coverage",
# coveralls 1.11.0 added a service number for calls from
# GitHub Actions. This caused a regression which resulted in a 422
# response from the coveralls API with the message:
# Unprocessable Entity for url: https://coveralls.io/api/v1/jobs
# 1.11.1 fixed this issue, but to ensure expected behavior we'll pin
# to never grab the regression version.
"coveralls != 1.11.0",
"coverage",
"pre-commit",
"pytest-cov",
"mock",
"pytest",
Expand Down

0 comments on commit a6b08f2

Please sign in to comment.