Skip to content

Commit

Permalink
fix: create arguments needs data property
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisdlangton committed Nov 26, 2024
1 parent 3d34bfa commit 2c93c67
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 24 deletions.
24 changes: 12 additions & 12 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -64,18 +64,18 @@ git-demo:

_purge_data: ## FOR DOCO ONLY
npx wrangler d1 execute vulnetix --local --command "DELETE FROM Session;"
npx wrangler d1 execute vulnetix --local --command "DELETE FROM GitBranch;"
npx wrangler d1 execute vulnetix --local --command "DELETE FROM Dependency;"
npx wrangler d1 execute vulnetix --local --command "DELETE FROM SarifResults;"
npx wrangler d1 execute vulnetix --local --command "DELETE FROM CycloneDXInfo;"
npx wrangler d1 execute vulnetix --local --command "DELETE FROM SPDXInfo;"
npx wrangler d1 execute vulnetix --local --command "DELETE FROM SARIFInfo;"
npx wrangler d1 execute vulnetix --local --command "DELETE FROM IntegrationUsageLog;"
npx wrangler d1 execute vulnetix --local --command "DELETE FROM Triage;"
npx wrangler d1 execute vulnetix --local --command "DELETE FROM Finding;"
npx wrangler d1 execute vulnetix --local --command "DELETE FROM GitRepo;"
npx wrangler d1 execute vulnetix --local --command "DELETE FROM Artifact;"
npx wrangler d1 execute vulnetix --local --command "DELETE FROM Link WHERE artifactUuid IS NOT NULL;"
npx wrangler d1 execute vulnetix --local --command "DELETE FROM GitBranch;"
npx wrangler d1 execute vulnetix --local --command "DELETE FROM Dependency;"
npx wrangler d1 execute vulnetix --local --command "DELETE FROM SarifResults;"
npx wrangler d1 execute vulnetix --local --command "DELETE FROM CycloneDXInfo;"
npx wrangler d1 execute vulnetix --local --command "DELETE FROM SPDXInfo;"
npx wrangler d1 execute vulnetix --local --command "DELETE FROM SARIFInfo;"
npx wrangler d1 execute vulnetix --local --command "DELETE FROM IntegrationUsageLog;"
npx wrangler d1 execute vulnetix --local --command "DELETE FROM Triage;"
npx wrangler d1 execute vulnetix --local --command "DELETE FROM Finding;"
npx wrangler d1 execute vulnetix --local --command "DELETE FROM GitRepo;"
npx wrangler d1 execute vulnetix --local --command "DELETE FROM Artifact;"
npx wrangler d1 execute vulnetix --local --command "DELETE FROM Link WHERE artifactUuid IS NOT NULL;"

_helpers: ## FOR DOCO ONLY
npx wrangler d1 execute vulnetix --local --file ./migrations/0001_init.sql
Expand Down
11 changes: 6 additions & 5 deletions functions/api/cdx.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ export async function onRequestPost(context) {
}
}
})
const newData = { ...dep, cdxId }
if (lookup?.key) {
const infoUpd = await data.prisma.Dependency.update({
where: {
Expand All @@ -94,12 +95,12 @@ export async function onRequestPost(context) {
childOfKey: dep.childOfKey
}
})
data.logger(`Update CDX ${cdxId} Dep ${dep.name}`, infoUpd)
dependencies.push({ ...dep, cdxId })
data.logger(`Update CycloneDX ${cdxId} Dep ${dep.name}`, infoUpd)
dependencies.push(newData)
} else {
const infoAdd = await data.prisma.Dependency.create({ ...dep, cdxId })
data.logger(`Create CDX ${cdxId} Dep ${dep.name}`, infoAdd)
dependencies.push({ ...dep, cdxId })
const infoAdd = await data.prisma.Dependency.create({ data: newData })
data.logger(`Create CycloneDX ${cdxId} Dep ${dep.name}`, infoAdd)
dependencies.push(newData)
}
}
const cdxStr = JSON.stringify(cdx)
Expand Down
7 changes: 4 additions & 3 deletions functions/api/github/repos/[org]/[repo]/spdx.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ export async function onRequestGet(context) {
}
}
})
const newData = { ...dep, spdxId }
if (lookup?.key) {
const infoUpd = await data.prisma.Dependency.update({
where: {
Expand All @@ -87,11 +88,11 @@ export async function onRequestGet(context) {
}
})
data.logger(`Update SPDX ${spdxId} Dep ${dep.name}`, infoUpd)
dependencies.push({ ...dep, spdxId })
dependencies.push(newData)
} else {
const infoAdd = await data.prisma.Dependency.create({ ...dep, spdxId })
const infoAdd = await data.prisma.Dependency.create({ data: newData })
data.logger(`Create SPDX ${spdxId} Dep ${dep.name}`, infoAdd)
dependencies.push({ ...dep, spdxId })
dependencies.push(newData)
}
}
spdx.dependencies = dependencies
Expand Down
7 changes: 4 additions & 3 deletions functions/api/spdx.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ export async function onRequestPost(context) {
}
}
})
const newData = { ...dep, spdxId }
if (lookup?.key) {
const infoUpd = await data.prisma.Dependency.update({
where: {
Expand All @@ -120,11 +121,11 @@ export async function onRequestPost(context) {
}
})
data.logger(`Update SPDX ${spdxId} Dep ${dep.name}`, infoUpd)
dependencies.push({ ...dep, spdxId })
dependencies.push(newData)
} else {
const infoAdd = await data.prisma.Dependency.create({ ...dep, spdxId })
const infoAdd = await data.prisma.Dependency.create({ data: newData })
data.logger(`Create SPDX ${spdxId} Dep ${dep.name}`, infoAdd)
dependencies.push({ ...dep, spdxId })
dependencies.push(newData)
}
}
const spdxData = {
Expand Down
2 changes: 1 addition & 1 deletion prisma/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ model SPDXInfo {
}

model Dependency {
key String @unique
key String @id
name String
version String
license String?
Expand Down

0 comments on commit 2c93c67

Please sign in to comment.