CyberFortress-Backend is a robust Node.js-based backend service for the CyberFortress API security dashboard. It provides API endpoints to fetch security reports and manages data storage using MongoDB.
- 🚀 Fast and efficient Node.js server
- 📊 RESTful API for fetching security reports
- 🗄️ MongoDB integration for data persistence
- 🔐 Secure API endpoints
- 🔄 Easy-to-use data retrieval system
- 🔄 Jenkins pipeline for CI/CD
- Node.js (v14.0.0 or later)
- npm (v6.0.0 or later)
- MongoDB (v4.0 or later)
-
Clone the repository:
git clone https://github.com/Captain-T2004/CyberFortress-Backend.git
-
Navigate to the project directory:
cd CyberFortress-Backend
-
Install dependencies:
npm install
-
Set up environment variables:
- Create a
.env
file in the root directory - Add necessary environment variables (e.g., MongoDB connection string, port)
- Create a
-
Start the server:
npm start
Update the .env
file with your specific configuration:
PORT=3000
MONGODB_URI=mongodb://localhost:27017/cyberfortress
// Add other necessary environment variables
Fetches the API security report from the MongoDB database.
Response:
{
"apis": [
{
"id": "1",
"name": "User Authentication API",
"securityHealth": "Good",
"vulnerabilities": []
},
{
"id": "2",
"name": "Payment Processing API",
"securityHealth": "At Risk",
"vulnerabilities": [
{
"type": "SQL Injection",
"severity": "High",
"description": "Potential SQL injection vulnerability in query parameter"
}
]
}
]
}
- Ensure your MongoDB instance is running and accessible
- Set up environment variables for production
- Build the project (if necessary):
npm run build
- Start the server:
npm start
The project includes a Jenkinsfile in the codebase to easily set up a CI/CD pipeline using Jenkins. This pipeline automates the build, test, and deployment processes.
- Jenkins server installed and running
-
In Jenkins, create a new Pipeline job.
-
In the job configuration, under "Pipeline", select "Pipeline script from SCM".
-
Choose your SCM (e.g., Git) and provide the repository URL.
-
Specify the path to the Jenkinsfile (usually just
Jenkinsfile
if it's in the root of your repository). -
Save the job configuration.
The Jenkinsfile defines the following stages:
- Checkout: Clones the repository
- Install Dependencies: Runs
npm install
- Run Tests: Executes the test suite with
npm test
- Build: Builds the project (if necessary)
To run the pipeline:
- Go to the Jenkins job you created.
- Click "Build Now".
Jenkins will execute each stage defined in the Jenkinsfile, providing feedback on the progress and results of each stage.