mirror of
https://github.com/usebruno/bruno.git
synced 2026-06-24 21:25:45 +00:00
Safe Mode Sandbox using QuickJS Co-authored-by: Anoop M D <anoop.md1421@gmail.com> Co-authored-by: lohit <lohit.jiddimani@gmail.com>
40 lines
1.1 KiB
JavaScript
40 lines
1.1 KiB
JavaScript
const _ = require('lodash');
|
|
const Store = require('electron-store');
|
|
|
|
class CollectionSecurityStore {
|
|
constructor() {
|
|
this.store = new Store({
|
|
name: 'collection-security',
|
|
clearInvalidConfig: true
|
|
});
|
|
}
|
|
|
|
setSecurityConfigForCollection(collectionPathname, securityConfig) {
|
|
const collections = this.store.get('collections') || [];
|
|
const collection = _.find(collections, (c) => c.path === collectionPathname);
|
|
|
|
if (!collection) {
|
|
collections.push({
|
|
path: collectionPathname,
|
|
securityConfig: {
|
|
jsSandboxMode: securityConfig.jsSandboxMode
|
|
}
|
|
});
|
|
|
|
this.store.set('collections', collections);
|
|
return;
|
|
}
|
|
|
|
collection.securityConfig = securityConfig || {};
|
|
this.store.set('collections', collections);
|
|
}
|
|
|
|
getSecurityConfigForCollection(collectionPathname) {
|
|
const collections = this.store.get('collections') || [];
|
|
const collection = _.find(collections, (c) => c.path === collectionPathname);
|
|
return collection?.securityConfig || {};
|
|
}
|
|
}
|
|
|
|
module.exports = CollectionSecurityStore;
|