Spaces:
Running
Running
Download scripts/validate-executable-command.js from othmanekabal/tdgbench-studio: direct link, hf CLI and curl.
- Browser
- Download file 687 Bytes
-
https://huggingface.co/spaces/othmanekabal/tdgbench-studio/resolve/main/scripts/validate-executable-command.js
- Command line
-
hf download hf://spaces/othmanekabal/tdgbench-studio/scripts/validate-executable-command.js
-
curl -L -o validate-executable-command.js https://huggingface.co/spaces/othmanekabal/tdgbench-studio/resolve/main/scripts/validate-executable-command.js
687 Bytes
| const fs = require('fs'); | |
| const vm = require('vm'); | |
| const context = { btoa: value => Buffer.from(value, 'binary').toString('base64') }; | |
| vm.createContext(context); | |
| vm.runInContext(fs.readFileSync('assets/js/core/utils.js', 'utf8'), context); | |
| const source = 'print("TDGBench command ready")'; | |
| const command = context.pythonCommand(source); | |
| const payload = command.match(/b64decode\('([^']+)'\)/)?.[1]; | |
| if (!command.startsWith('python -c "') || !payload || Buffer.from(payload, 'base64').toString('utf8') !== source) { | |
| throw new Error(`Generated command is invalid:\n${command}`); | |
| } | |
| console.log('Commande exécutable valide : le code Python généré peut être lancé directement.'); | |