Skip to content

Commit

Permalink
Only allow user packages on system VFS (#28)
Browse files Browse the repository at this point in the history
  • Loading branch information
andersevenrud committed Apr 11, 2020
1 parent 70d2dfe commit f1a2af6
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions src/packages.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,9 @@
const fs = require('fs-extra');
const fg = require('fast-glob');
const path = require('path');
const Package = require('./package.js');
const consola = require('consola');
const Package = require('./package.js');
const {getPrefix} = require('./utils/vfs.js');
const logger = consola.withTag('Packages');

const relative = filename => filename.replace(process.cwd(), '');
Expand Down Expand Up @@ -155,11 +156,17 @@ class Packages {
* @return {Package[]} List of packages
*/
async readPackageManifests(paths, user) {
const {realpath} = this.core.make('osjs/vfs');
const {realpath, mountpoints} = this.core.make('osjs/vfs');
const {manifestFile} = this.options;
const systemManifest = await readOrDefault(manifestFile);

const userManifests = await Promise.all(paths.map(async p => {
const isValidVfs = p => {
const prefix = getPrefix(p);
const mount = mountpoints.find(m => m.name === prefix);
return mount && mount.attributes.root;
};

const userManifests = await Promise.all(paths.filter(isValidVfs).map(async p => {
const real = await realpath(`${p}/metadata.json`, user);
const list = await readOrDefault(real);

Expand Down

0 comments on commit f1a2af6

Please sign in to comment.