Skip to content

Commit

Permalink
hardened JSON imports
Browse files Browse the repository at this point in the history
Signed-off-by: Jan Kowalleck <jan.kowalleck@gmail.com>
  • Loading branch information
jkowalleck committed Dec 10, 2023
1 parent 6007220 commit 926bd58
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/builders.ts
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,7 @@ export class BomBuilder {
const packageJsonPath = path.join(data.path, 'package.json')
try {
return Object.assign(
loadJsonFile(packageJsonPath),
loadJsonFile(packageJsonPath) ?? {},
data
)
} catch {
Expand Down Expand Up @@ -591,7 +591,7 @@ export class BomBuilder {
/* eslint-enable no-labels */

for (const packageJsonPath of packageJsonPaths) {
const packageData = loadJsonFile(packageJsonPath)
const packageData: object = loadJsonFile(packageJsonPath) ?? {}
normalizePackageData(packageData /* add debug for warnings? */)
const tool = this.toolBuilder.makeTool(packageData)
if (tool !== undefined) {
Expand Down

0 comments on commit 926bd58

Please sign in to comment.