Skip to content

Commit

Permalink
chore: code clean up to refocus on priority feature branches
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisdlangton committed Nov 18, 2024
1 parent 51c0adc commit 1126e46
Show file tree
Hide file tree
Showing 15 changed files with 1,343 additions and 861 deletions.
79 changes: 79 additions & 0 deletions functions/api/archive.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
import { AuthResult, Server } from "@/utils";
import { PrismaD1 } from '@prisma/adapter-d1';
import { PrismaClient } from '@prisma/client';

export async function onRequestGet(context) {
const {
request, // same as existing Worker API
env, // same as existing Worker API
params, // if filename includes [id] or [[path]]
waitUntil, // same as ctx.waitUntil in existing Worker API
next, // used for middleware or to fetch assets
data, // arbitrary space for passing data between middlewares
} = context
try {
const adapter = new PrismaD1(env.d1db)
const prisma = new PrismaClient({
adapter,
transactionOptions: {
maxWait: 1500, // default: 2000
timeout: 2000, // default: 5000
},
})
const verificationResult = await (new Server(request, prisma)).authenticate()
if (!verificationResult.isValid) {
return Response.json({ ok: false, result: verificationResult.message })
}
const { searchParams } = new URL(request.url)
const take = parseInt(searchParams.get('take'), 10) || 50
const skip = parseInt(searchParams.get('skip'), 10) || 0
const findings = await prisma.Finding.findMany({
where: {
orgId: verificationResult.session.orgId,
AND: {
triage: {
some: { analysisState: { in: ['resolved', 'resolved_with_pedigree', 'false_positive', 'not_affected'] } }
}
},
},
omit: {
memberEmail: true,
},
include: {
triage: {
orderBy: {
triagedAt: 'desc'
}
},
spdx: {
include: {
repo: true
}
},
cdx: {
include: {
repo: true
}
},
},
take,
skip,
orderBy: {
modifiedAt: 'desc',
}
})

return Response.json({
ok: true, findings: findings.map(finding => {
finding.references = JSON.parse(finding.referencesJSON)
delete finding.referencesJSON
finding.aliases = JSON.parse(finding.aliases)
finding.cwes = JSON.parse(finding.cwes)
return finding
})
})
} catch (err) {
console.error(err)
return Response.json({ ok: false, error: { message: err }, result: AuthResult.REVOKED })
}
}
14 changes: 7 additions & 7 deletions functions/api/history.js → functions/api/exploitable.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,17 +30,17 @@ export async function onRequestGet(context) {
const findings = await prisma.Finding.findMany({
where: {
orgId: verificationResult.session.orgId,
NOT: {
triage: {
every: { analysisState: 'in_triage', }
}
},
triage: { every: { analysisState: 'exploitable' } }
},
omit: {
memberEmail: true,
},
include: {
triage: true,
triage: {
orderBy: {
lastObserved: 'desc'
}
},
spdx: {
include: {
repo: true
Expand All @@ -55,7 +55,7 @@ export async function onRequestGet(context) {
take,
skip,
orderBy: {
createdAt: 'asc',
modifiedAt: 'desc'
}
})

Expand Down
2 changes: 1 addition & 1 deletion functions/api/new-issues.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export async function onRequestGet(context) {
orgId: verificationResult.session.orgId,
AND: {
triage: {
every: { seen: 0, analysisState: 'in_triage', }
is: { seen: 0, analysisState: 'in_triage', }
}
},
},
Expand Down
2 changes: 1 addition & 1 deletion functions/api/next-issue.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export async function onRequestGet(context) {
orgId: verificationResult.session.orgId,
AND: {
triage: {
every: { analysisState: 'in_triage' }
is: { analysisState: 'in_triage' }
}
},
}
Expand Down
77 changes: 77 additions & 0 deletions functions/api/unresolved.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
import { AuthResult, Server } from "@/utils";
import { PrismaD1 } from '@prisma/adapter-d1';
import { PrismaClient } from '@prisma/client';

export async function onRequestGet(context) {
const {
request, // same as existing Worker API
env, // same as existing Worker API
params, // if filename includes [id] or [[path]]
waitUntil, // same as ctx.waitUntil in existing Worker API
next, // used for middleware or to fetch assets
data, // arbitrary space for passing data between middlewares
} = context
try {
const adapter = new PrismaD1(env.d1db)
const prisma = new PrismaClient({
adapter,
transactionOptions: {
maxWait: 1500, // default: 2000
timeout: 2000, // default: 5000
},
})
const verificationResult = await (new Server(request, prisma)).authenticate()
if (!verificationResult.isValid) {
return Response.json({ ok: false, result: verificationResult.message })
}
const { searchParams } = new URL(request.url)
const take = parseInt(searchParams.get('take'), 10) || 50
const skip = parseInt(searchParams.get('skip'), 10) || 0
const findings = await prisma.Finding.findMany({
where: {
orgId: verificationResult.session.orgId,
AND: {
triage: { every: { analysisState: { in: ['exploitable', 'in_triage'] } } }
},
},
omit: {
memberEmail: true,
},
include: {
triage: {
orderBy: {
triagedAt: 'desc'
}
},
spdx: {
include: {
repo: true
}
},
cdx: {
include: {
repo: true
}
},
},
take,
skip,
orderBy: {
modifiedAt: 'desc',
}
})

return Response.json({
ok: true, findings: findings.map(finding => {
finding.references = JSON.parse(finding.referencesJSON)
delete finding.referencesJSON
finding.aliases = JSON.parse(finding.aliases)
finding.cwes = JSON.parse(finding.cwes)
return finding
})
})
} catch (err) {
console.error(err)
return Response.json({ ok: false, error: { message: err }, result: AuthResult.REVOKED })
}
}
9 changes: 4 additions & 5 deletions src/components/Finding.vue
Original file line number Diff line number Diff line change
Expand Up @@ -46,15 +46,14 @@ const props = defineProps({
default: true,
},
})
// Intentionally not using the VEX classes here, to provide UX that makes sense
const Response = ref([
{ value: "false_positive", text: "False Positive" },
{ value: "not_affected", text: "Not Affected" },
{ value: "can_not_fix", text: "Can Not Fix" },
{ value: "will_not_fix", text: "Will Not Fix" },
{ value: "workaround_available", text: "Workaround Available" },
])
const Justification = ref([
{ value: "code_not_present", text: "Code Not Present" },
{ value: "code_not_reachable", text: "Code Not Reachable" },
Expand Down Expand Up @@ -2457,7 +2456,7 @@ watch([
class="font-weight-bold"
>{{
cvssScore
}} / 10.0</span>
}} / 10.0</span>
</div>
<VProgressLinear
:model-value="cvssScore"
Expand All @@ -2477,7 +2476,7 @@ watch([
<span class="font-weight-medium">EPSS Score</span>
<span class="font-monospace">{{
parseFloat(props.currentTriage.epssScore).toFixed(5)
}}</span>
}}</span>
</div>
<VProgressLinear
:model-value="parseFloat(props.currentTriage.epssScore).toFixed(5)"
Expand All @@ -2498,7 +2497,7 @@ watch([
<span class="font-weight-medium">EPSS Percentile</span>
<span class="font-monospace">{{
parseFloat(props.currentTriage.epssPercentile).toFixed(5)
}}%</span>
}}%</span>
</div>
<VProgressLinear
:model-value="parseFloat(props.currentTriage.epssPercentile).toFixed(5)"
Expand Down
17 changes: 11 additions & 6 deletions src/layouts/components/DefaultLayoutWithVerticalNav.vue
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,9 @@ watch(NotificationsStore, () => {
to: '/projects',
}" />
<VerticalNavLink :item="{
title: 'Products',
title: 'Catalog',
icon: 'fluent-mdl2:product',
to: '/products',
to: '/catalog',
}" />

<VerticalNavSectionTitle :item="{
Expand All @@ -103,15 +103,20 @@ watch(NotificationsStore, () => {
icon: 'fluent-mdl2:set-action',
to: '/triage',
}" />
<!-- <VerticalNavLink :item="{
<VerticalNavLink :item="{
title: 'Exploitable',
icon: 'eos-icons:critical-bug-outlined',
to: '/triage/exploitable',
}" /> -->
}" />
<VerticalNavLink :item="{
title: 'History',
title: 'Unresolved',
icon: 'mdi-clipboard-text-history',
to: '/triage/history',
to: '/triage/unresolved',
}" />
<VerticalNavLink :item="{
title: 'Archive',
icon: 'mdi:archive',
to: '/triage/archive',
}" />

<VerticalNavSectionTitle :item="{
Expand Down
File renamed without changes.
1 change: 0 additions & 1 deletion src/pages/IssuePage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,6 @@ class Controller {
}
state.loading = false
}
}
function onTabChange() {
Expand Down
Loading

0 comments on commit 1126e46

Please sign in to comment.