( installed: readonly InstalledAppLike[], homeDir: string | undefined, )
| 166 | * attacker-installed); still length-capped, deduped, sorted. |
| 167 | */ |
| 168 | export function filterAppsForDescription( |
| 169 | installed: readonly InstalledAppLike[], |
| 170 | homeDir: string | undefined, |
| 171 | ): string[] { |
| 172 | const { alwaysKept, rest } = installed.reduce<{ |
| 173 | alwaysKept: string[] |
| 174 | rest: string[] |
| 175 | }>( |
| 176 | (acc, app) => { |
| 177 | if (ALWAYS_KEEP_BUNDLE_IDS.has(app.bundleId)) { |
| 178 | acc.alwaysKept.push(app.displayName) |
| 179 | } else if ( |
| 180 | isUserFacingPath(app.path, homeDir) && |
| 181 | !isNoisyName(app.displayName) |
| 182 | ) { |
| 183 | acc.rest.push(app.displayName) |
| 184 | } |
| 185 | return acc |
| 186 | }, |
| 187 | { alwaysKept: [], rest: [] }, |
| 188 | ) |
| 189 | |
| 190 | const sanitizedAlways = sanitizeTrustedNames(alwaysKept) |
| 191 | const alwaysSet = new Set(sanitizedAlways) |
| 192 | return [ |
| 193 | ...sanitizedAlways, |
| 194 | ...sanitizeAppNames(rest).filter(n => !alwaysSet.has(n)), |
| 195 | ] |
| 196 | } |
| 197 |
no test coverage detected