From 4f4637f05fbdbaed7a138c22984283f5a362e6d6 Mon Sep 17 00:00:00 2001 From: Roy Russo Date: Thu, 26 Dec 2024 15:05:50 -0500 Subject: [PATCH] -- --- README.md | 62 +++++++++---------- backend/api/default.py | 6 +- backend/main.py | 14 ++++- docker-compose.yml | 8 +-- ...{Dockerfile-backend => backend.Dockerfile} | 0 ...ockerfile-frontend => frontend.Dockerfile} | 0 frontend/src/App.tsx | 2 +- frontend/src/components/header.tsx | 2 +- frontend/src/routes/home.tsx | 2 +- spa_docker_attempt | 62 +++++++++++++++++++ 10 files changed, 116 insertions(+), 42 deletions(-) rename docker/{Dockerfile-backend => backend.Dockerfile} (100%) rename docker/{Dockerfile-frontend => frontend.Dockerfile} (100%) create mode 100644 spa_docker_attempt diff --git a/README.md b/README.md index b164911..0f61c61 100644 --- a/README.md +++ b/README.md @@ -1,32 +1,20 @@ -# PROBUS +
+ +# Probus - Network Scanner [![codecov](https://codecov.io/github/royrusso/probus/graph/badge.svg?token=B972KDOOOB)](https://codecov.io/github/royrusso/probus) ![Tests](https://img.shields.io/github/actions/workflow/status/royrusso/probus/pytests_codecov.yml?label=Tests) ![License](https://img.shields.io/badge/license-Apache%202.0-blue?style=flat-square) -# This project is in early development! - -A _FAST_ network monitor and UI that actively scans and alerts you -to network changes, new devices, open ports, and identifies CVEs -(Common Vulnerabilities and Exposures) - -## Table of Contents - -- [Introduction](#introduction) - - [Features](#features) -- [Installation](#installation) -- [Development](#development) -- [Contributing](#contributing) -- [Contact](#contact) -- [License](#license) +**This project is in early development!** -## Introduction +A network scanner with an attractive UI, that identifies security vulnerabilities in your network and alerts you to new ones as they arise. Scans are performed on a schedule or on-demand. -Probus is a network scanner that identifies security vulnerabilities in your network and alerts you to new ones as they arise. Probus scans your network quickly using a combination of Nmap and a 2-pass scanning technique to identify hosts and open ports. +[Introduction](#bulb-introduction) _ [Key Features](#dart-key-features) _ [Quickstart](#zap-quickstart) _ [Development](#dizzy-development) _ [Contributing](#+1-contributing) \* [Contact](#incoming_envelope-contact) -Probus is platform-agnostic and available as a Docker container. +
-### Features: +## :dart: Key Features: - **Network Scanner:** Asynchronously scans your network for hosts and open ports. - **Scheduled Scans:** Scans your network on a schedule. @@ -35,30 +23,42 @@ Probus is platform-agnostic and available as a Docker container. - **Alerting:** Alerts you to new vulnerabilities as they arise, new devices added to your network, given a network range. - **Platform agnostic**: Avilable as a docker container. -## Installation +## :zap: Quickstart + +In order to run the commands described below, you need: + +- [Docker](https://www.docker.com/) +- [Docker Compose](https://docs.docker.com/compose/) + +### Running + +1. Linux Installs: Run `docker compose up` to start the application. +2. Mac and Windows Installs: Run `NETWORK_MODE=bridge docker compose up` to start the application. -Download the Docker from: TODO +UI: [http://localhost:8080](http://localhost:8080) -UI is accessible from: [http://localhost:8080](http://localhost:8080). +API: [http://localhost:8000/docs](http://localhost:8000/docs) -Swagger API is accessible from: [http://localhost:8000/docs](http://localhost:8000/docs). +> **Note:** The `NETWORK_MODE=bridge` environment variable is required for Mac and Windows. This is because the default network mode for Docker Compose is `host`, which is not supported on Mac and Windows and Probus requires access to the host network to scan the network. -### Local Installation from Sources +Alternatively, you can create a `.env` file in the root of the project with the following content: -Clone the repository. Then, run `docker compose up --build`. +```bash +NETWORK_MODE=bridge +``` -## Development +## :dizzy: Development -Please read the [DEVELOPMENT.md](DEVELOPMENT.md) file for more information on how to run this project locally. +Please read the [DEVELOPMENT.md](DEVELOPMENT.md) file for more information on how to run this project locally and contribute. -## Contributing +## :+1: Contributing Please read the [CONTRIBUTING.md](CONTRIBUTING.md) file for more information on how to contribute to this project. -## Contact +## :incoming_envelope: Contact - Use **GitHub Issues** for code-related issues. -## License +## :file_cabinet: License Probus is licensed under the [Apache License 2.0](LICENSE). diff --git a/backend/api/default.py b/backend/api/default.py index 61c5bb8..57d1e12 100644 --- a/backend/api/default.py +++ b/backend/api/default.py @@ -3,6 +3,6 @@ router = APIRouter() -@router.get("/", tags=["default"]) -def read_root(): - return {"Probus says": "Hello World"} +# @router.get("/", tags=["default"]) +# def read_root(): +# return {"Probus says": "Hello World"} diff --git a/backend/main.py b/backend/main.py index 54d4973..8626e53 100644 --- a/backend/main.py +++ b/backend/main.py @@ -45,7 +45,6 @@ def probus_openapi_schema(): app.include_router(info.router) app.include_router(default.router) - app.openapi = probus_openapi_schema # TODO: We should disable this and reverse proxy through the UI's dev server. @@ -58,6 +57,19 @@ def probus_openapi_schema(): allow_headers=["*"], ) + +### BEGIN: attempt to serve the frontend via FastAPI so we only have one Docker container +# Fails on serving non-cached assets? Fails on refreshing the page +# class SPAStaticFiles(StaticFiles): +# async def get_response(self, path: str, scope): +# response = await super().get_response(path, scope) +# if response.status_code == 404: +# response = await super().get_response(".", scope) +# return response +# app.mount("/", SPAStaticFiles(directory="frontend/dist", html=True), name="frontend") +## END + + if __name__ == "__main__": """ If using VSCode, you can run this script in the included FastAPI debug configuration diff --git a/docker-compose.yml b/docker-compose.yml index fb9913c..52357f6 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -2,15 +2,15 @@ services: backend: build: context: . - dockerfile: docker/Dockerfile-backend + dockerfile: docker/backend.Dockerfile ports: - "8000:8000" privileged: true - #user: root - #network_mode: bridge #TODO: make configurable for linux to use host mode. + user: root + network_mode: ${NETWORK_MODE:-host} frontend: build: context: . - dockerfile: docker/Dockerfile-frontend + dockerfile: docker/frontend.Dockerfile ports: - "8080:8080" diff --git a/docker/Dockerfile-backend b/docker/backend.Dockerfile similarity index 100% rename from docker/Dockerfile-backend rename to docker/backend.Dockerfile diff --git a/docker/Dockerfile-frontend b/docker/frontend.Dockerfile similarity index 100% rename from docker/Dockerfile-frontend rename to docker/frontend.Dockerfile diff --git a/frontend/src/App.tsx b/frontend/src/App.tsx index 39a75e2..90b81ab 100644 --- a/frontend/src/App.tsx +++ b/frontend/src/App.tsx @@ -12,7 +12,7 @@ const App = () => { } /> } /> - } /> + } /> diff --git a/frontend/src/components/header.tsx b/frontend/src/components/header.tsx index 140c948..7a2ee7b 100644 --- a/frontend/src/components/header.tsx +++ b/frontend/src/components/header.tsx @@ -25,7 +25,7 @@ const Header = () => { >