-
Notifications
You must be signed in to change notification settings - Fork 0
[VW-354] Issue/Note model changes; VEX sorting agent
#150
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
Open
0xcad
wants to merge
13
commits into
main
Choose a base branch
from
VW-354
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 all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
2ae5bbb
new issue + notes schema
0xcad 4424996
no longer seed issues
0xcad 01d0a9b
VEX agent, prisma client extensions
0xcad 5734d34
reorganized agent code
0xcad 11a908e
mostly comment changes
0xcad 243d8b5
Merge branch 'main' into VW-354
0xcad 5eeae10
changed whitespace of schema.prisma
0xcad 7b93d04
fetch device groups from deviceGroupsMatchings
0xcad 43c0b45
device group matching change again
0xcad e5d3fcb
new seed script; get notes stub
0xcad 75edfbf
notes no longer reference dg directly
0xcad 40c404b
format
0xcad 7663869
coderabbit suggestion
0xcad 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
151 changes: 151 additions & 0 deletions
151
prisma/migrations/20260701212209_issue_and_notes/migration.sql
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,151 @@ | ||
| /* | ||
| Warnings: | ||
|
|
||
| - The `status` column on the `advisory` table would be dropped and recreated. This will lead to data loss if there is data in the column. | ||
| - The `status` column on the `issue` table would be dropped and recreated. This will lead to data loss if there is data in the column. | ||
| - A unique constraint covering the columns `[deviceGroupMatchingId,vulnerabilityId]` on the table `issue` will be added. If there are existing duplicate values, this will fail. | ||
|
|
||
| */ | ||
| -- CreateEnum | ||
| CREATE TYPE "IssueStatus_new" AS ENUM ('NOT_AFFECTED', 'AFFECTED', 'FIXED', 'UNDER_INVESTIGATION'); | ||
|
|
||
| -- CreateEnum | ||
| CREATE TYPE "NotAffectedJustification" AS ENUM ('COMPONENT_NOT_PRESENT', 'VULNERABLE_CODE_NOT_PRESENT', 'VULNERABLE_CODE_NOT_IN_EXECUTE_PATH', 'VULNERABLE_CODE_CANNOT_BE_CONTROLLED_BY_ADVERSARY', 'INLINE_MITIGATIONS_ALREADY_EXIST', 'HOSPITAL_COMPENSATING_CONTROL', 'HOSPITAL_ACCEPTS_RISK'); | ||
|
|
||
| -- CreateEnum | ||
| CREATE TYPE "NoteStatus" AS ENUM ('PERSISTENT', 'SCOPED'); | ||
|
|
||
| -- CreateEnum | ||
| CREATE TYPE "ScopeTargetModel" AS ENUM ('DEVICE_GROUP_MATCHING', 'ASSET', 'VULNERABILITY', 'REMEDIATION'); | ||
|
|
||
| -- AlterTable | ||
| -- Remap "advisory"."status" to the new IssueStatus values without dropping | ||
| -- the column, so existing data is preserved instead of discarded. | ||
| ALTER TABLE "advisory" ALTER COLUMN "status" DROP DEFAULT; | ||
| ALTER TABLE "advisory" ALTER COLUMN "status" TYPE "IssueStatus_new" | ||
| USING ( | ||
| CASE "status"::text | ||
| WHEN 'ACTIVE' THEN 'AFFECTED' | ||
| WHEN 'FALSE_POSITIVE' THEN 'NOT_AFFECTED' | ||
| WHEN 'REMEDIATED' THEN 'FIXED' | ||
| END | ||
| )::"IssueStatus_new"; | ||
| ALTER TABLE "advisory" ALTER COLUMN "status" SET DEFAULT 'AFFECTED'; | ||
|
|
||
| -- AlterTable | ||
| ALTER TABLE "issue" ADD COLUMN "deviceGroupMatchingId" TEXT, | ||
| ADD COLUMN "notAffectedJustification" "NotAffectedJustification", | ||
| ADD COLUMN "statusConfidence" "ConfidenceLevel", | ||
| ADD COLUMN "statusNotes" TEXT, | ||
| ALTER COLUMN "assetId" DROP NOT NULL; | ||
|
|
||
| -- Remap "issue"."status" to the new IssueStatus values without dropping | ||
| -- the column, so existing per-asset issues keep their status | ||
| -- (ACTIVE->AFFECTED, FALSE_POSITIVE->NOT_AFFECTED, REMEDIATED->FIXED). | ||
| ALTER TABLE "issue" ALTER COLUMN "status" DROP DEFAULT; | ||
| ALTER TABLE "issue" ALTER COLUMN "status" TYPE "IssueStatus_new" | ||
| USING ( | ||
| CASE "status"::text | ||
| WHEN 'ACTIVE' THEN 'AFFECTED' | ||
| WHEN 'FALSE_POSITIVE' THEN 'NOT_AFFECTED' | ||
| WHEN 'REMEDIATED' THEN 'FIXED' | ||
| END | ||
| )::"IssueStatus_new"; | ||
| ALTER TABLE "issue" ALTER COLUMN "status" SET DEFAULT 'AFFECTED'; | ||
|
|
||
| -- DropEnum (old IssueStatus, now unreferenced since both columns were | ||
| -- repointed to IssueStatus_new above) | ||
| DROP TYPE "IssueStatus"; | ||
|
|
||
| -- Rename the new enum into the name the old one vacated | ||
| ALTER TYPE "IssueStatus_new" RENAME TO "IssueStatus"; | ||
|
|
||
| -- CreateTable | ||
| CREATE TABLE "note" ( | ||
| "id" TEXT NOT NULL, | ||
| "text" TEXT NOT NULL, | ||
| "status" "NoteStatus" NOT NULL DEFAULT 'SCOPED', | ||
| "userId" TEXT, | ||
| "targetModel" "ScopeTargetModel", | ||
| "instanceId" TEXT, | ||
| "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, | ||
| "updatedAt" TIMESTAMP(3) NOT NULL, | ||
|
|
||
| CONSTRAINT "note_pkey" PRIMARY KEY ("id") | ||
| ); | ||
|
|
||
| -- CreateTable | ||
| CREATE TABLE "entity_filter" ( | ||
| "id" TEXT NOT NULL, | ||
| "label" TEXT, | ||
| "targetModel" "ScopeTargetModel" NOT NULL, | ||
| "filter" JSONB NOT NULL, | ||
| "noteId" TEXT, | ||
| "issueId" TEXT, | ||
| "lastResolvedAt" TIMESTAMP(3), | ||
| "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, | ||
| "updatedAt" TIMESTAMP(3) NOT NULL, | ||
|
|
||
| CONSTRAINT "entity_filter_pkey" PRIMARY KEY ("id") | ||
| ); | ||
|
|
||
| -- CreateTable | ||
| CREATE TABLE "entity_filter_match" ( | ||
| "id" TEXT NOT NULL, | ||
| "entityFilterId" TEXT NOT NULL, | ||
| "targetId" TEXT NOT NULL, | ||
| "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, | ||
|
|
||
| CONSTRAINT "entity_filter_match_pkey" PRIMARY KEY ("id") | ||
| ); | ||
|
|
||
| -- CreateIndex | ||
| CREATE INDEX "note_targetModel_instanceId_idx" ON "note"("targetModel", "instanceId"); | ||
|
|
||
| -- CreateIndex | ||
| CREATE INDEX "note_userId_idx" ON "note"("userId"); | ||
|
|
||
| -- CreateIndex | ||
| CREATE INDEX "note_status_idx" ON "note"("status"); | ||
|
|
||
| -- CreateIndex | ||
| CREATE INDEX "entity_filter_noteId_idx" ON "entity_filter"("noteId"); | ||
|
|
||
| -- CreateIndex | ||
| CREATE INDEX "entity_filter_issueId_idx" ON "entity_filter"("issueId"); | ||
|
|
||
| -- CreateIndex | ||
| CREATE INDEX "entity_filter_targetModel_idx" ON "entity_filter"("targetModel"); | ||
|
|
||
| -- CreateIndex | ||
| CREATE INDEX "entity_filter_match_targetId_idx" ON "entity_filter_match"("targetId"); | ||
|
|
||
| -- CreateIndex | ||
| CREATE UNIQUE INDEX "entity_filter_match_entityFilterId_targetId_key" ON "entity_filter_match"("entityFilterId", "targetId"); | ||
|
|
||
| -- CreateIndex | ||
| CREATE INDEX "issue_assetId_idx" ON "issue"("assetId"); | ||
|
|
||
| -- CreateIndex | ||
| CREATE INDEX "issue_deviceGroupMatchingId_idx" ON "issue"("deviceGroupMatchingId"); | ||
|
|
||
| -- CreateIndex | ||
| CREATE INDEX "issue_vulnerabilityId_idx" ON "issue"("vulnerabilityId"); | ||
|
|
||
| -- CreateIndex | ||
| CREATE UNIQUE INDEX "issue_deviceGroupMatchingId_vulnerabilityId_key" ON "issue"("deviceGroupMatchingId", "vulnerabilityId"); | ||
|
|
||
| -- AddForeignKey | ||
| ALTER TABLE "issue" ADD CONSTRAINT "issue_deviceGroupMatchingId_fkey" FOREIGN KEY ("deviceGroupMatchingId") REFERENCES "device_group_matching"("id") ON DELETE CASCADE ON UPDATE CASCADE; | ||
|
|
||
| -- AddForeignKey | ||
| ALTER TABLE "note" ADD CONSTRAINT "note_userId_fkey" FOREIGN KEY ("userId") REFERENCES "user"("id") ON DELETE SET NULL ON UPDATE CASCADE; | ||
|
|
||
| -- AddForeignKey | ||
| ALTER TABLE "entity_filter" ADD CONSTRAINT "entity_filter_noteId_fkey" FOREIGN KEY ("noteId") REFERENCES "note"("id") ON DELETE CASCADE ON UPDATE CASCADE; | ||
|
|
||
| -- AddForeignKey | ||
| ALTER TABLE "entity_filter" ADD CONSTRAINT "entity_filter_issueId_fkey" FOREIGN KEY ("issueId") REFERENCES "issue"("id") ON DELETE CASCADE ON UPDATE CASCADE; | ||
|
|
||
| -- AddForeignKey | ||
| ALTER TABLE "entity_filter_match" ADD CONSTRAINT "entity_filter_match_entityFilterId_fkey" FOREIGN KEY ("entityFilterId") REFERENCES "entity_filter"("id") ON DELETE CASCADE ON UPDATE CASCADE; |
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
Oops, something went wrong.
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.
Consistent with RFC: https://docs.google.com/document/d/1aNnNuV9U0cPtB4w47FdAa9NcuhoNUHWLi3lTrvJipLE/edit?tab=t.58d3c6iikxg2