Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

hardened JSON imports #1135

Merged
merged 2 commits into from
Dec 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion HISTORY.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ All notable changes to this project will be documented in this file.
* Log output is less verbose, can be re-enabled via CLI switch `--verbose` ([#158] via [#1131])
Warnings and errors are still displayed as before.
This is considered a non-breaking change, since only informational logs and debug information is affected.
* Hardened JSON imports (via [#1132])
* Hardened JSON imports (via [#1132], [#1135])
* Added
* CLI switch `-v, --verbose` to increase output verbosity ([#158] via [#1131])
May be used multiple times, like `-vvv`.
Expand All @@ -21,6 +21,7 @@ All notable changes to this project will be documented in this file.
[#1131]: https://github.com/CycloneDX/cyclonedx-node-npm/pull/1131
[#1132]: https://github.com/CycloneDX/cyclonedx-node-npm/pull/1132
[#1133]: https://github.com/CycloneDX/cyclonedx-node-npm/pull/1133
[#1135]: https://github.com/CycloneDX/cyclonedx-node-npm/pull/1135

## 1.14.3 - 2023-12-01

Expand Down
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