-
Notifications
You must be signed in to change notification settings - Fork 44
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
docs: add guide for enriching security vulnerabilities with AI #1905
Open
devin-ai-integration
wants to merge
5
commits into
main
Choose a base branch
from
devin/1735757339-add-ai-security-guide
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 2 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
72753b7
docs: add guide for enriching security vulnerabilities with AI
devin-ai-integration[bot] 2a80d9c
chore: format new guide with prettier
devin-ai-integration[bot] 5031fe4
docs: add CVE explanation and field requirements
devin-ai-integration[bot] c098455
docs: add AI technology and guide to navigation
devin-ai-integration[bot] 9d4a53e
docs: add example image showing AI summary feature
devin-ai-integration[bot] 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
163 changes: 163 additions & 0 deletions
163
docs/guides/all/enrich-security-vulnerabilities-with-ai.md
This file contains 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,163 @@ | ||
--- | ||
title: Enrich security vulnerabilities using AI | ||
--- | ||
|
||
# Enrich security vulnerabilities using AI | ||
|
||
This guide demonstrates how to leverage 3rd-party AI tools within Port to get additional details on security vulnerabilities and mitigation strategies. | ||
|
||
## Prerequisites | ||
|
||
- This guide assumes you have a Port account and that you have finished the [onboarding process](https://docs.getport.io/quickstart). | ||
- You will need at least one code security tool integrated. You can check our [integrations section](https://docs.getport.io/build-your-software-catalog/sync-data-to-catalog/code-quality-security/). | ||
- You will need access to the LLM API you wish to integrate (e.g., OpenAI ChatGPT). | ||
- You should have a security issue blueprint set up in your Port installation (such as the `snykVulnerability` blueprint). | ||
|
||
## The goal of this guide | ||
|
||
Code security tools provide context for issues in your code. This guide will show how to leverage AI to understand these issues better and how to fix them. | ||
After completing it, developers can resolve issues faster and more independently by getting AI-powered insights about vulnerabilities and their remediation steps. | ||
|
||
## Set up AI integration | ||
|
||
To set up the AI integration, follow these steps: | ||
|
||
1. Go to your Port [settings page](https://app.getport.io/settings/secrets) | ||
2. Click on "Add new secret" | ||
3. Enter a name for your secret (e.g., `gpt_token`) | ||
4. Paste your LLM API token (e.g., OpenAI API key) | ||
5. Click "Save" | ||
|
||
For more information about managing secrets in Port, see the [secrets documentation](https://docs.getport.io/sso-rbac/port-secrets/). | ||
|
||
## Data model setup | ||
|
||
We'll add a new markdown field to store AI-generated insights about security vulnerabilities. This field will be added to your existing security issue blueprint (e.g., `snykVulnerability`). | ||
|
||
1. Go to the [Builder](https://app.getport.io/settings/data-model) page in your Port installation | ||
2. Find your security issue blueprint (e.g., `snykVulnerability`) | ||
3. Click on "Edit JSON" | ||
4. Add the following field to your blueprint's properties: | ||
|
||
```json | ||
{ | ||
"ai_summary": { | ||
"type": "string", | ||
"title": "ai_summary", | ||
"format": "markdown" | ||
} | ||
} | ||
``` | ||
|
||
5. Click "Save" to update the blueprint | ||
|
||
## Set up the action | ||
|
||
1. Head to the [Self-service tab](https://app.getport.io/self-serve) in your Port application | ||
2. Click on "New action" | ||
3. Click on "Edit JSON" and paste the following configuration: | ||
|
||
```json | ||
{ | ||
"identifier": "enrichSecurityVulnerabilityUsingAI", | ||
"title": "Enrich security vulnerability using AI", | ||
"icon": "Codacy", | ||
"trigger": { | ||
"type": "self-service", | ||
"operation": "DAY-2", | ||
"userInputs": { | ||
"properties": {}, | ||
"required": [], | ||
"order": [] | ||
}, | ||
"blueprintIdentifier": "snykVulnerability" | ||
}, | ||
"invocationMethod": { | ||
"type": "WEBHOOK", | ||
"url": "https://api.openai.com/v1/chat/completions", | ||
"agent": false, | ||
"synchronized": true, | ||
"method": "POST", | ||
"headers": { | ||
"RUN_ID": "{{ .run.id }}", | ||
"Content-Type": "application/json", | ||
"Authorization": "Bearer {{ .secrets.gpt_token }}" | ||
}, | ||
"body": { | ||
"model": "gpt-3.5-turbo", | ||
"messages": [ | ||
{ | ||
"role": "system", | ||
"content": "you are a security expert and should help remediate issues. Lookup for this CVE and provide in markdown few sentences on what is it and how to resolve. Limit to 500 chars. Return in markdown formatting." | ||
}, | ||
{ | ||
"role": "user", | ||
"content": " {{ .entity.properties.cveID }} " | ||
} | ||
] | ||
} | ||
} | ||
} | ||
``` | ||
|
||
4. Click "Create" to save the action | ||
|
||
## Setup automation | ||
|
||
To automatically update the security issue with the AI response, we'll create an automation: | ||
|
||
1. Go to the [Automations](https://app.getport.io/settings/automations) page | ||
2. Click on "New automation" | ||
3. Click on "Edit JSON" and paste the following configuration: | ||
|
||
```json | ||
{ | ||
"identifier": "updateSecurityIssueWithAIResponse", | ||
"title": "Update security issue based on AI", | ||
"trigger": { | ||
"type": "automation", | ||
"event": { | ||
"type": "RUN_UPDATED", | ||
"actionIdentifier": "enrichSecurityVulnerabilityUsingAI" | ||
}, | ||
"condition": { | ||
"type": "JQ", | ||
"expressions": [".diff.after.status == \"SUCCESS\""], | ||
"combinator": "and" | ||
} | ||
}, | ||
"invocationMethod": { | ||
"type": "UPSERT_ENTITY", | ||
"blueprintIdentifier": "snykVulnerability", | ||
"mapping": { | ||
"identifier": "{{ .event.diff.after.entity.identifier }} ", | ||
"properties": { | ||
"ai_summary": "{{ .event.diff.after.response.choices[0].message.content }}" | ||
} | ||
} | ||
}, | ||
"publish": true | ||
} | ||
``` | ||
|
||
4. Click "Create" to save the automation | ||
|
||
## Testing the action | ||
|
||
To test the AI enrichment: | ||
|
||
1. Navigate to your security issues page in Port | ||
2. Select a security issue that has a CVE ID | ||
3. Click on the "..." menu | ||
4. Select "Enrich security vulnerability using AI" | ||
5. Wait a few seconds for the action to complete | ||
6. Refresh the page | ||
7. You should now see the AI-generated summary in the "AI Summary" field | ||
|
||
The summary will include: | ||
|
||
- A brief explanation of the vulnerability | ||
- Potential impact | ||
- Recommended remediation steps | ||
|
||
By following these steps, you've set up an AI-powered system to help developers understand and fix security vulnerabilities more effectively 🎉 |
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the default blueprint of security issue doesn't contain cveID.
Add in the guide a section explaining what a "CVE" is, and explain the guide assumes you maintain it on a field called cveID for each issue