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

Direct dependencies not recognized when yarn.lock #1085

Closed
jc911 opened this issue May 16, 2024 · 4 comments
Closed

Direct dependencies not recognized when yarn.lock #1085

jc911 opened this issue May 16, 2024 · 4 comments

Comments

@jc911
Copy link

jc911 commented May 16, 2024

The direct dependencies are righ when I use npm install (package-lock.json)
There are many more direct dependencies in bom.json when I use yarn install (yarn.lock)

Maybe the same question as this issue Dependency Tree failing for yarn.lock files

@prabhu
Copy link
Contributor

prabhu commented May 19, 2024

@jc911, could you triage a bit more and let me know the correct list of direct dependencies for yarn. May be there is some yarn command that we can try and mimic?

@jc911
Copy link
Author

jc911 commented May 20, 2024

Thanks for your response!
For example:
https://github.com/yarnpkg/website
The direct dependencies I think should be devDependencies and dependencies in the package.json

"devDependencies": {
    "algolia-sitemap": "^2.1.1",
    "babel-core": "^6.26.3",
    "babel-loader": "^7.1.4",
    "babel-plugin-transform-react-constant-elements": "^6.23.0",
    "babel-plugin-transform-react-inline-elements": "^6.22.0",
    "babel-preset-env": "1.7.0",
    "babel-preset-react": "^6.24.1",
    "babel-preset-stage-2": "^6.24.1",
    "happypack": "^4.0.1",
    "lint-staged": "9.0.0",
    "pre-commit": "^1.2.2",
    "prettier": "^1.13.4",
    "webpack": "^3.5.5",
    "webpack-bundle-analyzer": "^3.3.2",
    "webpack-manifest-plugin": "^1.3.1"
  },
"dependencies": {
    "@haroenv/react-sparklines": "^1.7.1",
    "algoliasearch": "^3.27.1",
    "bootstrap": "^4.0.0-alpha.5",
    "bytes": "^3.0.0",
    "date-fns": "^2.0.0-alpha.7",
    "docsearch.js": "^2.5.2",
    "jquery": "^3.4.0",
    "marked": "^0.4.0",
    "popper.js": "^1.14.3",
    "prop-types": "^15.6.1",
    "qs": "^6.5.2",
    "react": "^16.4.0",
    "react-dom": "^16.4.2",
    "react-instantsearch-dom": "^5.2.0-beta.2",
    "react-transition-group": "^1.2.1",
    "unescape-html": "^1.0.0",
    "unfetch": "^3.0.0",
    "xss": "^1.0.3"
  },

But in the bom.json there are a lot

{
      "ref": "pkg:npm/website@1.0.0",
      "dependsOn": [
        "pkg:npm/@haroenv/react-sparklines@1.7.1",
        "pkg:npm/@samverschueren/stream-to-observable@0.3.0",
        "pkg:npm/@types/events@3.0.0",
        "pkg:npm/@types/glob@7.1.1",
        "pkg:npm/@types/minimatch@3.0.3",
        "pkg:npm/@types/node@12.0.10",
        "pkg:npm/abbrev@1.1.1",
        "pkg:npm/accepts@1.3.7",
        "pkg:npm/acorn-dynamic-import@2.0.2",
        "pkg:npm/acorn-walk@6.1.1",
        "pkg:npm/acorn@4.0.13",
        "pkg:npm/acorn@5.6.2",
        "pkg:npm/acorn@6.1.1",
        "pkg:npm/agentkeepalive@2.2.0",
        "pkg:npm/ajv-keywords@3.2.0",
        "pkg:npm/ajv@6.5.1",
        "pkg:npm/algolia-sitemap@2.1.1",
        "pkg:npm/algoliasearch-helper@2.26.1",
        "pkg:npm/algoliasearch@3.27.1",
        "pkg:npm/align-text@0.1.4",
        "pkg:npm/ansi-escapes@3.2.0",
        "pkg:npm/ansi-regex@2.1.1",
        "pkg:npm/ansi-regex@3.0.0",
        "pkg:npm/ansi-styles@2.2.1",
        "pkg:npm/ansi-styles@3.2.1",
        "pkg:npm/any-observable@0.3.0",
        "pkg:npm/anymatch@2.0.0",
        "pkg:npm/aproba@1.2.0",
        "pkg:npm/are-we-there-yet@1.1.5",
        "pkg:npm/argparse@1.0.10",
        "pkg:npm/arr-diff@4.0.0",
        "pkg:npm/arr-flatten@1.1.0",
        "pkg:npm/arr-union@3.1.0",
        "pkg:npm/array-flatten@1.1.1",
        "pkg:npm/array-union@1.0.2",
        "pkg:npm/array-uniq@1.0.3",
        "pkg:npm/array-unique@0.3.2",
        "pkg:npm/asap@2.0.6",
        "pkg:npm/asn1.js@4.10.1",
        "pkg:npm/assert@1.4.1",
        "pkg:npm/assign-symbols@1.0.0",
        "pkg:npm/async-each@1.0.1",
        "pkg:npm/async-limiter@1.0.0",
        "pkg:npm/async@1.5.0",
        "pkg:npm/async@2.6.1",
        "pkg:npm/atob@2.1.1",
        "pkg:npm/autocomplete.js@0.29.0",
        "pkg:npm/babel-code-frame@6.26.0",
        "pkg:npm/babel-core@6.26.0",
        ......
        ......
        "pkg:npm/xtend@4.0.1",
        "pkg:npm/y18n@3.2.1",
        "pkg:npm/yallist@2.1.2",
        "pkg:npm/yallist@3.0.2",
        "pkg:npm/yargs-parser@7.0.0",
        "pkg:npm/yargs@3.10.0",
        "pkg:npm/yargs@8.0.2"
      ]
    },

@prabhu
Copy link
Contributor

prabhu commented May 20, 2024

@jc911 Thank you. Below is the line that needs to be improved to match this behaviour. It is currently matching yarn list command. Would you be interested in contributing a PR?

cdxgen/index.js

Line 2374 in e5d2054

// In case of yarn, yarn list command lists every root package as a direct dependency

@prabhu
Copy link
Contributor

prabhu commented May 22, 2024

I tested cdxgen with the output of yarn list --depth=0 and found the results to be matching. Closing this bug, since this is not an issue (although I agree that yarn is over-reporting the first level dependencies). You can always feel free to use --required-only and other filters to limit the components in the SBOM.

@prabhu prabhu closed this as completed May 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants