-
Notifications
You must be signed in to change notification settings - Fork 2
Build Reachability Frontend #72
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
juliankepka
merged 8 commits into
vulnerability-database
from
build-reachability-analysis-frontend
Feb 26, 2026
Merged
Changes from 2 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
ecb21e7
first prototype for minimum requirements
Hubtrick-Git 7add69d
built a prototype table to display results
Hubtrick-Git ee7431b
adjusted structure and design ti match other frontend designs
Hubtrick-Git 00e71fc
first working version for reachability main page with data fetching, …
Hubtrick-Git 68bd768
saving before checkout
Hubtrick-Git 3b0dd39
functional version of frontend, visuals will be finalized when gettin…
Hubtrick-Git c3ca7d8
Update .gitignore to include .env and Sentry files
Hubtrick-Git 0672ffd
implemented code review changes
Hubtrick-Git File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 |
|---|---|---|
|
|
@@ -18,6 +18,7 @@ | |
| # misc | ||
| .DS_Store | ||
| *.pem | ||
| .vscode/* | ||
|
|
||
| # debug | ||
| npm-debug.log* | ||
|
|
||
80 changes: 80 additions & 0 deletions
80
src/components/reachabilityAnalysis/reachability-analysis.tsx
This file contains hidden or 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,80 @@ | ||
| import React, { FormEventHandler, useState } from "react" | ||
| import { ReachabilityAnalysisResponse} from "./reachability-types" | ||
| import AnalysisResultsTable from "./renderData" | ||
|
|
||
| const apiBaseURL = 'http://localhost:8080/api/v1/' | ||
|
|
||
| export function ReachabilityAnalysisHero() { | ||
| return ( | ||
| <div className="bg-[#0D1017] pt-24"> | ||
|
Hubtrick-Git marked this conversation as resolved.
Outdated
|
||
| <div className="mx-auto text-center max-w-4xl px-6 max-lg:text-center lg:max-w-7xl"> | ||
| <h1 className="text-balance text-5xl font-semibold tracking-tight text-white sm:text-6xl lg:text-pretty"> | ||
| Reachability Analysis | ||
| </h1> | ||
| <p className="mx-auto mt-6 max-w-2xl text-pretty text-lg font-medium text-gray-400 max-lg:mx-auto sm:text-xl/8"> | ||
| This page enables you to search for a npm package and get a list of all CVEs associated with it. | ||
| Additionally you get information about whether the CVE is actually affecting this package or not. | ||
| </p> | ||
| </div> | ||
| <br/> <br/> | ||
| <br/> | ||
| </div> | ||
| ) | ||
| } | ||
|
|
||
| export const apiCall = ( baseURL: string,params: string,init?: RequestInit) => { | ||
| return fetch(baseURL + params,init) | ||
| } | ||
|
|
||
| export function ReachabilityAnalysisSearchBar() { | ||
| const [input,setInput] = useState("") | ||
| const [data, setData] = useState<ReachabilityAnalysisResponse>(); | ||
| const [isLoading, setIsLoading] = useState<boolean>(false); | ||
| const [error, setError] = useState<boolean>(false); | ||
|
Hubtrick-Git marked this conversation as resolved.
Outdated
|
||
|
|
||
| const getData = async () => { | ||
| setIsLoading(true) | ||
| try{ | ||
| const response = await fetch(apiBaseURL+input) | ||
| const data = await response.json() | ||
| setIsLoading(false) | ||
|
|
||
| if (!data || !response.ok) { | ||
| window.alert("error when trying to fetch data from api endpoint") | ||
| } | ||
| setData(data) | ||
| }catch{ | ||
| setError(true) | ||
| }finally{ | ||
| setIsLoading(false) | ||
| } | ||
| } | ||
|
|
||
| const onSubmit: FormEventHandler<HTMLFormElement> = (e) => { | ||
| e.preventDefault() | ||
| getData() | ||
| } | ||
|
|
||
|
|
||
| return ( | ||
| <div className="block pt-20 pb-20 bg-[#0D1017]" > | ||
| <form onSubmit={onSubmit}> | ||
| <label htmlFor="name" className="ml-px block text-center pl-2 text-4xl font-semibold text-white content-center"> | ||
| Search Package | ||
| </label> | ||
| <div className="flex flex-row gap-4 mx-auto mt-4 w-1/2"> | ||
| <input | ||
|
Hubtrick-Git marked this conversation as resolved.
Outdated
|
||
| id="name" | ||
| name="package" | ||
| type="text" | ||
| placeholder="type away..." | ||
| onChange={(e) => {setInput(e.target.value)}} | ||
| className="text-center block w-1/3 mx-auto focus:w-full text-xl rounded-full bg-white/5 px-5 py-2 text-white outline outline-1 -outline-offset-1 outline-white/50 focus:outline-3 focus:outline-white/70 placeholder:text-gray-500 focus:placeholder:opacity-0 transition-all duration-300 ease-in-out" | ||
| /> | ||
| </div> | ||
| </form> | ||
| <AnalysisResultsTable loading={isLoading} error={error} data={data} /> | ||
| </div> | ||
| ) | ||
| } | ||
| /* <input type="submit" className="block bg-primary p-2 rounded-md text-black font-semibold hover:bg-accent hover:text-accent-foreground" /> */ | ||
63 changes: 63 additions & 0 deletions
63
src/components/reachabilityAnalysis/reachability-types.tsx
This file contains hidden or 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,63 @@ | ||
|
|
||
| export interface ReachabilityAnalysisResponse{ | ||
| bomFormat : string | ||
| specVersion : string | ||
| serialNumber : string | ||
| version : number | ||
| metadata : Metadata | ||
| components : Component[] | ||
| vulnerabilities : Vulnerability[] | ||
| } | ||
|
|
||
| interface Metadata{ | ||
| timestamp : string | ||
| tools : Tool[] | ||
| } | ||
|
|
||
| interface Tool{ | ||
| vendor : string | ||
| name : string | ||
| version : string | ||
| } | ||
|
|
||
| interface Component { | ||
| type : string | ||
| name : string | ||
| purl : string | ||
| "bom-ref" : string | ||
| } | ||
|
|
||
| interface Vulnerability{ | ||
| "bom-ref" : string | ||
| id : string | ||
| description : string | ||
| affects : Affect[] | ||
| analysis : Analysis | ||
| } | ||
|
|
||
| interface Affect{ | ||
| ref : string | ||
| } | ||
|
|
||
| interface Analysis { | ||
| state : string | ||
| detail : string | ||
| evidence : Evidence[] | ||
| } | ||
|
|
||
| interface Evidence { | ||
| path : PathElement[] | ||
| } | ||
|
|
||
|
|
||
| interface PathElement{ | ||
| id: number; | ||
| cve_id: string; | ||
| signature: string; | ||
| filename: string; | ||
| start_line: number; | ||
| end_line: number; | ||
| evidence: string; | ||
| purl: string; | ||
| calls_id: number | null; | ||
| } | ||
|
Hubtrick-Git marked this conversation as resolved.
|
||
This file contains hidden or 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,53 @@ | ||
| import React from "react"; | ||
| import { ReachabilityAnalysisResponse } from "./reachability-types"; | ||
| import { d } from "nextra/dist/types-BhjhW0gX"; | ||
|
|
||
| interface fetchResults{ | ||
| loading: boolean | ||
| error : boolean | ||
| data? : ReachabilityAnalysisResponse | ||
| } | ||
|
|
||
| interface tableEntry { | ||
| component : string | ||
| type : string | ||
| count : string | ||
| } | ||
|
|
||
| const AnalysisResultsTable: React.FC<fetchResults> = ({loading,error,data}) => { | ||
| if (loading && !error) { | ||
| return <div>Loading</div> | ||
| } | ||
| if (!loading && error){ | ||
| return <div>Error occurred</div> | ||
| } | ||
| if (!data){ | ||
| return <div>No data in response</div> | ||
| } | ||
|
|
||
| if (!loading && !error && data){ | ||
| return ( | ||
| <div className="flex flex-row justify-center items-center mt-20"> | ||
| <table className="divide-y text-center rounded-lg w-1/2"> | ||
| <thead className="text-3xl bg-gray-800/75 divide-gray-200"> | ||
| <tr> | ||
| <th className="py-3 px-10 font-semibold">Component</th> | ||
| <th className="py-3 px-10 font-semibold">Type</th> | ||
| </tr> | ||
| </thead> | ||
| <tbody className="divide-y text-xl bg-gray-800/50"> | ||
| {data.components.map((component, index) => ( | ||
| <tr key={index}> | ||
| <td className="py-3 px-5">{component.purl}</td> | ||
| <td className="py-3 px-5">{component.type}</td> | ||
| </tr> | ||
| ))} | ||
| </tbody> | ||
| </table> | ||
| </div> | ||
| ) | ||
| } | ||
| return <div>undefined behavior</div> | ||
| } | ||
|
|
||
| export default AnalysisResultsTable |
This file contains hidden or 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 contains hidden or 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,7 @@ | ||
| import { | ||
| ReachabilityAnalysisHero, | ||
| ReachabilityAnalysisSearchBar, | ||
| } from '../components/reachabilityAnalysis/reachability-analysis' | ||
|
|
||
| <ReachabilityAnalysisHero /> | ||
| <ReachabilityAnalysisSearchBar /> |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.