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

3.4.0 - ReferenceError: Name is required #252

Closed
IonKiwi opened this issue Feb 10, 2022 · 9 comments · Fixed by #253
Closed

3.4.0 - ReferenceError: Name is required #252

IonKiwi opened this issue Feb 10, 2022 · 9 comments · Fixed by #253
Labels

Comments

@IonKiwi
Copy link

IonKiwi commented Feb 10, 2022

Upgraded from 3.3.1 to 3.4.0.
Running 3.4 results in the following error:

C:\Tools\node\node_modules@cyclonedx\bom\model\CycloneDXObject.js:35
if (required) { throw new ReferenceError(name + ' is required') }
^

ReferenceError: Name is required
at Component.validateType (C:\Tools\node\node_modules@cyclonedx\bom\model\CycloneDXObject.js:35:29)
at Component.set name [as name] (C:\Tools\node\node_modules@cyclonedx\bom\model\Component.js:276:23)
at new Component (C:\Tools\node\node_modules@cyclonedx\bom\model\Component.js:98:17)
at Bom.createMetadata (C:\Tools\node\node_modules@cyclonedx\bom\model\Bom.js:48:26)
at new Bom (C:\Tools\node\node_modules@cyclonedx\bom\model\Bom.js:39:29)
at C:\Tools\node\node_modules@cyclonedx\bom\index.js:33:15
at C:\Tools\node\node_modules\read-installed\read-installed.js:142:5
at C:\Tools\node\node_modules\read-installed\read-installed.js:263:14
at cb (C:\Tools\node\node_modules\slide\lib\async-map.js:47:24)
at C:\Tools\node\node_modules\read-installed\read-installed.js:263:14

OS: Windows Server 2019
NodeJS: 16.5.0
Command: cyclonedx-bom -o bom.js

@jkowalleck
Copy link
Member

@IonKiwi please provide more details:

  • the npm-lockfile that was used (upload/atack it to the issue)

@IonKiwi
Copy link
Author

IonKiwi commented Feb 10, 2022

attached the lock file that was used
package-lock.zip

@IonKiwi IonKiwi closed this as completed Feb 10, 2022
@IonKiwi IonKiwi reopened this Feb 10, 2022
@jkowalleck
Copy link
Member

@IonKiwi could you help understand the serup a bit more?

Maybe setup a repository with that package-lock and as minimal content as required, to reproduce the issue?
maybe add a README file in it, that describes the setup, the expectations, the observed behavior and so on?

@IonKiwi
Copy link
Author

IonKiwi commented Feb 10, 2022

Also attached the package.json file.
package.zip

Steps to reproduce:
npm install -g @cyclonedx/bom
npm install (in the directory with the attached package.json)
cyclonedx-bom -o bom.js

with 3.3.1 that results in the sbom file, with 3.4.0 it results in the above error

@jkowalleck jkowalleck added the bug label Feb 10, 2022
@jkowalleck
Copy link
Member

jkowalleck commented Feb 10, 2022

reproduced the error.

found the issue: the root component does not have a name - and is therefore invalid.

the package might be a private one, and have no name for that reason. also other required fields might be missing.

intended solution:

  • the root component might miss some fields that are required for CycloneDX. therefore a bunch of fallback literals should be used instead of the missing information, so that the resulting data structures are valid.

additional tasks:

  • add a test scenario there the name of the root component is empty -> see that it is filled in the result
  • add additional exception handling
  • add more verbose error text

@jkowalleck jkowalleck pinned this issue Feb 10, 2022
@jkowalleck
Copy link
Member

thanks for the report @IonKiwi .

I am working on a fix.

jkowalleck added a commit that referenced this issue Feb 11, 2022
Signed-off-by: Jan Kowalleck <jan.kowalleck@gmail.com>
jkowalleck added a commit that referenced this issue Feb 11, 2022
Signed-off-by: Jan Kowalleck <jan.kowalleck@gmail.com>
jkowalleck added a commit that referenced this issue Feb 11, 2022
Signed-off-by: Jan Kowalleck <jan.kowalleck@gmail.com>
jkowalleck added a commit that referenced this issue Feb 11, 2022
fix #252

Signed-off-by: Jan Kowalleck <jan.kowalleck@gmail.com>
jkowalleck added a commit that referenced this issue Feb 11, 2022
fix #252

Signed-off-by: Jan Kowalleck <jan.kowalleck@gmail.com>
jkowalleck added a commit that referenced this issue Feb 11, 2022
fix #252

Signed-off-by: Jan Kowalleck <jan.kowalleck@gmail.com>
jkowalleck added a commit that referenced this issue Feb 11, 2022
fix #252

Signed-off-by: Jan Kowalleck <jan.kowalleck@gmail.com>
jkowalleck added a commit that referenced this issue Feb 11, 2022
fix #252

Signed-off-by: Jan Kowalleck <jan.kowalleck@gmail.com>
jkowalleck added a commit that referenced this issue Feb 11, 2022
fix #252

Signed-off-by: Jan Kowalleck <jan.kowalleck@gmail.com>
@jkowalleck
Copy link
Member

fix was implemented. #253
ready for review&merge&release

jkowalleck added a commit that referenced this issue Feb 11, 2022
fix #252

Signed-off-by: Jan Kowalleck <jan.kowalleck@gmail.com>
jkowalleck added a commit that referenced this issue Feb 11, 2022
* Fixed
  * root-packages without a name no longer cause unexpected crashes ([#252] via [#253])

[#252]: #252
[#253]: #253
@jkowalleck jkowalleck unpinned this issue Feb 11, 2022
@jkowalleck
Copy link
Member

@IonKiwi a fix was released via 3.4.1
could you check?

@IonKiwi
Copy link
Author

IonKiwi commented Feb 11, 2022

Great! can confirm that it's fixed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants