mirror of
https://github.com/pnpm/pnpm.git
synced 2026-01-23 14:28:50 -05:00
fix: detecting files with executable permissions in side effects cache (#8625)
close #8546 close #7746
This commit is contained in:
6
.changeset/olive-pants-know.md
Normal file
6
.changeset/olive-pants-know.md
Normal file
@@ -0,0 +1,6 @@
|
||||
---
|
||||
"@pnpm/store.cafs": patch
|
||||
"pnpm": patch
|
||||
---
|
||||
|
||||
When checking whether a file in the store has executable permissions, the new approach checks if at least one of the executable bits (owner, group, and others) is set to 1. Previously, a file was incorrectly considered executable only when all the executable bits were set to 1. This fix ensures that files with any executable permission, regardless of the user class, are now correctly identified as executable [#8546](https://github.com/pnpm/pnpm/issues/8546).
|
||||
@@ -1,7 +1,20 @@
|
||||
import path from 'path'
|
||||
import ssri, { type IntegrityLike } from 'ssri'
|
||||
|
||||
export const modeIsExecutable = (mode: number): boolean => (mode & 0o111) === 0o111
|
||||
/**
|
||||
* Checks if a file mode has any executable permissions set.
|
||||
*
|
||||
* This function performs a bitwise check to determine if at least one of the
|
||||
* executable bits (owner, group, or others) is set in the file mode.
|
||||
*
|
||||
* The bit mask `0o111` corresponds to the executable bits for the owner (0o100),
|
||||
* group (0o010), and others (0o001). If any of these bits are set, the file
|
||||
* is considered executable.
|
||||
*
|
||||
* @param {number} mode - The file mode (permission bits) to check.
|
||||
* @returns {boolean} - Returns true if any of the executable bits are set, false otherwise.
|
||||
*/
|
||||
export const modeIsExecutable = (mode: number): boolean => (mode & 0o111) !== 0
|
||||
|
||||
export type FileType = 'exec' | 'nonexec' | 'index'
|
||||
|
||||
|
||||
Reference in New Issue
Block a user