-
Notifications
You must be signed in to change notification settings - Fork 354
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #248 from kumavis/secure-eval
feat: more safely evaluate llm generated code in a SES Compartment
- Loading branch information
Showing
5 changed files
with
55 additions
and
60 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,6 @@ | ||
import * as skills from '../../../src/agent/library/skills.js'; | ||
import * as world from '../../../src/agent/library/world.js'; | ||
import Vec3 from 'vec3'; | ||
(async (bot) => { | ||
|
||
const log = skills.log; | ||
/* CODE HERE */ | ||
log(bot, 'Code finished.'); | ||
|
||
export async function main(bot) { | ||
/* CODE HERE */ | ||
log(bot, 'Code finished.'); | ||
} | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import 'ses'; | ||
|
||
// This sets up the secure environment | ||
// We disable some of the taming to allow for more flexibility | ||
|
||
// For configuration, see https://github.com/endojs/endo/blob/master/packages/ses/docs/lockdown.md | ||
lockdown({ | ||
// basic devex and quality of life improvements | ||
localeTaming: 'unsafe', | ||
consoleTaming: 'unsafe', | ||
errorTaming: 'unsafe', | ||
stackFiltering: 'verbose', | ||
// allow eval outside of created compartments | ||
// (mineflayer dep "protodef" uses eval) | ||
evalTaming: 'unsafeEval', | ||
}); | ||
|
||
export const makeCompartment = (endowments = {}) => { | ||
return new Compartment({ | ||
// provide untamed Math, Date, etc | ||
Math, | ||
Date, | ||
// standard endowments | ||
...endowments | ||
}); | ||
} |
This file was deleted.
Oops, something went wrong.