-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #48 from cisagov/feature/add-bootstrap
feature: add bootstrap
- Loading branch information
Showing
14 changed files
with
182 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import logging | ||
import os | ||
|
||
from flask import Flask, render_template, send_from_directory | ||
|
||
from navv.gui.utils import get_pcap_file | ||
|
||
|
||
logging.basicConfig(level=logging.INFO) | ||
logger = logging.getLogger(__name__) | ||
app = Flask(__name__) | ||
|
||
|
||
@app.route("/") | ||
def index(): | ||
pcap_file, pcap_msg, pcap_msg_color = get_pcap_file() | ||
|
||
return render_template( | ||
"index.html", | ||
pcap_file=pcap_file, | ||
pcap_msg=pcap_msg, | ||
pcap_msg_color=pcap_msg_color, | ||
) | ||
|
||
|
||
@app.route("/download") | ||
def download(): | ||
"""Download the network analysis excel file.""" | ||
filename = "test-customer_network_analysis.xlsx" | ||
current_path = os.getcwd() | ||
|
||
if not os.path.isfile(os.path.join(current_path, filename)): | ||
logger.error(f"File {filename} not found in {current_path}") | ||
|
||
return send_from_directory( | ||
current_path, | ||
filename, | ||
as_attachment=True, | ||
) |
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
@media (min-width: 992px) { | ||
.rounded-lg-3 { | ||
border-radius: .3rem; | ||
} | ||
} | ||
|
||
.alert { | ||
width: 40%; | ||
font-size: .5rem; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
<!doctype html> | ||
<html lang="en"> | ||
|
||
<head> | ||
<meta charset="utf-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1"> | ||
<meta name="description" content=""> | ||
<meta name="author" content="Idaho National Laboratory"> | ||
<meta name="generator" content="Hugo 0.84.0"> | ||
<title>NAVV</title> | ||
|
||
<link rel="canonical" href="https://pypi.org/project/navv/"> | ||
|
||
|
||
|
||
<!-- Bootstrap core CSS --> | ||
<link href="../static/css/bootstrap.min.css" rel="stylesheet"> | ||
|
||
<style> | ||
.bd-placeholder-img { | ||
font-size: 1.125rem; | ||
text-anchor: middle; | ||
-webkit-user-select: none; | ||
-moz-user-select: none; | ||
user-select: none; | ||
} | ||
|
||
@media (min-width: 768px) { | ||
.bd-placeholder-img-lg { | ||
font-size: 3.5rem; | ||
} | ||
} | ||
</style> | ||
|
||
<!-- Custom styles for this template --> | ||
<link href="../static/styles.css" rel="stylesheet"> | ||
</head> | ||
|
||
<body> | ||
|
||
<main> | ||
<h1 class="visually-hidden">NAVV</h1> | ||
|
||
<div class="px-4 py-5 my-5 text-center"> | ||
<img class="d-block mx-auto mb-4" src="../static/img/navv-logo.png" alt="" width="100" height="100"> | ||
<h1 class="display-5 fw-bold">NAVV</h1> | ||
<div class="col-lg-6 mx-auto"> | ||
<h3 class="lead mb-3">Network Architecture Verification and Validation</h3> | ||
<p class="mb-3">Generate a spreadsheet for network traffic analysis. You can optionally upload a PCAP file to | ||
analyze network traffic. | ||
</p> | ||
<div class="d-grid gap-2 d-sm-flex justify-content-sm-center"> | ||
<button type="file" class="btn btn-primary btn-sm px-4 gap-3 {% if pcap_file %}disabled{% endif %}">Upload | ||
PCAP</button> | ||
<a class="btn btn-outline-secondary btn-sm px-4" href="{{ url_for('download') }}">Download Excel</a> | ||
</div> | ||
</div> | ||
<div class="alert alert-{{ pcap_msg_color }} mx-auto mt-3" role="alert">{{ pcap_msg }}</div> | ||
</div> | ||
|
||
<div class="bg-dark text-secondary px-2 py-3 text-center"> | ||
<div class="py-3"> | ||
<div class="col-lg-6 mx-auto"> | ||
<p class="fs-5 mb-3">This project uses <a class="link-offset-2 link-underline link-underline-opacity-0" | ||
href="https://zeek.org">Zeek</a>, a network security monitoring tool. | ||
</p> | ||
</div> | ||
</div> | ||
</div> | ||
</main> | ||
|
||
|
||
<script src="../static/dist/js/bootstrap.bundle.min.js"></script> | ||
|
||
|
||
</body> | ||
|
||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import os | ||
import logging | ||
|
||
logger = logging.getLogger(__name__) | ||
|
||
|
||
def get_pcap_file() -> tuple[str, str, str]: | ||
"""Get the pcap file from the current working directory.""" | ||
pcap_files = set() | ||
for file in os.listdir(os.getcwd()): | ||
if file.endswith(".pcap"): | ||
logger.info(f"Found pcap file: {file} in {os.getcwd()}") | ||
pcap_files.add(file) | ||
|
||
# No PCAP file found | ||
if len(pcap_files) == 0: | ||
logger.error(f"Could not find a pcap file in {os.getcwd()}") | ||
return ( | ||
"", | ||
"Could not find a pcap file in the current directory. Please upload.", | ||
"warning", | ||
) | ||
|
||
# Multiple PCAP files found | ||
if len(pcap_files) > 1: | ||
logger.error(f"Found multiple pcap files, please remove all but one.") | ||
return "", "Found multiple pcap files. Please remove all but one.", "danger" | ||
|
||
filename = pcap_files.pop() | ||
return filename, f"{filename} detected and uploaded successfully.", "success" |