Skip to content
This repository has been archived by the owner on Feb 14, 2024. It is now read-only.

Commit

Permalink
Merge 3d6012c into ee68ece
Browse files Browse the repository at this point in the history
  • Loading branch information
cduhn17 committed Jun 9, 2022
2 parents ee68ece + 3d6012c commit 57d56ab
Show file tree
Hide file tree
Showing 15 changed files with 3,832 additions and 7 deletions.
25 changes: 20 additions & 5 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ def get_version(version_file):
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
],
python_requires=">=3.6",
# What does your project relate to?
Expand All @@ -95,25 +96,39 @@ def get_version(version_file):
"boto3 == 1.21.10",
"botocore == 1.24.10",
"chevron == 0.14.0",
"docopt == 0.6.2",
"celery",
"click==8.0.3",
"docopt",
"glob2 == 0.7",
"importlib-resources == 5.4.0",
"flask",
"flask",
"flask_login",
"flask_migrate",
"flask_wtf",
"Flask-SQLAlchemy",
"importlib_resources == 5.4.0",
"matplotlib == 3.3.4",
"mongo-db-from-config@http://github.com/cisagov/mongo-db-from-config/tarball/develop",
"openpyxl == 3.0.9",
"openpyxl",
"pandas == 1.1.5",
"psycopg2 == 2.9.3",
"psutil",
"psycopg2-binary == 2.9.3",
"pymongo == 4.0.1",
"pymupdf == 1.19.0",
"pytest-cov == 3.0.0",
"python-dateutil >= 2.7.3",
"pytest-cov",
"python-pptx == 0.6.21",
"pytz",
"pyyaml == 6.0",
"reportlab == 3.6.6",
"requests == 2.26.0",
"schema == 0.7.5",
"setuptools == 58.1.0",
"shodan ==1.27.0",
"sublist3r",
"types-PyYAML == 6.0.4",
"urllib3 == 1.26.7",
"wtforms",
"xhtml2pdf == 0.2.5",
],
extras_require={
Expand Down
59 changes: 58 additions & 1 deletion src/pe_reports/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,63 @@
# package_name.__version__, which is used to get version information about this
# Python package.

# Standard Python Libraries
import logging
import os

# Third-Party Libraries
from celery import Celery
from flask import Flask
from flask_login import LoginManager
from flask_migrate import Migrate
from flask_sqlalchemy import SQLAlchemy

# cisagov Libraries
from pe_reports.data.config import config

# Stakeholder views
from pe_reports.home.views import home_blueprint
from pe_reports.stakeholder.views import stakeholder_blueprint

from ._version import __version__ # noqa: F401

__all__ = ["pages", "report_generator", "stylesheet"]
params = config()
login_manager = LoginManager()
# Flask implementation
app = Flask(__name__)
app.config["SECRET_KEY"] = os.getenv("FLASK_SECRET_KEY", "dev")
app.config["SQLALCHEMY_TRACK_MODIFICATIONS"] = False
app.config[
"SQLALCHEMY_DATABASE_URI"
] = f'postgresql+psycopg2://{params["user"]}:{params["password"]}@{params["host"]}:{params["port"]}/{params["database"]}'


# Configure the redis server
app.config["CELERY_BROKER_URL"] = "redis://localhost:6379/0"
app.config["CELERY_RESULT_BACKEND"] = "redis://localhost:6379/0"

# Creates a Celery object
celery = Celery(app.name, broker=app.config["CELERY_BROKER_URL"])
celery.conf.update(app.config)

# Config DB
db = SQLAlchemy(app)
Migrate(app, db)

# TODO: Add a login page in the future. Issue #207 contains details
# login_manager.init_app(app)
# login_manager.login_view = "login"

__all__ = ["app", "pages", "report_generator", "stylesheet"]


# Register the flask apps
app.register_blueprint(stakeholder_blueprint)
# TODO: Add login blueprint. Issue #207 contains details
# app.register_blueprint(manage_login_blueprint)
app.register_blueprint(home_blueprint)


if __name__ == "__main__":
logging.info("The program has started...")
app.run(host="127.0.0.1", debug=False, port=8000)
1 change: 1 addition & 0 deletions src/pe_reports/home/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"""Init file for module implementation."""
53 changes: 53 additions & 0 deletions src/pe_reports/home/templates/home/home.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
{% extends "base.html" %} {% block content %} {#
<div class="container">
#} {#
<img#}
{#
src="{{ url_for('static', filename='CISAImage.png') }}"
#}
{#
alt="Cinque Terre"
#}
{#
width="200"
#}
{#
height="200"
#}
{#
/>#} {#{% if current_user.is_authenticated %}#} {#
<p>Welcome {{ current_user.username }}</p>
#} {# {% else %}#} {#
<p>Please Login</p>
#} {##} {#{% endif %}#} {#
</div>
#}
<!--End of container-->
<script>
function showDiv() {
let T = document.getElementById("TestsDiv"),
displayValue = "";
if (T.style.display == "") displayValue = "none";
T.style.display = displayValue;
}

function loading() {
$("#loading").show();
$("#content").hide();
}

$(document).ready(function () {
console.log("Im ready ");

showDiv();

setTimeout(function () {
$("#messageDiv").fadeOut("fast");
}, 5000);
$(window).load(function () {
$("#loading").hide();
});
});
</script>

{% endblock %}
18 changes: 18 additions & 0 deletions src/pe_reports/home/views.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
"""Flask application will add new stakeholder information to the PE Database.
Automate the process to add stakeholder information to Cyber Sixgill portal.
"""

# Third-Party Libraries
from flask import Blueprint, render_template

home_blueprint = Blueprint("home", __name__, template_folder="templates/home")


@home_blueprint.route("/")
def index():
"""Create "add customer" HTML form.
Gather data from form and insert into database.
"""
return render_template("home.html")
1 change: 1 addition & 0 deletions src/pe_reports/stakeholder/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"""Init file for module implementation."""
31 changes: 31 additions & 0 deletions src/pe_reports/stakeholder/forms.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
"""Create the stakeholder data input form."""

# Third-Party Libraries
from flask_wtf import FlaskForm
from wtforms import StringField, SubmitField
from wtforms.validators import DataRequired


class InfoFormExternal(FlaskForm):
"""Create web form to take user input on organization information/details."""

cust = StringField("What is the stakeholder name?", validators=[DataRequired()])
# TODO: The following form field may be used in a future update. Issue #208
# custIP = StringField(
# "What is the stakeholder ip/cidr? *comma separate entries",
# validators=[DataRequired()],
# )
custRootDomain = StringField(
"What is the root domain for this stakeholder? " "*comma separate entries"
)
custDomainAliases = StringField(
"What are the organization aliases? " "*comma separate entries"
)
# TODO: The following form field may be used in a future update. Issue #208
# custSubDomain = StringField(
# "What is the sub-domain for this stakeholder?" " *comma separate entries"
# )
custExecutives = StringField(
"Who are the executives for this stakeholder? " "*comma separate entries"
)
submit = SubmitField("Submit", render_kw={"onclick": "loading()"})
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
{% extends "base.html" %} {% block content %}

<div class="container">
<img
src="{{ url_for('static', filename='CISAImage.png') }}"
alt="CISA seal image"
width="200"
height="200"
/>
<div id="loading" class="justify-content-lg-center"></div>
<div class="row justify-content-lg-center">
<div class="row col-lg-6 offset-lg-3">
<input
type="hidden"
value="{% block title %} Stakeholder {% endblock%}"
/>

<button type="button" class="btn btn-primary" onclick="showDiv()">
Add External Stakeholder
</button>
</div>
<br />

<div id="TestsDiv" class="row justify-content-lg-center">
<div class="d-flex justify-content-center">
<div class="card" id="content">
<div class="card-header text-white bg-primary mb-3">
Add external agency
</div>
<div class="card-body">
<form method="post">
{{ formExternal.hidden_tag() }} {{
formExternal.cust.label(style='font-size: 24px') }} {{
formExternal.cust(class='form-control') }} {{
formExternal.custDomainAliases.label(style='font-size: 24px') }}
{{ formExternal.custDomainAliases(class='form-control') }} {{
formExternal.custRootDomain.label(style='font-size: 24px') }} {{
formExternal.custRootDomain(class='form-control') }} {{
formExternal.custExecutives.label(style='font-size: 24px') }} {{
formExternal.custExecutives(class='form-control') }}
<br />
{{ formExternal.submit(class='btn btn-primary') }}
</form>
</div>
</div>
</div>
</div>
</div>
<!--End of container-->
<script>
function showDiv() {
let T = document.getElementById("TestsDiv"),
displayValue = "";
if (T.style.display == "") displayValue = "none";
T.style.display = displayValue;
}

function loading() {
$("#loading").show();
$("#content").hide();
}

$(document).ready(function () {
console.log("Im ready ");

showDiv();

setTimeout(function () {
$("#messageDiv").fadeOut("fast");
}, 5000);
$(window).load(function () {
$("#loading").hide();
});
});
</script>

{% endblock %}
</div>

0 comments on commit 57d56ab

Please sign in to comment.