Problem/Motivation
Since #3308369: Block access to yarn.lock and package.json we block access to yarn.lock.
Core only uses Yarn and does not have a package-lock.json but custom themes could use NPM and have this lock file so it could make sense to also block access to it as a hardening.
For example gin has one: https://git.drupalcode.org/project/gin/-/blob/5.0.x/package-lock.json?re...
Steps to reproduce
- Install gin.
- Browse to /themes/contrib/gin/package-lock.json.
Proposed resolution
Add package-lock.json to this rule in .htaccess: https://git.drupalcode.org/project/drupal/-/blob/5674bcd77c27bbc82ed92bb...
Remaining tasks
User interface changes
Introduced terminology
API changes
Data model changes
Release notes snippet
Drupal's .htaccess now blocks HTTP access to package-lock.json, alongside the existing protection for package.json and yarn.lock.
Core uses Yarn and does not produce a package-lock.json itself. Contributed or custom themes and modules that use npm can have one.
Sites with a customized .htaccess (including scaffold-managed sites that override the scaffolded file) need to apply the same change: replace package\.json with package(-lock)?\.json in the FilesMatch rule.
Issue fork drupal-3584532
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
- 3584532-block-access-to
changes, plain diff MR !15451
Comments
Comment #2
scontzen commentedComment #4
scontzen commentedChanged
package\.jsontopackage(-lock)?\.jsonin.htaccess. Theweb.configwas removed from core in #3437335: Remove web.config from 11.x, so no changes needed there.Tested locally.
package-lock.jsonreturned 200 before, 403 after.Comment #5
smustgrave commentedTest failure seems relevant, may need to update the scaffold files too.
Comment #6
scontzen commentedThanks. Updated the scaffold file and added test coverage for package-lock.json.
Comment #7
smustgrave commentedChange LGTM.
Comment #10
catchCommitted/pushed to main and cherry-picked to 11.x, thanks!
After committing I realised we need a release note and probably a change record - since sites can modify their .htaccess and might need to manually apply the same change.
I've added a stub release note but moving to needs work for fleshing that out and the CR.
Comment #12
scontzen commentedExpanded the release notes snippet.
Comment #13
prudloff commentedI drafted a CR.
Comment #14
smustgrave commentedLGTM
Comment #15
godotislatePublished the CR.