(stats: {
mode: number;
uid: number;
})
| 187 | * Reports unsafe ownership or write permissions from filesystem metadata. |
| 188 | */ |
| 189 | export function getUnsafeStatsReason(stats: { |
| 190 | mode: number; |
| 191 | uid: number; |
| 192 | }): string | null { |
| 193 | const getuid = process.geteuid ?? process.getuid; |
| 194 | |
| 195 | if (typeof getuid !== 'function') { |
| 196 | return null; |
| 197 | } |
| 198 | |
| 199 | const uid = getuid(); |
| 200 | |
| 201 | if ((stats.mode & 0o022) !== 0) { |
| 202 | if ((stats.mode & 0o002) !== 0) { |
| 203 | return 'world-writable'; |
| 204 | } |
| 205 | |
| 206 | return 'group-writable'; |
| 207 | } |
| 208 | |
| 209 | if (stats.uid !== uid) { |
| 210 | return `owned by uid ${stats.uid}, current uid is ${uid}`; |
| 211 | } |
| 212 | |
| 213 | return null; |
| 214 | } |
no outgoing calls
no test coverage detected