Skip to content

Commit cbe72d6

Browse files
authored
Merge pull request #1 from cisagov/first-commits
First commits
2 parents 361a06a + d3887b2 commit cbe72d6

File tree

14 files changed

+1415
-284
lines changed

14 files changed

+1415
-284
lines changed

.coveragerc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# https://coverage.readthedocs.io/en/latest/config.html
33

44
[run]
5-
source = src/example
5+
source = src/guacscanner
66
omit =
77
branch = true
88

README.md

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,20 +6,17 @@
66
[![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)
77
[![Known Vulnerabilities](https://snyk.io/test/github/cisagov/guacscanner/develop/badge.svg)](https://snyk.io/test/github/cisagov/guacscanner)
88

9-
This is a generic skeleton project that can be used to quickly get a
10-
new [cisagov](https://github.com/cisagov) Python library GitHub
11-
project started. This skeleton project contains [licensing
12-
information](LICENSE), as well as
13-
[pre-commit hooks](https://pre-commit.com) and
14-
[GitHub Actions](https://github.com/features/actions) configurations
15-
appropriate for a Python library project.
16-
17-
## New Repositories from a Skeleton ##
18-
19-
Please see our [Project Setup guide](https://github.com/cisagov/development-guide/tree/develop/project_setup)
20-
for step-by-step instructions on how to start a new repository from
21-
a skeleton. This will save you time and effort when configuring a
22-
new repository!
9+
This project is a Python utility that continually scans the EC2 instances
10+
in an AWS VPC and adds/removes Guacamole connections in the underlying
11+
PostgreSQL database accordingly.
12+
13+
This utility is [Dockerized](https://docker.com) in
14+
[cisagov/guacscanner-docker](https://github.com/cisagov/guacscanner-docker),
15+
and the resulting Docker container is intended to run as a part of
16+
[cisagov/guacamole-composition](https://github.com/cisagov/guacamole-composition),
17+
although it could - probably uselessly - run in a [Docker
18+
composition](https://docs.docker.com/compose/) alongside only the
19+
[official PostgreSQL Docker image](https://hub.docker.com/_/postgres).
2320

2421
## Contributing ##
2522

bump_version.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ set -o nounset
66
set -o errexit
77
set -o pipefail
88

9-
VERSION_FILE=src/example/_version.py
9+
VERSION_FILE=src/guacscanner/_version.py
1010

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

setup.py

Lines changed: 23 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
"""
2-
This is the setup module for the example project.
2+
This is the setup module for the guacscanner project.
33
44
Based on:
55
@@ -42,10 +42,10 @@ def get_version(version_file):
4242

4343

4444
setup(
45-
name="example",
45+
name="guacscanner",
4646
# Versions should comply with PEP440
47-
version=get_version("src/example/_version.py"),
48-
description="Example Python library",
47+
version=get_version("src/guacscanner/_version.py"),
48+
description="Scan for EC2 instances added (removed) from a VPC and create (destroy) the corresponding Guacamole connections.",
4949
long_description=readme(),
5050
long_description_content_type="text/markdown",
5151
# Landing page for CISA's cybersecurity mission
@@ -81,13 +81,21 @@ def get_version(version_file):
8181
],
8282
python_requires=">=3.6",
8383
# What does your project relate to?
84-
keywords="skeleton",
84+
keywords="aws, guacamole, vpc",
8585
packages=find_packages(where="src"),
8686
package_dir={"": "src"},
87-
package_data={"example": ["data/*.txt"]},
8887
py_modules=[splitext(basename(path))[0] for path in glob("src/*.py")],
8988
include_package_data=True,
90-
install_requires=["docopt", "schema", "setuptools >= 24.2.0"],
89+
# TODO: Loosen these requirements. See cisagov/guacscanner#9 for
90+
# more details.
91+
install_requires=[
92+
"boto3 == 1.19.6",
93+
"docopt == 0.6.2",
94+
"ec2-metadata == 2.5.0",
95+
"psycopg == 3.0.1",
96+
"schema == 0.7.4",
97+
"setuptools >= 24.2.0",
98+
],
9199
extras_require={
92100
"test": [
93101
"coverage",
@@ -98,11 +106,17 @@ def get_version(version_file):
98106
# 1.11.1 fixed this issue, but to ensure expected behavior we'll pin
99107
# to never grab the regression version.
100108
"coveralls != 1.11.0",
109+
"moto",
101110
"pre-commit",
102111
"pytest-cov",
103112
"pytest",
104113
]
105114
},
106-
# Conveniently allows one to run the CLI tool as `example`
107-
entry_points={"console_scripts": ["example = example.example:main"]},
115+
# Conveniently allows one to run the CLI tool as
116+
# `guacscanner`
117+
entry_points={
118+
"console_scripts": [
119+
"guacscanner = guacscanner.guacscanner:main",
120+
],
121+
},
108122
)

src/example/__init__.py

Lines changed: 0 additions & 9 deletions
This file was deleted.

src/example/data/secret.txt

Lines changed: 0 additions & 1 deletion
This file was deleted.

src/example/example.py

Lines changed: 0 additions & 103 deletions
This file was deleted.
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
"""A dataclass container for Guacamole connection parameters."""
2+
3+
4+
# Standard Python Libraries
5+
from dataclasses import dataclass
6+
7+
8+
@dataclass
9+
class ConnectionParameters:
10+
"""A dataclass container for Guacamole connection parameters."""
11+
12+
"""The slots for this dataclass."""
13+
__slots__ = (
14+
"private_ssh_key",
15+
"rdp_password",
16+
"rdp_username",
17+
"vnc_password",
18+
"vnc_username",
19+
)
20+
21+
"""The private SSH key to use when transferring data via VNC."""
22+
private_ssh_key: str
23+
24+
"""The password to use when Guacamole establishes an RDP connection."""
25+
rdp_password: str
26+
27+
"""The user name to use when Guacamole establishes an RDP connection."""
28+
rdp_username: str
29+
30+
"""The password to use when Guacamole establishes a VNC connection."""
31+
vnc_password: str
32+
33+
"""The user name to use when Guacamole establishes a VNC connection."""
34+
vnc_username: str

src/guacscanner/__init__.py

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
"""The guacscanner library."""
2+
# We disable a Flake8 check for "Module imported but unused (F401)"
3+
# here because, although this import is not directly used, it
4+
# populates the value package_name.__version__, which is used to get
5+
# version information about this Python package.
6+
from ._version import __version__ # noqa: F401
7+
from .guacscanner import (
8+
ConnectionParameters,
9+
add_instance_connection,
10+
add_user,
11+
check_for_ghost_instances,
12+
entity_exists,
13+
get_connection_name,
14+
get_entity_id,
15+
instance_connection_exists,
16+
main,
17+
process_instance,
18+
remove_connection,
19+
remove_instance_connections,
20+
)
21+
22+
__all__ = [
23+
"ConnectionParameters",
24+
"add_instance_connection",
25+
"add_user",
26+
"check_for_ghost_instances",
27+
"entity_exists",
28+
"get_connection_name",
29+
"get_entity_id",
30+
"instance_connection_exists",
31+
"main",
32+
"process_instance",
33+
"remove_connection",
34+
"remove_instance_connections",
35+
]
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
"""Code to run if this package is used as a Python module."""
22

3-
from .example import main
3+
from .guacscanner import main
44

55
main()
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
"""This file defines the version of this module."""
2-
__version__ = "0.0.1"
2+
__version__ = "1.0.0"

0 commit comments

Comments
 (0)