Skip to content

Commit

Permalink
Merge pull request #1 from cisagov/first-commits
Browse files Browse the repository at this point in the history
First commits
  • Loading branch information
jsf9k committed Nov 12, 2021
2 parents 361a06a + d3887b2 commit cbe72d6
Show file tree
Hide file tree
Showing 14 changed files with 1,415 additions and 284 deletions.
2 changes: 1 addition & 1 deletion .coveragerc
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# https://coverage.readthedocs.io/en/latest/config.html

[run]
source = src/example
source = src/guacscanner
omit =
branch = true

Expand Down
25 changes: 11 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,17 @@
[![Language grade: Python](https://img.shields.io/lgtm/grade/python/g/cisagov/guacscanner.svg?logo=lgtm&logoWidth=18)](https://lgtm.com/projects/g/cisagov/guacscanner/context:python)
[![Known Vulnerabilities](https://snyk.io/test/github/cisagov/guacscanner/develop/badge.svg)](https://snyk.io/test/github/cisagov/guacscanner)

This is a generic skeleton project that can be used to quickly get a
new [cisagov](https://github.com/cisagov) Python library GitHub
project started. This skeleton project contains [licensing
information](LICENSE), as well as
[pre-commit hooks](https://pre-commit.com) and
[GitHub Actions](https://github.com/features/actions) configurations
appropriate for a Python library project.

## New Repositories from a Skeleton ##

Please see our [Project Setup guide](https://github.com/cisagov/development-guide/tree/develop/project_setup)
for step-by-step instructions on how to start a new repository from
a skeleton. This will save you time and effort when configuring a
new repository!
This project is a Python utility that continually scans the EC2 instances
in an AWS VPC and adds/removes Guacamole connections in the underlying
PostgreSQL database accordingly.

This utility is [Dockerized](https://docker.com) in
[cisagov/guacscanner-docker](https://github.com/cisagov/guacscanner-docker),
and the resulting Docker container is intended to run as a part of
[cisagov/guacamole-composition](https://github.com/cisagov/guacamole-composition),
although it could - probably uselessly - run in a [Docker
composition](https://docs.docker.com/compose/) alongside only the
[official PostgreSQL Docker image](https://hub.docker.com/_/postgres).

## Contributing ##

Expand Down
2 changes: 1 addition & 1 deletion bump_version.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ set -o nounset
set -o errexit
set -o pipefail

VERSION_FILE=src/example/_version.py
VERSION_FILE=src/guacscanner/_version.py

HELP_INFORMATION="bump_version.sh (show|major|minor|patch|prerelease|build|finalize)"

Expand Down
32 changes: 23 additions & 9 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"""
This is the setup module for the example project.
This is the setup module for the guacscanner project.
Based on:
Expand Down Expand Up @@ -42,10 +42,10 @@ def get_version(version_file):


setup(
name="example",
name="guacscanner",
# Versions should comply with PEP440
version=get_version("src/example/_version.py"),
description="Example Python library",
version=get_version("src/guacscanner/_version.py"),
description="Scan for EC2 instances added (removed) from a VPC and create (destroy) the corresponding Guacamole connections.",
long_description=readme(),
long_description_content_type="text/markdown",
# Landing page for CISA's cybersecurity mission
Expand Down Expand Up @@ -81,13 +81,21 @@ def get_version(version_file):
],
python_requires=">=3.6",
# What does your project relate to?
keywords="skeleton",
keywords="aws, guacamole, vpc",
packages=find_packages(where="src"),
package_dir={"": "src"},
package_data={"example": ["data/*.txt"]},
py_modules=[splitext(basename(path))[0] for path in glob("src/*.py")],
include_package_data=True,
install_requires=["docopt", "schema", "setuptools >= 24.2.0"],
# TODO: Loosen these requirements. See cisagov/guacscanner#9 for
# more details.
install_requires=[
"boto3 == 1.19.6",
"docopt == 0.6.2",
"ec2-metadata == 2.5.0",
"psycopg == 3.0.1",
"schema == 0.7.4",
"setuptools >= 24.2.0",
],
extras_require={
"test": [
"coverage",
Expand All @@ -98,11 +106,17 @@ def get_version(version_file):
# 1.11.1 fixed this issue, but to ensure expected behavior we'll pin
# to never grab the regression version.
"coveralls != 1.11.0",
"moto",
"pre-commit",
"pytest-cov",
"pytest",
]
},
# Conveniently allows one to run the CLI tool as `example`
entry_points={"console_scripts": ["example = example.example:main"]},
# Conveniently allows one to run the CLI tool as
# `guacscanner`
entry_points={
"console_scripts": [
"guacscanner = guacscanner.guacscanner:main",
],
},
)
9 changes: 0 additions & 9 deletions src/example/__init__.py

This file was deleted.

1 change: 0 additions & 1 deletion src/example/data/secret.txt

This file was deleted.

103 changes: 0 additions & 103 deletions src/example/example.py

This file was deleted.

34 changes: 34 additions & 0 deletions src/guacscanner/ConnectionParameters.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
"""A dataclass container for Guacamole connection parameters."""


# Standard Python Libraries
from dataclasses import dataclass


@dataclass
class ConnectionParameters:
"""A dataclass container for Guacamole connection parameters."""

"""The slots for this dataclass."""
__slots__ = (
"private_ssh_key",
"rdp_password",
"rdp_username",
"vnc_password",
"vnc_username",
)

"""The private SSH key to use when transferring data via VNC."""
private_ssh_key: str

"""The password to use when Guacamole establishes an RDP connection."""
rdp_password: str

"""The user name to use when Guacamole establishes an RDP connection."""
rdp_username: str

"""The password to use when Guacamole establishes a VNC connection."""
vnc_password: str

"""The user name to use when Guacamole establishes a VNC connection."""
vnc_username: str
35 changes: 35 additions & 0 deletions src/guacscanner/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
"""The guacscanner library."""
# We disable a Flake8 check for "Module imported but unused (F401)"
# here because, although this import is not directly used, it
# populates the value package_name.__version__, which is used to get
# version information about this Python package.
from ._version import __version__ # noqa: F401
from .guacscanner import (
ConnectionParameters,
add_instance_connection,
add_user,
check_for_ghost_instances,
entity_exists,
get_connection_name,
get_entity_id,
instance_connection_exists,
main,
process_instance,
remove_connection,
remove_instance_connections,
)

__all__ = [
"ConnectionParameters",
"add_instance_connection",
"add_user",
"check_for_ghost_instances",
"entity_exists",
"get_connection_name",
"get_entity_id",
"instance_connection_exists",
"main",
"process_instance",
"remove_connection",
"remove_instance_connections",
]
2 changes: 1 addition & 1 deletion src/example/__main__.py → src/guacscanner/__main__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"""Code to run if this package is used as a Python module."""

from .example import main
from .guacscanner import main

main()
2 changes: 1 addition & 1 deletion src/example/_version.py → src/guacscanner/_version.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
"""This file defines the version of this module."""
__version__ = "0.0.1"
__version__ = "1.0.0"

0 comments on commit cbe72d6

Please sign in to comment.