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

Fix invalid format of generated bom by incomplete package.json files #68

Merged
merged 2 commits into from
Jun 11, 2022

Conversation

peschuster
Copy link
Contributor

Some packages (like e.g. babel/runtime) contain package.json files in sub directories that don't contain all necessary data for generating boms.

This PR introduces a solution to iterate through parent directories until a package.json with at least a name property is found and prevents incomplete dependency refs from being added to the bom to not generate output that does not comply to the cyclonedx specification.

This should also fix #31.

@peschuster peschuster requested a review from a team as a code owner June 10, 2022 10:55
@peschuster peschuster force-pushed the fix-invalid-dependency-output branch from fcd152b to 6d7a52f Compare June 10, 2022 10:57
@jkowalleck
Copy link
Member

tried to reproduce the example regarding @babel/runtime.
could not find evidences for the described behavior. tried with version 7.18.3 -- did not find any internal/shipped/bundled packages

in addition to your fix, @peschuster , could you provide an integration test so the behavior can be reproduced and fixed for good?

@peschuster
Copy link
Contributor Author

This here is the package.json that breaks the output in my project (using babel/runtime 7.17.2): https://github.com/babel/babel/blob/main/packages/babel-runtime/helpers/esm/package.json

It is a react project. I will try to create an integration test for it.

@peschuster peschuster force-pushed the fix-invalid-dependency-output branch 6 times, most recently from 5fb3e64 to 51e7176 Compare June 10, 2022 15:54
…ency

Signed-off-by: Peter Schuster <p.schuster@pilz.de>
…in sub directories of npm packages

Signed-off-by: Peter Schuster <p.schuster@pilz.de>
@peschuster peschuster force-pushed the fix-invalid-dependency-output branch from 51e7176 to f614fbf Compare June 10, 2022 16:08
@peschuster
Copy link
Contributor Author

peschuster commented Jun 10, 2022

@jkowalleck A react example with webpack5 and babel-runtime is now part of the integrations test and the tests are green again (it took some time to find a way through all the pitfalls...)

@@ -1481,3 +1481,658 @@ exports[`integration webpack5 with vue2 generated xml file: dist/.bom/bom.xml 1`
</dependencies>
</bom>"
`;

exports[`integration webpack5 with react generated json file: dist/.bom/bom.json 1`] = `
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@peschuster did you review this data?
is it the way you expected it to be?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes I did and it looks correct to me.

@jkowalleck
Copy link
Member

Thank you for the fix.
Could you add an entry to the HISTORY.md file?

@jkowalleck
Copy link
Member

Thank you for the fix. Could you add an entry to the HISTORY.md file?

nevermind, will add it in release preparations

@jkowalleck jkowalleck merged commit 1df3d5d into CycloneDX:master Jun 11, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

null entries in dependsOn
2 participants