-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: code clean up to refocus on priority feature branches
- Loading branch information
1 parent
51c0adc
commit 1126e46
Showing
15 changed files
with
1,343 additions
and
861 deletions.
There are no files selected for viewing
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,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 }) | ||
} | ||
} |
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
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
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
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,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 }) | ||
} | ||
} |
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
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
File renamed without changes.
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 |
---|---|---|
|
@@ -126,7 +126,6 @@ class Controller { | |
} | ||
state.loading = false | ||
} | ||
} | ||
function onTabChange() { | ||
|
Oops, something went wrong.