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

Security fix for semver vulnerability #7043

Conversation

romainmenke
Copy link
Member

@romainmenke romainmenke commented Jul 4, 2023

Which issue, if any, is this issue related to?

Closes #5042
Closes #7040

Is there anything in the PR that needs further explanation?

Not sure how to describe this change within the conventions of the project.
Suggestions welcome.


How do we verify that #5042 is fixed?

Comments within that issue describe that updating meow is the solution, but it would be nice to verify this and to have a test that prevents regressions.


#7040 :

npm audit --production
found 0 vulnerabilities

@changeset-bot
Copy link

changeset-bot bot commented Jul 4, 2023

🦋 Changeset detected

Latest commit: 685c37f

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
stylelint Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@jeddy3
Copy link
Member

jeddy3 commented Jul 4, 2023

Not sure how to describe this change within the conventions of the project.

Let's lead with the security fix. We can manually add a changeset entry for the windows 10 regression.

@jeddy3 jeddy3 changed the title Migrate cli to ESM and update meow dependency Security fix for semver vulnerability Jul 4, 2023
@jeddy3
Copy link
Member

jeddy3 commented Jul 4, 2023

How do we verify that #5042 is fixed?

Not sure. In the past, for intermittent platform-specific issues we've just waited for users to verify it's working after release. Particularly when the issue was patched in one of our dependencies.

Copy link
Member

@ybiquitous ybiquitous left a comment

Choose a reason for hiding this comment

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

@romainmenke I don't realize this solution! Thanks!

I still have two concerns:

  1. meow requires Node.js >=14.16. Is this a breaking change? That is, should we update engines.node to ^14.18.0 || >= 16.0.0?
$ npm view meow@11.0.0 engines
{ node: '>=14.16' }

$ npx ls-engines@latest
...
┌───────────────────────────────────┬───────────────────────────┐
│ package engines:                  │ dependency graph engines: │
├───────────────────────────────────┼───────────────────────────┤
│ "engines": {                      │ "engines": {              │
│   "node": "^14.13.1 || >= 16.0.0" │   "node": ">= 14.18"      │
│ }                                 │ }                         │
└───────────────────────────────────┴───────────────────────────┘
...
  1. People will not be able to require "stylelint/lib/cli.js". Should this be acceptable? I guess there may be few people who need such a CJS way... 🤔

lib/cli.mjs Outdated Show resolved Hide resolved
@Mouvedia
Copy link
Contributor

Mouvedia commented Jul 5, 2023

That is, should we update engines.node to ^14.18.0 || >= 16.0.0?

If we revert #7020, it should be "^14.13.1 || >=16.0.0".

@jeddy3
Copy link
Member

jeddy3 commented Jul 5, 2023

meow requires Node.js >=14.16. Is this a breaking change? That is, should we update engines.node to ^14.18.0 || >= 16.0.0?

That's a shame. It is breaking (although probably for only a handful of users).

No easier answer here. Major releases are painful for plugin authors, so we only do it once a year.

Shall we move this change to v16? It's a security fix, but as we're a dev tool the impact should be low.

People will not be able to require "stylelint/lib/cli.js". Should this be acceptable?

I believe so, as it's not part of our public API.

@romainmenke
Copy link
Member Author

meow requires Node.js >=14.16. Is this a breaking change? That is, should we update engines.node to ^14.18.0 || >= 16.0.0?

meow version 11 requires these node versions, but version 10 should be fine.
I did get a typescript warning on 10, but that might be possible to solve.

Version 10 also resolves the security issue.

I will look into this shortly :)

@Mouvedia
Copy link
Contributor

Mouvedia commented Jul 5, 2023

meow version 11 requires these node versions, but version 10 should be fine.

I agree but it needs to be at least version 10.1.0.
cf #5042 (comment)

romainmenke and others added 2 commits July 5, 2023 11:42
Co-authored-by: Masafumi Koba <473530+ybiquitous@users.noreply.github.com>
Comment on lines +8 to +12
)
+ // @ts-expect-error
: Key extends keyof WithStringKeys<BaseType>
+ // @ts-expect-error
? WithStringKeys<BaseType>[Key]
Copy link
Member Author

Choose a reason for hiding this comment

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

The types were incorrect at this version, but that doesn't affect the runtime of the cli.

tsconfig.json Outdated Show resolved Hide resolved
@ybiquitous
Copy link
Member

I also agree with updating to meow@10 instead of meow@11. 👍🏼

For your information:

$ npm view meow@^10.1.0 engines
meow@10.1.0 { node: '>=12.17' }
meow@10.1.1 { node: '>=12.17' }
meow@10.1.2 { node: '^12.20.0 || ^14.13.1 || >=16.0.0' }
meow@10.1.3 { node: '^12.20.0 || ^14.13.1 || >=16.0.0' }
meow@10.1.4 { node: '^12.20.0 || ^14.13.1 || >=16.0.0' }
meow@10.1.5 { node: '^12.20.0 || ^14.13.1 || >=16.0.0' }

Perhaps, it may be better to update the latest version of meow@^10.1.0 like this:

- "meow": "^10.1.0",
+ "meow": "^10.1.5",

@ybiquitous
Copy link
Member

In addition, here's a result of ls-engines:

$ npx ls-engines@latest
...
┌───────────────────────────────────┬───────────────────────────┐
│ package engines:                  │ dependency graph engines: │
├───────────────────────────────────┼───────────────────────────┤
│ "engines": {                      │ "engines": {              │
│   "node": "^14.13.1 || >= 16.0.0" │   "node": ">= 14.18"      │
│ }                                 │ }                         │
└───────────────────────────────────┴───────────────────────────┘
...
Your “engines” field does not exactly match your dependency graph‘s requirements!
...

ls-engines still complains as above, but I think meow@^10.1.0 is acceptable because meow itself requires node: '^12.20.0 || ^14.13.1 || >=16.0.0'. 👍🏼

Copy link
Member

@ybiquitous ybiquitous left a comment

Choose a reason for hiding this comment

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

Thank you for the excellent fix. LGTM 👍🏼

"stylelint": patch
---

Security: fix for `semver` vulnerability
Copy link
Member

Choose a reason for hiding this comment

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

[note] Our maintainer guide now doesn't mention the Security: prefix. This doesn't block this PR, but I'm a bit curious. 😅

2. If applicable, add a [changeset](https://github.com/changesets/changesets) using the GitHub interface:
- prefix the entry with either: "Removed", "Changed", "Deprecated", "Added", or "Fixed"

Copy link
Member

Choose a reason for hiding this comment

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

It's an oversight. It should list all the ones from https://keepachangelog.com/en/1.0.0/. I'll open a PR.

package.json Outdated Show resolved Hide resolved
@ybiquitous
Copy link
Member

I think this PR needs one more approvement.

romainmenke and others added 2 commits July 5, 2023 15:04
Co-authored-by: Masafumi Koba <473530+ybiquitous@users.noreply.github.com>
@romainmenke
Copy link
Member Author

ls-engines still complains as above

Seems to be because of supports-hyperlinks, which is a direct dependency.

"node_modules/supports-hyperlinks": {
	"version": "3.0.0",
	// ...
	"engines": {
		"node": ">=14.18"
	}
},

Luckily not a sub dependency of meow v10.x :)

Copy link
Member

@jeddy3 jeddy3 left a comment

Choose a reason for hiding this comment

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

LGTM, thank you very much.

@romainmenke romainmenke merged commit 56a545e into main Jul 5, 2023
16 checks passed
@romainmenke romainmenke deleted the migrate-cli-to-esmodules-and-update-meow-dependency--ambitious-chihuahua-db1b479643 branch July 5, 2023 13:27
This was referenced Jul 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

Security fix for vulnerability in semver Fix invalid option regression on Windows 10
4 participants