├── README.md
├── vulnerability-backend
├── Procfile
├── Procfile.windows
├── main.py
├── model.py
├── requirements.txt
├── runtime.txt
├── user.py
└── vulnerability.py
└── vulnerability-frontend
├── .gitattributes
├── .gitignore
├── README.md
├── package-lock.json
├── package.json
├── public
├── _redirects
│ ├── favicon.ico
│ ├── index.html
│ ├── logo192.png
│ ├── logo512.png
│ ├── manifest.json
│ └── robots.txt
├── favicon.ico
├── index.html
├── logo192.png
├── logo512.png
├── manifest.json
├── netlify.toml
└── robots.txt
└── src
├── App.css
├── App.js
├── auth
├── auth.js
├── login.js
├── protected-route.js
└── register.js
├── images
└── logo.svg
├── index.css
├── index.js
└── pages
├── Home.js
├── Login.js
├── Signup.js
└── editForm.js
/README.md:
--------------------------------------------------------------------------------
1 | # Vulnerability
2 |
3 |
4 |
5 | ## Getting started
6 |
7 | To make it easy for you to get started with GitLab, here's a list of recommended next steps.
8 |
9 | Already a pro? Just edit this README.md and make it your own. Want to make it easy? [Use the template at the bottom](#editing-this-readme)!
10 |
11 | ## Add your files
12 |
13 | - [ ] [Create](https://docs.gitlab.com/ee/user/project/repository/web_editor.html#create-a-file) or [upload](https://docs.gitlab.com/ee/user/project/repository/web_editor.html#upload-a-file) files
14 | - [ ] [Add files using the command line](https://docs.gitlab.com/ee/gitlab-basics/add-file.html#add-a-file-using-the-command-line) or push an existing Git repository with the following command:
15 |
16 | ```
17 | cd existing_repo
18 | git remote add origin https://gitlab.com/ITopGun/vulnerability.git
19 | git branch -M main
20 | git push -uf origin main
21 | ```
22 |
23 | ## Integrate with your tools
24 |
25 | - [ ] [Set up project integrations](https://gitlab.com/ITopGun/vulnerability/-/settings/integrations)
26 |
27 | ## Collaborate with your team
28 |
29 | - [ ] [Invite team members and collaborators](https://docs.gitlab.com/ee/user/project/members/)
30 | - [ ] [Create a new merge request](https://docs.gitlab.com/ee/user/project/merge_requests/creating_merge_requests.html)
31 | - [ ] [Automatically close issues from merge requests](https://docs.gitlab.com/ee/user/project/issues/managing_issues.html#closing-issues-automatically)
32 | - [ ] [Enable merge request approvals](https://docs.gitlab.com/ee/user/project/merge_requests/approvals/)
33 | - [ ] [Automatically merge when pipeline succeeds](https://docs.gitlab.com/ee/user/project/merge_requests/merge_when_pipeline_succeeds.html)
34 |
35 | ## Test and Deploy
36 |
37 | Use the built-in continuous integration in GitLab.
38 |
39 | - [ ] [Get started with GitLab CI/CD](https://docs.gitlab.com/ee/ci/quick_start/index.html)
40 | - [ ] [Analyze your code for known vulnerabilities with Static Application Security Testing(SAST)](https://docs.gitlab.com/ee/user/application_security/sast/)
41 | - [ ] [Deploy to Kubernetes, Amazon EC2, or Amazon ECS using Auto Deploy](https://docs.gitlab.com/ee/topics/autodevops/requirements.html)
42 | - [ ] [Use pull-based deployments for improved Kubernetes management](https://docs.gitlab.com/ee/user/clusters/agent/)
43 | - [ ] [Set up protected environments](https://docs.gitlab.com/ee/ci/environments/protected_environments.html)
44 |
45 | ***
46 |
47 | # Editing this README
48 |
49 | When you're ready to make this README your own, just edit this file and use the handy template below (or feel free to structure it however you want - this is just a starting point!). Thank you to [makeareadme.com](https://www.makeareadme.com/) for this template.
50 |
51 | ## Suggestions for a good README
52 | Every project is different, so consider which of these sections apply to yours. The sections used in the template are suggestions for most open source projects. Also keep in mind that while a README can be too long and detailed, too long is better than too short. If you think your README is too long, consider utilizing another form of documentation rather than cutting out information.
53 |
54 | ## Name
55 | Choose a self-explaining name for your project.
56 |
57 | ## Description
58 | Let people know what your project can do specifically. Provide context and add a link to any reference visitors might be unfamiliar with. A list of Features or a Background subsection can also be added here. If there are alternatives to your project, this is a good place to list differentiating factors.
59 |
60 | ## Badges
61 | On some READMEs, you may see small images that convey metadata, such as whether or not all the tests are passing for the project. You can use Shields to add some to your README. Many services also have instructions for adding a badge.
62 |
63 | ## Visuals
64 | Depending on what you are making, it can be a good idea to include screenshots or even a video (you'll frequently see GIFs rather than actual videos). Tools like ttygif can help, but check out Asciinema for a more sophisticated method.
65 |
66 | ## Installation
67 | Within a particular ecosystem, there may be a common way of installing things, such as using Yarn, NuGet, or Homebrew. However, consider the possibility that whoever is reading your README is a novice and would like more guidance. Listing specific steps helps remove ambiguity and gets people to using your project as quickly as possible. If it only runs in a specific context like a particular programming language version or operating system or has dependencies that have to be installed manually, also add a Requirements subsection.
68 |
69 | ## Usage
70 | Use examples liberally, and show the expected output if you can. It's helpful to have inline the smallest example of usage that you can demonstrate, while providing links to more sophisticated examples if they are too long to reasonably include in the README.
71 |
72 | ## Support
73 | Tell people where they can go to for help. It can be any combination of an issue tracker, a chat room, an email address, etc.
74 |
75 | ## Roadmap
76 | If you have ideas for releases in the future, it is a good idea to list them in the README.
77 |
78 | ## Contributing
79 | State if you are open to contributions and what your requirements are for accepting them.
80 |
81 | For people who want to make changes to your project, it's helpful to have some documentation on how to get started. Perhaps there is a script that they should run or some environment variables that they need to set. Make these steps explicit. These instructions could also be useful to your future self.
82 |
83 | You can also document commands to lint the code or run tests. These steps help to ensure high code quality and reduce the likelihood that the changes inadvertently break something. Having instructions for running tests is especially helpful if it requires external setup, such as starting a Selenium server for testing in a browser.
84 |
85 | ## Authors and acknowledgment
86 | Show your appreciation to those who have contributed to the project.
87 |
88 | ## License
89 | For open source projects, say how it is licensed.
90 |
91 | ## Project status
92 | If you have run out of energy or time for your project, put a note at the top of the README saying that development has slowed down or stopped completely. Someone may choose to fork your project or volunteer to step in as a maintainer or owner, allowing your project to keep going. You can also make an explicit request for maintainers.
93 |
--------------------------------------------------------------------------------
/vulnerability-backend/Procfile:
--------------------------------------------------------------------------------
1 | web: gunicorn -w 4 -k uvicorn.workers.UvicornWorker main:app
--------------------------------------------------------------------------------
/vulnerability-backend/Procfile.windows:
--------------------------------------------------------------------------------
1 | web: uvicorn main:app --reload
--------------------------------------------------------------------------------
/vulnerability-backend/main.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python3
2 | # -*- coding: utf-8 -*-
3 |
4 | from fastapi.middleware.cors import CORSMiddleware
5 | from fastapi import FastAPI, Request, Depends, HTTPException
6 | from user import User, UserCreate, UserUpdate, UserDB, auth_backends, fastapi_users
7 | from vulnerability import (
8 | create_vulnerability,
9 | fetch_all_vulnerabilities,
10 | update_vulnerability,
11 | fetch_one_vulnerability,
12 | remove_vulnerability,
13 | )
14 | from model import VulnerabilityOutput, VulnerabilityInput
15 |
16 | # Initiating FastAPI Server
17 | app = FastAPI()
18 |
19 | # Managing CORS for the React Frontend connections
20 | origins = ["*"]
21 |
22 | app.add_middleware(
23 | CORSMiddleware,
24 | allow_origins=origins,
25 | allow_credentials=True,
26 | allow_methods=["*"],
27 | allow_headers=["*"]
28 | )
29 |
30 |
31 | # --- User Authentication Routes ----------------------------------------------
32 |
33 | # Learn more at https://frankie567.github.io/fastapi-users/configuration/routers/
34 |
35 | # Add route for Login POST "/auth/login", "/auth/register"
36 | app.include_router(
37 | fastapi_users.get_auth_router(auth_backends[0]),
38 | prefix="/auth",
39 | tags=["auth"]
40 | )
41 |
42 |
43 | def on_after_register(user: UserDB, request: Request):
44 | print("User {user.id} has registered.")
45 |
46 |
47 | app.include_router(
48 | # fastapi_users.get_register_router(),
49 | fastapi_users.get_register_router(on_after_register),
50 | prefix="/auth",
51 | tags=["auth"]
52 | )
53 |
54 | # Add route for User utilities "/auth/users/*"
55 |
56 | """
57 | Get current logged in user profile GET "/auth/users/me"
58 | Update current logged in user profile PATCH "/auth/users/me"
59 | Get "_id" user profile GET "/auth/users/"
60 | Update "_id" user profile PATCH "/auth/users/{id}"
61 | Delete "_id" user profile DELETE "/auth/users/{id}"
62 | """
63 |
64 | app.include_router(
65 | fastapi_users.get_users_router(),
66 | prefix="/auth/users",
67 | tags=["auth"]
68 | )
69 |
70 | # Add route for Reset Password utility
71 |
72 | """
73 | Forgot Password POST /auth/users/forgot-password
74 | Reset Password POST /auth/users/reset-password
75 | """
76 |
77 | app.include_router(
78 | fastapi_users.get_reset_password_router("SECRET"),
79 | prefix="/auth/users",
80 | tags=["auth"]
81 | )
82 |
83 | # ----------------- Vulnerability CRUD urls --------------------------------
84 |
85 |
86 | @app.get("/api/vulnerability", tags=["vulnerability solution crud"])
87 | async def get_vulnerability(user: User = Depends(fastapi_users.get_current_user)):
88 | response = await fetch_all_vulnerabilities()
89 | return response
90 |
91 |
92 | @app.post("/api/vulnerability/", response_model=VulnerabilityOutput, tags=["vulnerability solution crud"])
93 | async def post_vulnerability(vulnerability: VulnerabilityInput, user: User = Depends(fastapi_users.get_current_user)):
94 | response = await create_vulnerability(vulnerability.dict())
95 | if not user.is_superuser:
96 | HTTPException(400, "You are not admin.")
97 | if response:
98 | return response
99 | raise HTTPException(400, "Something went wrong")
100 |
101 |
102 | @app.put("/api/vulnerability/{id}/", response_model=VulnerabilityOutput, tags=["vulnerability solution crud"])
103 | async def put_vulnerability(id: str, body: VulnerabilityInput, user: User = Depends(fastapi_users.get_current_user)):
104 | response = await update_vulnerability(id, body)
105 | if not user.is_superuser:
106 | HTTPException(400, "You are not admin.")
107 | if response:
108 | return response
109 | raise HTTPException(
110 | 404, f"There is no vulnerability with the id {id}")
111 |
112 |
113 | @app.get("/api/vulnerability/{id}", response_model=VulnerabilityOutput, tags=["vulnerability solution crud"])
114 | async def get_vulnerability_by_id(id, user: User = Depends(fastapi_users.get_current_user)):
115 | response = await fetch_one_vulnerability(id)
116 | if response:
117 | return response
118 | raise HTTPException(
119 | 404, f"There is no vulnerability with the id {id}")
120 |
121 |
122 | @app.delete("/api/vulnerability/{id}", tags=["vulnerability solution crud"])
123 | async def delete_vulnerability(id, user: User = Depends(fastapi_users.get_current_user)):
124 | response = await remove_vulnerability(id)
125 | if not user.is_superuser:
126 | HTTPException(400, "You are not admin.")
127 | if response:
128 | return {"result": True, "msg": "Successfully deleted vulnerability", "_id": id}
129 | raise HTTPException(
130 | 404, f"There is no vulnerability with the id {id}")
131 |
--------------------------------------------------------------------------------
/vulnerability-backend/model.py:
--------------------------------------------------------------------------------
1 | from pydantic import BaseModel, Field
2 | from typing import Dict, Optional
3 | from bson import ObjectId
4 |
5 |
6 | class PyObjectId(ObjectId):
7 |
8 | @classmethod
9 | def __get_validators__(cls):
10 | yield cls.validate
11 |
12 | @classmethod
13 | def validate(cls, v):
14 | if not ObjectId.is_valid(v):
15 | raise ValueError('Invalid objectid')
16 | return ObjectId(v)
17 |
18 | @classmethod
19 | def __modify_schema__(cls, field_schema):
20 | field_schema.update(type='string')
21 |
22 |
23 | class VulnerabilityInput(BaseModel):
24 | type: str
25 | cve: str
26 | name: str
27 | solution: str
28 |
29 |
30 | class VulnerabilityOutput(BaseModel):
31 | id: Optional[PyObjectId] = Field(alias='_id')
32 | type: str
33 | cve: str
34 | name: str
35 | solution: str
36 |
37 | class Config:
38 | arbitrary_types_allowed = True
39 | json_encoders = {
40 | ObjectId: str
41 | }
42 |
--------------------------------------------------------------------------------
/vulnerability-backend/requirements.txt:
--------------------------------------------------------------------------------
1 | fastapi==0.61.1
2 | fastapi-users==3.0.5
3 | uvicorn==0.11.8
4 | motor==2.2.0
5 | gunicorn
6 |
--------------------------------------------------------------------------------
/vulnerability-backend/runtime.txt:
--------------------------------------------------------------------------------
1 | python-3.8.13
--------------------------------------------------------------------------------
/vulnerability-backend/user.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python3
2 | # -*- coding: utf-8 -*-
3 |
4 | import motor.motor_asyncio
5 | from fastapi_users import FastAPIUsers, models
6 | from fastapi_users.db import MongoDBUserDatabase
7 | from fastapi_users.authentication import JWTAuthentication
8 |
9 | # --- MongoDB Setup -----------------------------------------------------------
10 |
11 | # MongoDB Configurations
12 | DATABASE_URL = "mongodb://localhost:27017"
13 | client = motor.motor_asyncio.AsyncIOMotorClient(
14 | DATABASE_URL, uuidRepresentation="standard"
15 | )
16 | database = client["vulnerability_db"]
17 |
18 | # MongoDB users collection instance ("users" by default, can be changed)
19 | collection = database["users"]
20 |
21 |
22 | # --- Users Collection Schema Setup -------------------------------------------
23 |
24 | # Pydantic models for MongoDB "User" collection schema
25 | # Learn more at https://frankie567.github.io/fastapi-users/configuration/model/
26 |
27 | class User(models.BaseUser):
28 | firstName: str
29 | lastName: str
30 |
31 |
32 | class UserCreate(models.BaseUserCreate):
33 | firstName: str
34 | lastName: str
35 |
36 |
37 | class UserUpdate(User, models.BaseUserUpdate):
38 | pass
39 |
40 |
41 | class UserDB(User, models.BaseUserDB):
42 | pass
43 |
44 | # --- Authentication Method Setup ---------------------------------------------
45 |
46 |
47 | # Secret Key (must be changed from "SECRET")
48 | SECRET = "SECRET"
49 |
50 | # Authentication Method JWT
51 | auth_backends = []
52 | authentication = JWTAuthentication(secret=SECRET, lifetime_seconds=3600)
53 | auth_backends.append(authentication)
54 |
55 |
56 | # --- FastAPIUsers Object Declaration -----------------------------------------
57 |
58 | # MongoDB "users" collection adaptor for API calls
59 | user_db = MongoDBUserDatabase(UserDB, collection)
60 |
61 | # FastAPI Users helper class with all the configurations from above
62 | # It provides us all the routes
63 | fastapi_users = FastAPIUsers(
64 | user_db,
65 | auth_backends,
66 | User,
67 | UserCreate,
68 | UserUpdate,
69 | UserDB
70 | )
71 |
--------------------------------------------------------------------------------
/vulnerability-backend/vulnerability.py:
--------------------------------------------------------------------------------
1 | import motor.motor_asyncio
2 | from model import VulnerabilityOutput
3 | from bson import ObjectId
4 |
5 |
6 | DATABASE_URL = "mongodb://localhost:27017"
7 | client = motor.motor_asyncio.AsyncIOMotorClient(
8 | DATABASE_URL, uuidRepresentation="standard"
9 | )
10 |
11 | db = client['vulnerability_db']
12 | vulnerability_tb = db['vulnerability']
13 |
14 |
15 | async def fetch_all_vulnerabilities():
16 | vulnerabilities = []
17 | cursor = vulnerability_tb.find({})
18 | async for document in cursor:
19 | vulnerabilities.append(VulnerabilityOutput(**document))
20 |
21 | print(vulnerabilities)
22 | return vulnerabilities
23 |
24 |
25 | async def create_vulnerability(vulnerability):
26 | document = vulnerability
27 | result = await vulnerability_tb.insert_one(document)
28 | return document
29 |
30 |
31 | async def update_vulnerability(id, body):
32 | print(body, body.cve)
33 | await vulnerability_tb.update_one({"_id": ObjectId(id)}, {"$set": {
34 | "type": body.type, "cve": body.cve, "name": body.name, "solution": body.solution}})
35 | document = await vulnerability_tb.find_one({"_id": ObjectId(id)})
36 | return document
37 |
38 |
39 | async def fetch_one_vulnerability(id):
40 | document = await vulnerability_tb.find_one({"_id": ObjectId(id)})
41 | return document
42 |
43 |
44 | async def remove_vulnerability(id):
45 | await vulnerability_tb.delete_one({"_id": ObjectId(id)})
46 | return True
47 |
--------------------------------------------------------------------------------
/vulnerability-frontend/.gitattributes:
--------------------------------------------------------------------------------
1 | # Auto detect text files and perform LF normalization
2 | * text=auto
3 |
--------------------------------------------------------------------------------
/vulnerability-frontend/.gitignore:
--------------------------------------------------------------------------------
1 | node_modules/
2 | build/
--------------------------------------------------------------------------------
/vulnerability-frontend/README.md:
--------------------------------------------------------------------------------
1 | This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app).
2 |
3 | ## Available Scripts
4 |
5 | In the project directory, you can run:
6 |
7 | ### `npm start`
8 |
9 | Runs the app in the development mode.
10 | Open [http://localhost:3000](http://localhost:3000) to view it in the browser.
11 |
12 | The page will reload if you make edits.
13 | You will also see any lint errors in the console.
14 |
15 | ### `npm test`
16 |
17 | Launches the test runner in the interactive watch mode.
18 | See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information.
19 |
20 | ### `npm run build`
21 |
22 | Builds the app for production to the `build` folder.
23 | It correctly bundles React in production mode and optimizes the build for the best performance.
24 |
25 | The build is minified and the filenames include the hashes.
26 | Your app is ready to be deployed!
27 |
28 | See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information.
29 |
30 | ### `npm run eject`
31 |
32 | **Note: this is a one-way operation. Once you `eject`, you can’t go back!**
33 |
34 | If you aren’t satisfied with the build tool and configuration choices, you can `eject` at any time. This command will remove the single build dependency from your project.
35 |
36 | Instead, it will copy all the configuration files and the transitive dependencies (webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except `eject` will still work, but they will point to the copied scripts so you can tweak them. At this point you’re on your own.
37 |
38 | You don’t have to ever use `eject`. The curated feature set is suitable for small and middle deployments, and you shouldn’t feel obligated to use this feature. However we understand that this tool wouldn’t be useful if you couldn’t customize it when you are ready for it.
39 |
40 | ## Learn More
41 |
42 | You can learn more in the [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started).
43 |
44 | To learn React, check out the [React documentation](https://reactjs.org/).
45 |
46 | ### Code Splitting
47 |
48 | This section has moved here: https://facebook.github.io/create-react-app/docs/code-splitting
49 |
50 | ### Analyzing the Bundle Size
51 |
52 | This section has moved here: https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size
53 |
54 | ### Making a Progressive Web App
55 |
56 | This section has moved here: https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app
57 |
58 | ### Advanced Configuration
59 |
60 | This section has moved here: https://facebook.github.io/create-react-app/docs/advanced-configuration
61 |
62 | ### Deployment
63 |
64 | This section has moved here: https://facebook.github.io/create-react-app/docs/deployment
65 |
66 | ### `npm run build` fails to minify
67 |
68 | This section has moved here: https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify
69 |
--------------------------------------------------------------------------------
/vulnerability-frontend/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "frontend",
3 | "version": "0.1.0",
4 | "private": true,
5 | "dependencies": {
6 | "@progress/kendo-data-query": "^1.5.6",
7 | "@progress/kendo-drawing": "^1.16.3",
8 | "@progress/kendo-licensing": "^1.2.2",
9 | "@progress/kendo-react-animation": "^5.3.0",
10 | "@progress/kendo-react-buttons": "^5.3.0",
11 | "@progress/kendo-react-data-tools": "^5.3.0",
12 | "@progress/kendo-react-dateinputs": "^5.3.0",
13 | "@progress/kendo-react-dialogs": "^5.3.0",
14 | "@progress/kendo-react-dropdowns": "^5.3.0",
15 | "@progress/kendo-react-excel-export": "^5.3.0",
16 | "@progress/kendo-react-form": "^5.3.0",
17 | "@progress/kendo-react-grid": "^5.3.0",
18 | "@progress/kendo-react-inputs": "^5.3.0",
19 | "@progress/kendo-react-intl": "^5.3.0",
20 | "@progress/kendo-react-notification": "^5.3.0",
21 | "@progress/kendo-react-pdf": "^5.3.0",
22 | "@progress/kendo-react-treeview": "^5.3.0",
23 | "@progress/kendo-theme-default": "^5.3.0",
24 | "@testing-library/jest-dom": "^5.16.4",
25 | "@testing-library/react": "^9.5.0",
26 | "@testing-library/user-event": "^7.2.1",
27 | "bootstrap": "^5.1.3",
28 | "jwt-decode": "^2.2.0",
29 | "react": "^16.14.0",
30 | "react-bootstrap": "^2.3.1",
31 | "react-csv": "^2.2.2",
32 | "react-dom": "^16.14.0",
33 | "react-icons": "^3.11.0",
34 | "react-router-dom": "^5.3.1",
35 | "react-scripts": "^4.0.1"
36 | },
37 | "overrides": {
38 | "autoprefixer": "10.4.5"
39 | },
40 | "resolutions": {
41 | "autoprefixer": "10.4.5"
42 | },
43 | "scripts": {
44 | "start": "react-scripts start",
45 | "build": "react-scripts build",
46 | "test": "react-scripts test",
47 | "eject": "react-scripts eject"
48 | },
49 | "browserslist": {
50 | "production": [
51 | ">0.2%",
52 | "not dead",
53 | "not op_mini all"
54 | ],
55 | "development": [
56 | "last 1 chrome version",
57 | "last 1 firefox version",
58 | "last 1 safari version"
59 | ]
60 | }
61 | }
62 |
--------------------------------------------------------------------------------
/vulnerability-frontend/public/_redirects/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ITopGun/Vulnerability-Hub/f8fc5d8eab264b52433b51d8492793132932c06b/vulnerability-frontend/public/_redirects/favicon.ico
--------------------------------------------------------------------------------
/vulnerability-frontend/public/_redirects/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |