diff --git a/functions/cdx/results.js b/functions/cdx/results.js index 03a2496..9d9a673 100644 --- a/functions/cdx/results.js +++ b/functions/cdx/results.js @@ -24,7 +24,7 @@ export async function onRequestGet(context) { return Response.json({ ok: false, result: verificationResult.message }) } const { searchParams } = new URL(request.url) - const take = parseInt(searchParams.get('take'), 10) || 25 + const take = parseInt(searchParams.get('take'), 10) || 50 const skip = parseInt(searchParams.get('skip'), 10) || 0 const cdx = await prisma.CycloneDXInfo.findMany({ where: { diff --git a/functions/sarif/results.js b/functions/sarif/results.js index 7ea4ec4..3bbbdf9 100644 --- a/functions/sarif/results.js +++ b/functions/sarif/results.js @@ -24,7 +24,7 @@ export async function onRequestGet(context) { return Response.json({ ok: false, result: verificationResult.message }) } const { searchParams } = new URL(request.url) - const take = parseInt(searchParams.get('take'), 10) || 25 + const take = parseInt(searchParams.get('take'), 10) || 50 const skip = parseInt(searchParams.get('skip'), 10) || 0 const sarif = await prisma.SARIFInfo.findMany({ where: { diff --git a/functions/spdx/results.js b/functions/spdx/results.js index bec20ba..b04ef1b 100644 --- a/functions/spdx/results.js +++ b/functions/spdx/results.js @@ -24,25 +24,32 @@ export async function onRequestGet(context) { return Response.json({ ok: false, result: verificationResult.message }) } const { searchParams } = new URL(request.url) - const take = parseInt(searchParams.get('take'), 10) || 25 + const take = parseInt(searchParams.get('take'), 10) || 50 const skip = parseInt(searchParams.get('skip'), 10) || 0 - const spdx = await prisma.SPDXInfo.findMany({ + let spdx = await prisma.SPDXInfo.findMany({ where: { orgId: verificationResult.session.orgId, }, - include: { + select: { + spdxId: true, + source: true, + repoName: true, + artifactUuid: true, + spdxVersion: true, + name: true, + createdAt: true, + toolName: true, + packagesCount: true, artifact: { - include: { - downloadLinks: true + select: { + downloadLinks: { + select: { + url: true, + } + } } } }, - omit: { - memberEmail: true, - comment: true, - documentNamespace: true, - documentDescribes: true, - }, take, skip, orderBy: { @@ -50,5 +57,29 @@ export async function onRequestGet(context) { }, }) + const repos = await prisma.gitRepo.findMany({ + where: { + fullName: { in: spdx.map(s => s?.repoName).filter(s => !!s).filter((value, index, array) => array.indexOf(value) === index) }, + }, + select: { + avatarUrl: true, + fullName: true, + }, + }) + const repoMap = new Map(repos.map(repo => [repo.fullName, repo.avatarUrl])); + + spdx = spdx.map(item => { + let updatedItem = { ...item } + if (item.repoName && repoMap.has(item.repoName)) { + updatedItem.avatarUrl = repoMap.get(item.repoName) + } + if (item.artifact && item.artifact.downloadLinks && item.artifact.downloadLinks.length) { + updatedItem.downloadLink = item.artifact.downloadLinks.pop().url + } + delete updatedItem.artifact + + return updatedItem + }) + return Response.json({ ok: true, spdx }) } diff --git a/prisma/schema.prisma b/prisma/schema.prisma index 2858749..aad2d46 100644 --- a/prisma/schema.prisma +++ b/prisma/schema.prisma @@ -309,7 +309,7 @@ model Link { id Int @id @default(autoincrement()) url String contentType String // OCI PLAIN_JSON OCTET_STREAM PLAIN_XML - Artifact Artifact? @relation(fields: [artifactUuid], references: [uuid]) + artifact Artifact? @relation(fields: [artifactUuid], references: [uuid]) artifactUuid String? } diff --git a/src/pages/SARIFManager.vue b/src/pages/SARIFManager.vue index 601f502..e34a85c 100644 --- a/src/pages/SARIFManager.vue +++ b/src/pages/SARIFManager.vue @@ -451,13 +451,13 @@ const controller = reactive(new Controller())