Importer cleanup
DELETE
packages/make-importer/.circleci/config.yml
-version: 2.0
-
-references:
-
- node12: &node12image
- docker:
- - image: circleci/node:12
-
- node11: &node11image
- docker:
- - image: circleci/node:11
-
- node10: &node10image
- docker:
- - image: circleci/node:10
-
- node9: &node9image
- docker:
- - image: circleci/node:9
-
- node8: &node8image
- docker:
- - image: circleci/node:8
-
- node7: &node7image
- docker:
- - image: circleci/node:7
-
- node11browser: &node11browsersimage
- docker:
- - image: circleci/node:11-browsers
-
- node10browser: &node10browsersimage
- docker:
- - image: circleci/node:10-browsers
-
- node9browser: &node9browsersimage
- docker:
- - image: circleci/node:9-browsers
-
- node8browser: &node8browsersimage
- docker:
- - image: circleci/node:8-browsers
-
- node7browser: &node7browsersimage
- docker:
- - image: circleci/node:7-browsers
-
- install_npm_default: &install_npm
- run:
- name: Update npm
- command: 'sudo npm install -g npm@latest'
- restore_cache_default: &restore_cache # special step to restore the dependency cache
- restore_cache:
- # Read about caching dependencies: https://circleci.com/docs/2.0/caching/
- key: dependency-cache-{{ checksum "package.json" }}
- install_npm_packages_default: &install_npm_packages
- run:
- name: Install npm packages
- command: npm install
- save_cache_default: &save_cache # special step to save the dependency cache
- save_cache:
- key: dependency-cache-{{ checksum "package.json" }}
- paths:
- - ./node_modules
- update_realm_submodule_default: &update_realm_submodule
- run:
- name: Git Submodule Update
- command: git submodule update --init --recursive
-
-
-jobs:
-
- # Lint and Test
-
- lint_and_test_node_12: &lint_and_test
- <<: *node12image
- steps:
- - checkout
- - *update_realm_submodule
- - *install_npm
- - *restore_cache
- - *install_npm_packages
- - *save_cache
- - run: &lint
- name: Lint
- command: npm run lint-check
- - run: &test
- name: Test
- command: npm test
-
- lint_and_test_node_10:
- <<: *lint_and_test
- <<: *node10image
-
- lint_and_test_node_9:
- <<: *lint_and_test
- <<: *node9image
-
- lint_and_test_node_8:
- <<: *lint_and_test
- <<: *node8image
-
- lint_and_test_node_7:
- <<: *lint_and_test
- <<: *node7image
-
- # Pre-Release Test Integration
-
- pre_release_test_integration_node_11: &pre_release_test_integration
- <<: *node11browsersimage
- steps:
- - checkout
- - *update_realm_submodule
- - *install_npm
- - *restore_cache
- - *install_npm_packages
- - *save_cache
- - run:
- name: Build browser tests and bundle
- command: ./integration-test/scripts/build-pre-release-test.sh
- - run:
- name: Test bundles
- command: |
- cd integration-test
- npm run test:pre-release
-
- pre_release_test_integration_node_10:
- <<: *pre_release_test_integration
- <<: *node10browsersimage
-
- pre_release_test_integration_node_9:
- <<: *pre_release_test_integration
- <<: *node9browsersimage
-
- pre_release_test_integration_node_8:
- <<: *pre_release_test_integration
- <<: *node8browsersimage
-
- pre_release_test_integration_node_7:
- <<: *pre_release_test_integration
- <<: *node7browsersimage
-
- # Post-Release Test Integration
-
- post_release_test_integration_node_11: &post_release_test_integration
- <<: *node11browsersimage
- steps:
- - checkout
- - *update_realm_submodule
- - *install_npm
- - *restore_cache
- - *install_npm_packages
- - *save_cache
- - run:
- name: Build browser tests
- command: ./integration-test/scripts/build-post-release-test.sh
- - run:
- name: Test unpkg
- command: |
- cd integration-test
- npm run test:post-release
-
- post_release_test_integration_node_10:
- <<: *post_release_test_integration
- <<: *node10browsersimage
-
- post_release_test_integration_node_9:
- <<: *post_release_test_integration
- <<: *node9browsersimage
-
- post_release_test_integration_node_8:
- <<: *post_release_test_integration
- <<: *node8browsersimage
-
- post_release_test_integration_node_7:
- <<: *post_release_test_integration
- <<: *node7browsersimage
-
- npm_audit_node_12: &npm_audit
- docker:
- - image: circleci/node:12
- steps:
- - checkout
- - run:
- name: Update npm
- command: 'sudo npm install -g npm@latest'
- - run:
- name: install hub
- command: |
- set -xe
- go get -u -d github.com/github/hub
- cd /go/src/github.com/github/hub
- go install github.com/github/hub
- - run:
- name: Submit PR if npm audit fix makes changes
- command: ./scripts/npm-audit-fix.sh
-
-
-workflows:
- version: 2
- test_all:
- jobs:
- - lint_and_test_node_12
-# - lint_and_test_node_10
-# - pre_release_test_integration_node_11
-# - pre_release_test_integration_node_10
- nightly:
- triggers:
- - schedule:
- cron: "0 0 * * *"
- filters:
- branches:
- only:
- - master
- jobs:
- - npm_audit_node_12
-# - post_release_test_integration_node_11
-# - post_release_test_integration_node_10

DELETE
packages/make-importer/example/repairFunctionConstructors.js
-// Adapted from SES/Caja
-// Copyright (C) 2011 Google Inc.
-// https://github.com/google/caja/blob/master/src/com/google/caja/ses/startSES.js
-// https://github.com/google/caja/blob/master/src/com/google/caja/ses/repairES5.js
-
-/**
- * This block replaces the original Function constructor, and the original
- * %GeneratorFunction% %AsyncFunction% and %AsyncGeneratorFunction%, with
- * safe replacements that throw if invoked.
- *
- * These are all reachable via syntax, so it isn't sufficient to just
- * replace global properties with safe versions. Our main goal is to prevent
- * access to the Function constructor through these starting points.
- *
- * After this block is done, the originals must no longer be reachable, unless
- * a copy has been made, and funtions can only be created by syntax (using eval)
- * or by invoking a previously saved reference to the originals.
- */
-
-// todo: this file should be moved out to a separate repo and npm module.
-export function repairFunctionConstructors() {
- try {
- // Verify that the method is not callable.
- (0, Function.prototype.constructor)('return 1');
- } catch (ignore) {
- // Throws, no need to patch.
- return;
- }
-
- const { defineProperties, getPrototypeOf, setPrototypeOf } = Object;
-
- /**
- * The process to repair constructors:
- * 1. Create an instance of the function by evaluating syntax
- * 2. Obtain the prototype from the instance
- * 3. Create a substitute tamed constructor
- * 4. Replace the original constructor with the tamed constructor
- * 5. Replace tamed constructor prototype property with the original one
- * 6. Replace its [[Prototype]] slot with the tamed constructor of Function
- */
- function repairFunction(name, declaration) {
- let FunctionInstance;
- try {
- // eslint-disable-next-line no-eval
- FunctionInstance = (0, eval)(declaration);
- } catch (e) {
- if (e instanceof SyntaxError) {
- // Prevent failure on platforms where async and/or generators
- // are not supported.
- return;
- }
- // Re-throw
- throw e;
- }
- const FunctionPrototype = getPrototypeOf(FunctionInstance);
-
- // Prevents the evaluation of source when calling constructor on the
- // prototype of functions.
- // eslint-disable-next-line func-names
- const constructor = function() {
- throw new TypeError('Not available');
- };
- defineProperties(constructor, {
- name: {
- value: name,
- writable: false,
- enumerable: false,
- configurable: true,
- },
- toString: {
- value: () => `function ${name}() { [native code] }`,
- writable: false,
- enumerable: false,
- configurable: true,
- },
- });
-
- // (new Error()).constructors does not inherit from Function, because Error
- // was defined before ES6 classes. So we don't need to repair it too.
-
- // (Error()).constructor inherit from Function, which gets a tamed
- // constructor here.
-
- // todo: in an ES6 class that does not inherit from anything, what does its
- // constructor inherit from? We worry that it inherits from Function, in
- // which case instances could give access to unsafeFunction. markm says
- // we're fine: the constructor inherits from Object.prototype
-
- // This line replaces the original constructor in the prototype chain
- // with the tamed one. No copy of the original is peserved.
- defineProperties(FunctionPrototype, {
- constructor: { value: constructor },
- });
-
- // This line sets the tamed constructor's prototype data property to
- // the original one.
- defineProperties(constructor, {
- prototype: { value: FunctionPrototype },
- });
-
- // This line ensures that all functions meet "instanceof Function" in
- // a give realm.
- if (constructor !== Function.prototype.constructor) {
- setPrototypeOf(constructor, Function.prototype.constructor);
- }
- }
-
- // Here, the order of operation is important: Function needs to be repaired
- // first since the other repaired constructors need to inherit from the tamed
- // Function function constructor.
-
- // note: this really wants to be part of the standard, because new
- // constructors may be added in the future, reachable from syntax, and this
- // list must be updated to match.
-
- // "plain arrow functions" inherit from Function.prototype
-
- repairFunction('Function', '(function(){})');
- repairFunction('GeneratorFunction', '(function*(){})');
- repairFunction('AsyncFunction', '(async function(){})');
- repairFunction('AsyncGeneratorFunction', '(async function*(){})');
-}

DELETE
packages/make-importer/scripts/npm-audit-fix.sh
-git clone https://github.com/AgoricBot/make-importer.git
-cd make-importer
-git remote add upstream https://github.com/Agoric/make-importer.git
-git remote set-url origin https://AgoricBot:$GITHUB_TOKEN@github.com/AgoricBot/make-importer.git
-git fetch upstream
-git checkout master
-git rebase upstream/master
-git config user.email "kate+agoricbot@agoric.com"
-git config user.name "AgoricBot"
-git config --global hub.protocol https
-hub push origin master
-
-if git ls-remote --heads --exit-code origin npm-audit-fix ; then
- git push --delete origin npm-audit-fix
-fi
-
-git checkout -b npm-audit-fix
-
-if npm audit ; then
- echo "Nothing to fix"
-else
- npm audit fix
- files_changed=true
-fi
-
-if [ "$files_changed" = true ] ; then
- git add .
- git commit -m "results of running npm audit fix"
- git push origin npm-audit-fix
- hub pull-request --no-edit --base Agoric/make-importer:master
-fi

DELETE
packages/make-importer/scripts/setup-agoric-bot.md
-# AgoricBot
-
-AgoricBot is a github user that we've created to automatically create
-Pull Requests for anything that can be automatically fixed as a result
-of npm audit.
-
-# Setting up AgoricBot
-
-1. Sign in as AgoricBot on Github (see Kate for the password)
-2. Go to the github page for the Agoric repo that you have just
- created
-3. Fork the repo as AgoricBot
-4. Change npm-audit-fix.sh (in this folder) to use this forked repo
- and the actual Agoric repo instead of the '@REPO@' fillers
-5. On CircleCI (see setup-circleci.md in the root directory for more),
- go to your project's settings and look for 'Environmental
- Variables' under Build Settings
-6. Import the environmental variable from another repo, like SES. The
- variable should be named GITHUB_TOKEN and have a value that ends
- with "c166". (Note that the UI may not change once you have
- imported until you reload the page.)
-

Importer cleanup