This project analyzes vulnerabilities identified by their CVE id. It tries to find out how a vulnerability can be exploited. The web application can be accessed at https://torstenwerner.github.io/vulnerability-analysis/. The prompt can optionally be specified as a parameter e.g.: https://torstenwerner.github.io/vulnerability-analysis/?prompt=CVE-2021-44228.
The following technologies are used in the project.
- The OpenAI API with the websearch tool.
- Node to implement the AI service.
- An AWS lambda function to run the AI service without a permanently running server.
- The AWS gateway provides a secure REST API accessible from the internet.
- Svelte and Vite to implement a web UI.
- GitHub actions to build the web application and deploy it to GitHub pages.
- GitHub pages to deliver the web application to the user.
- The file
server.jsimplements a REST service using node to implement most of the business requirements. - The file
ai-chat.jsimplements the functionaskAiwhich is chatting with the AI. - The file
lambda/lambda.jsimplements an AWS Lambda function that provides the same functionality as the REST service. - The file
lambda/update-lambda.jsupdates the lambda function in AWS. - The file
client-slim.jstests the REST service or the lambda function. - The file
client-fat.jstests the business logic directly without usingserver.js. - The directory
webappimplements a Svelte based web application that can be deployed to any web server. It is currently deployed to GitHub pages.
The Lambda function code and configuration is located in the lambda directory.
To deploy the Lambda function:
-
Navigate to the lambda directory:
cd lambda -
Build and package the Lambda function:
npm run package
-
Deploy to AWS Lambda:
npm run update
Alternatively, you can manually deploy:
- Create a new Lambda function in the AWS Console
- Select "Author from scratch"
- Runtime: Node.js 20.x
- Architecture: x86_64 or arm64
- Upload the generated
function.zip - Set the handler to "lambda.handler"
- Configure environment variables:
- OPENAI_API_KEY: Your OpenAI API key
- Configure API Gateway:
- Create a new REST API
- Create a POST method for the /cve-analysis endpoint
- Integrate with your Lambda function
- Deploy the API
The Lambda function will now be accessible through the API Gateway endpoint.
- improved UI
- https://upstash.com/ for caching responses to reduce AI costs (Redis)
- or https://supabase.com/database (PostgreSQL)
- Use https://brave.com/search/api/ for a less expensive web search.
- improved AI developer prompt
- fetch data from the NVD API and include it in the AI developer prompt
- Allow uploading a JSON report from the OWASP Dependency-Check and render a select menu for all included CVE ids. Parse the JSON in the browser for data protection reasons.
- Render a full AI report for the uploaded OWASP JSON report adding AI answers to the NVD data for each CVE.
- Allow uploading two JSON OWASP reports from different generation dates and render an AI report that visualizes all new and fixed vulnerabilities.
- Add more research areas beyond vulnerability analysis.