Prevents dynamic import/require statements (#27515)
## Summary This PR enables the `import/no-dynamic-require` eslint rule, which requires that all require/import statements be statically defined. This mitigates certain attack vectors, such as those which enabled [`ESA-2018-18`](https://www.elastic.co/community/security)/[`CVE-2018-17246`](https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2018-17246)
This commit is contained in:
parent
e62db25d62
commit
22ba11eb52
|
@ -172,6 +172,7 @@ module.exports = {
|
||||||
'import/no-named-as-default': 'error',
|
'import/no-named-as-default': 'error',
|
||||||
'import/no-named-as-default-member': 'error',
|
'import/no-named-as-default-member': 'error',
|
||||||
'import/no-duplicates': 'error',
|
'import/no-duplicates': 'error',
|
||||||
|
'import/no-dynamic-require': 'error',
|
||||||
|
|
||||||
'prefer-object-spread/prefer-object-spread': 'error',
|
'prefer-object-spread/prefer-object-spread': 'error',
|
||||||
}
|
}
|
||||||
|
|
|
@ -55,7 +55,7 @@ exports.getPlugins = function(config, kibanaPath, projectRoot) {
|
||||||
return pluginsFromMap.concat(
|
return pluginsFromMap.concat(
|
||||||
glob.sync(globPatterns).map(pkgJsonPath => {
|
glob.sync(globPatterns).map(pkgJsonPath => {
|
||||||
const path = dirname(pkgJsonPath);
|
const path = dirname(pkgJsonPath);
|
||||||
const pkg = require(pkgJsonPath);
|
const pkg = require(pkgJsonPath); // eslint-disable-line import/no-dynamic-require
|
||||||
return {
|
return {
|
||||||
name: pkg.name,
|
name: pkg.name,
|
||||||
directory: path,
|
directory: path,
|
||||||
|
|
|
@ -57,7 +57,7 @@ export const populateServerRegistries = types => {
|
||||||
global.canvas.register = d => registries[type].register(d);
|
global.canvas.register = d => registries[type].register(d);
|
||||||
|
|
||||||
paths.forEach(path => {
|
paths.forEach(path => {
|
||||||
require(path);
|
require(path); // eslint-disable-line import/no-dynamic-require
|
||||||
});
|
});
|
||||||
|
|
||||||
Object.keys(global).forEach(key => {
|
Object.keys(global).forEach(key => {
|
||||||
|
|
|
@ -27,7 +27,7 @@ const chalk = require('chalk');
|
||||||
|
|
||||||
const pkg = require('../package.json');
|
const pkg = require('../package.json');
|
||||||
const kibanaPkgPath = require.resolve('../../../package.json');
|
const kibanaPkgPath = require.resolve('../../../package.json');
|
||||||
const kibanaPkg = require(kibanaPkgPath);
|
const kibanaPkg = require(kibanaPkgPath); // eslint-disable-line import/no-dynamic-require
|
||||||
|
|
||||||
const KBN_DIR = dirname(kibanaPkgPath);
|
const KBN_DIR = dirname(kibanaPkgPath);
|
||||||
|
|
||||||
|
|
|
@ -26,10 +26,10 @@ function babelRegister() {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// add support for moved babel-register source: https://github.com/elastic/kibana/pull/13973
|
// add support for moved babel-register source: https://github.com/elastic/kibana/pull/13973
|
||||||
require(resolve(plugin.kibanaRoot, 'src/setup_node_env/babel_register'));
|
require(resolve(plugin.kibanaRoot, 'src/setup_node_env/babel_register')); // eslint-disable-line import/no-dynamic-require
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
if (error.code === 'MODULE_NOT_FOUND') {
|
if (error.code === 'MODULE_NOT_FOUND') {
|
||||||
require(resolve(plugin.kibanaRoot, 'src/optimize/babel/register'));
|
require(resolve(plugin.kibanaRoot, 'src/optimize/babel/register')); // eslint-disable-line import/no-dynamic-require
|
||||||
} else {
|
} else {
|
||||||
throw error;
|
throw error;
|
||||||
}
|
}
|
||||||
|
@ -42,11 +42,8 @@ function resolveKibanaPath(path) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function readFtrConfigFile(log, path, settingOverrides) {
|
function readFtrConfigFile(log, path, settingOverrides) {
|
||||||
return require(resolveKibanaPath('src/functional_test_runner')).readConfigFile(
|
return require(resolveKibanaPath('src/functional_test_runner')) // eslint-disable-line import/no-dynamic-require
|
||||||
log,
|
.readConfigFile(log, path, settingOverrides);
|
||||||
path,
|
|
||||||
settingOverrides
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
|
|
|
@ -51,7 +51,7 @@ function removeSymlinkDependencies(root) {
|
||||||
|
|
||||||
// parse a ts config file
|
// parse a ts config file
|
||||||
function parseTsconfig(pluginSourcePath, configPath) {
|
function parseTsconfig(pluginSourcePath, configPath) {
|
||||||
const ts = require(path.join(pluginSourcePath, 'node_modules', 'typescript'));
|
const ts = require(path.join(pluginSourcePath, 'node_modules', 'typescript')); // eslint-disable-line import/no-dynamic-require
|
||||||
|
|
||||||
const { error, config } = ts.parseConfigFileTextToJson(
|
const { error, config } = ts.parseConfigFileTextToJson(
|
||||||
configPath,
|
configPath,
|
||||||
|
|
|
@ -42,7 +42,7 @@ describe('creating the build', () => {
|
||||||
|
|
||||||
await createBuild(PLUGIN, buildTarget, buildVersion, kibanaVersion, buildFiles);
|
await createBuild(PLUGIN, buildTarget, buildVersion, kibanaVersion, buildFiles);
|
||||||
|
|
||||||
const pkg = require(resolve(PLUGIN_BUILD_TARGET, 'package.json'));
|
const pkg = require(resolve(PLUGIN_BUILD_TARGET, 'package.json')); // eslint-disable-line import/no-dynamic-require
|
||||||
expect(pkg).not.toHaveProperty('scripts');
|
expect(pkg).not.toHaveProperty('scripts');
|
||||||
expect(pkg).not.toHaveProperty('devDependencies');
|
expect(pkg).not.toHaveProperty('devDependencies');
|
||||||
});
|
});
|
||||||
|
@ -52,7 +52,7 @@ describe('creating the build', () => {
|
||||||
|
|
||||||
await createBuild(PLUGIN, buildTarget, buildVersion, kibanaVersion, buildFiles);
|
await createBuild(PLUGIN, buildTarget, buildVersion, kibanaVersion, buildFiles);
|
||||||
|
|
||||||
const pkg = require(resolve(PLUGIN_BUILD_TARGET, 'package.json'));
|
const pkg = require(resolve(PLUGIN_BUILD_TARGET, 'package.json')); // eslint-disable-line import/no-dynamic-require
|
||||||
expect(pkg).toHaveProperty('build');
|
expect(pkg).toHaveProperty('build');
|
||||||
expect(pkg.build.git).not.toBeUndefined();
|
expect(pkg.build.git).not.toBeUndefined();
|
||||||
expect(pkg.build.date).not.toBeUndefined();
|
expect(pkg.build.date).not.toBeUndefined();
|
||||||
|
|
|
@ -25,7 +25,7 @@ import { createPlatform } from './platform';
|
||||||
|
|
||||||
export async function getConfig({ isRelease, targetAllPlatforms, versionQualifier }) {
|
export async function getConfig({ isRelease, targetAllPlatforms, versionQualifier }) {
|
||||||
const pkgPath = resolve(__dirname, '../../../../package.json');
|
const pkgPath = resolve(__dirname, '../../../../package.json');
|
||||||
const pkg = require(pkgPath);
|
const pkg = require(pkgPath); // eslint-disable-line import/no-dynamic-require
|
||||||
const repoRoot = dirname(pkgPath);
|
const repoRoot = dirname(pkgPath);
|
||||||
const nodeVersion = pkg.engines.node;
|
const nodeVersion = pkg.engines.node;
|
||||||
|
|
||||||
|
|
|
@ -25,7 +25,7 @@ import { transformDeprecations } from './transform_deprecations';
|
||||||
const cache = new WeakMap();
|
const cache = new WeakMap();
|
||||||
|
|
||||||
async function getSettingsFromFile(log, path, settingOverrides) {
|
async function getSettingsFromFile(log, path, settingOverrides) {
|
||||||
const configModule = require(path);
|
const configModule = require(path); // eslint-disable-line import/no-dynamic-require
|
||||||
const configProvider = configModule.__esModule
|
const configProvider = configModule.__esModule
|
||||||
? configModule.default
|
? configModule.default
|
||||||
: configModule;
|
: configModule;
|
||||||
|
|
|
@ -48,7 +48,7 @@ export const loadTestFiles = ({ mocha, log, lifecycle, providers, paths, exclude
|
||||||
loadTracer(path, `testFile[${path}]`, () => {
|
loadTracer(path, `testFile[${path}]`, () => {
|
||||||
log.verbose('Loading test file %s', path);
|
log.verbose('Loading test file %s', path);
|
||||||
|
|
||||||
const testModule = require(path);
|
const testModule = require(path); // eslint-disable-line import/no-dynamic-require
|
||||||
const testProvider = testModule.__esModule
|
const testProvider = testModule.__esModule
|
||||||
? testModule.default
|
? testModule.default
|
||||||
: testModule;
|
: testModule;
|
||||||
|
|
|
@ -27,7 +27,7 @@ export function resolveApi(senseVersion, apis, h) {
|
||||||
{
|
{
|
||||||
if (KNOWN_APIS.includes(name)) {
|
if (KNOWN_APIS.includes(name)) {
|
||||||
// for now we ignore sense_version. might add it in the api name later
|
// for now we ignore sense_version. might add it in the api name later
|
||||||
const api = require('./' + name);
|
const api = require('./' + name); // eslint-disable-line import/no-dynamic-require
|
||||||
result[name] = api.asJson();
|
result[name] = api.asJson();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,13 +17,12 @@
|
||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
const filename = require('path').basename(__filename);
|
const fn = require(`../average`);
|
||||||
const fn = require(`../${filename}`);
|
|
||||||
import moment from 'moment';
|
import moment from 'moment';
|
||||||
const expect = require('chai').expect;
|
const expect = require('chai').expect;
|
||||||
import _ from 'lodash';
|
import _ from 'lodash';
|
||||||
|
|
||||||
describe(filename, function () {
|
describe('average.js', function () {
|
||||||
|
|
||||||
describe('average', function () {
|
describe('average', function () {
|
||||||
it('fills holes in the data', function () {
|
it('fills holes in the data', function () {
|
||||||
|
|
|
@ -17,13 +17,12 @@
|
||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
const filename = require('path').basename(__filename);
|
const fn = require(`../carry`);
|
||||||
const fn = require(`../${filename}`);
|
|
||||||
import moment from 'moment';
|
import moment from 'moment';
|
||||||
const expect = require('chai').expect;
|
const expect = require('chai').expect;
|
||||||
import _ from 'lodash';
|
import _ from 'lodash';
|
||||||
|
|
||||||
describe(filename, function () {
|
describe('carry.js', function () {
|
||||||
it('fills holes in the data', function () {
|
it('fills holes in the data', function () {
|
||||||
const data = [
|
const data = [
|
||||||
[moment.utc('1980', 'YYYY').valueOf(), 10],
|
[moment.utc('1980', 'YYYY').valueOf(), 10],
|
||||||
|
|
|
@ -17,12 +17,11 @@
|
||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
const filename = require('path').basename(__filename);
|
const fn = require(`../load_functions`);
|
||||||
const fn = require(`../${filename}`);
|
|
||||||
|
|
||||||
const expect = require('chai').expect;
|
const expect = require('chai').expect;
|
||||||
|
|
||||||
describe(filename, () => {
|
describe('load_functions.js', () => {
|
||||||
it('exports a function', () => {
|
it('exports a function', () => {
|
||||||
expect(fn).to.be.a('function');
|
expect(fn).to.be.a('function');
|
||||||
});
|
});
|
||||||
|
|
|
@ -25,7 +25,7 @@ import processFunctionDefinition from './process_function_definition';
|
||||||
export default function (directory) {
|
export default function (directory) {
|
||||||
|
|
||||||
function getTuple(directory, name) {
|
function getTuple(directory, name) {
|
||||||
return [name, require('../' + directory + '/' + name)];
|
return [name, require('../' + directory + '/' + name)]; // eslint-disable-line import/no-dynamic-require
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get a list of all files and use the filename as the object key
|
// Get a list of all files and use the filename as the object key
|
||||||
|
|
|
@ -17,15 +17,14 @@
|
||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
const filename = require('path').basename(__filename);
|
const fn = require(`../abs`);
|
||||||
const fn = require(`../${filename}`);
|
|
||||||
|
|
||||||
import _ from 'lodash';
|
import _ from 'lodash';
|
||||||
const expect = require('chai').expect;
|
const expect = require('chai').expect;
|
||||||
const seriesList = require('./fixtures/seriesList.js')();
|
const seriesList = require('./fixtures/seriesList.js')();
|
||||||
import invoke from './helpers/invoke_series_fn.js';
|
import invoke from './helpers/invoke_series_fn.js';
|
||||||
|
|
||||||
describe(filename, function () {
|
describe('abs.js', function () {
|
||||||
it('should return the positive value of every value', function () {
|
it('should return the positive value of every value', function () {
|
||||||
|
|
||||||
return invoke(fn, [seriesList]).then(function (result) {
|
return invoke(fn, [seriesList]).then(function (result) {
|
||||||
|
|
|
@ -17,14 +17,13 @@
|
||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
const filename = require('path').basename(__filename);
|
const fn = require(`../bars`);
|
||||||
const fn = require(`../${filename}`);
|
|
||||||
|
|
||||||
import _ from 'lodash';
|
import _ from 'lodash';
|
||||||
const expect = require('chai').expect;
|
const expect = require('chai').expect;
|
||||||
import invoke from './helpers/invoke_series_fn.js';
|
import invoke from './helpers/invoke_series_fn.js';
|
||||||
|
|
||||||
describe(filename, () => {
|
describe('bars.js', () => {
|
||||||
|
|
||||||
let seriesList;
|
let seriesList;
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
|
|
|
@ -17,14 +17,13 @@
|
||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
const filename = require('path').basename(__filename);
|
const fn = require(`../color`);
|
||||||
const fn = require(`../${filename}`);
|
|
||||||
|
|
||||||
import _ from 'lodash';
|
import _ from 'lodash';
|
||||||
const expect = require('chai').expect;
|
const expect = require('chai').expect;
|
||||||
import invoke from './helpers/invoke_series_fn.js';
|
import invoke from './helpers/invoke_series_fn.js';
|
||||||
|
|
||||||
describe(filename, () => {
|
describe('color.js', () => {
|
||||||
|
|
||||||
let seriesList;
|
let seriesList;
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
|
|
|
@ -17,15 +17,14 @@
|
||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
const filename = require('path').basename(__filename);
|
const fn = require(`../condition`);
|
||||||
const fn = require(`../${filename}`);
|
|
||||||
import moment from 'moment';
|
import moment from 'moment';
|
||||||
const expect = require('chai').expect;
|
const expect = require('chai').expect;
|
||||||
import invoke from './helpers/invoke_series_fn.js';
|
import invoke from './helpers/invoke_series_fn.js';
|
||||||
import getSeriesList from './helpers/get_single_series_list';
|
import getSeriesList from './helpers/get_single_series_list';
|
||||||
import _ from 'lodash';
|
import _ from 'lodash';
|
||||||
|
|
||||||
describe(filename, function () {
|
describe('condition.js', function () {
|
||||||
|
|
||||||
let comparable;
|
let comparable;
|
||||||
let seriesList;
|
let seriesList;
|
||||||
|
|
|
@ -17,14 +17,13 @@
|
||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
const filename = require('path').basename(__filename);
|
const fn = require(`../cusum`);
|
||||||
const fn = require(`../${filename}`);
|
|
||||||
|
|
||||||
import _ from 'lodash';
|
import _ from 'lodash';
|
||||||
const expect = require('chai').expect;
|
const expect = require('chai').expect;
|
||||||
import invoke from './helpers/invoke_series_fn.js';
|
import invoke from './helpers/invoke_series_fn.js';
|
||||||
|
|
||||||
describe(filename, () => {
|
describe('cusum.js', () => {
|
||||||
|
|
||||||
let seriesList;
|
let seriesList;
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
|
|
|
@ -17,14 +17,13 @@
|
||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
const filename = require('path').basename(__filename);
|
const fn = require(`../derivative`);
|
||||||
const fn = require(`../${filename}`);
|
|
||||||
|
|
||||||
import _ from 'lodash';
|
import _ from 'lodash';
|
||||||
const expect = require('chai').expect;
|
const expect = require('chai').expect;
|
||||||
import invoke from './helpers/invoke_series_fn.js';
|
import invoke from './helpers/invoke_series_fn.js';
|
||||||
|
|
||||||
describe(filename, () => {
|
describe('derivative.js', () => {
|
||||||
|
|
||||||
let seriesList;
|
let seriesList;
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
|
|
|
@ -17,14 +17,13 @@
|
||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
const filename = require('path').basename(__filename);
|
const fn = require(`../divide`);
|
||||||
const fn = require(`../${filename}`);
|
|
||||||
|
|
||||||
import _ from 'lodash';
|
import _ from 'lodash';
|
||||||
const expect = require('chai').expect;
|
const expect = require('chai').expect;
|
||||||
import invoke from './helpers/invoke_series_fn.js';
|
import invoke from './helpers/invoke_series_fn.js';
|
||||||
|
|
||||||
describe(filename, () => {
|
describe('divide.js', () => {
|
||||||
|
|
||||||
let seriesList;
|
let seriesList;
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
|
|
|
@ -17,14 +17,13 @@
|
||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
const filename = require('path').basename(__filename);
|
const fn = require(`../first`);
|
||||||
const fn = require(`../${filename}`);
|
|
||||||
|
|
||||||
const expect = require('chai').expect;
|
const expect = require('chai').expect;
|
||||||
const seriesList = require('./fixtures/seriesList.js')();
|
const seriesList = require('./fixtures/seriesList.js')();
|
||||||
import invoke from './helpers/invoke_series_fn.js';
|
import invoke from './helpers/invoke_series_fn.js';
|
||||||
|
|
||||||
describe(filename, function () {
|
describe('first.js', function () {
|
||||||
it('should return exactly the data input', function () {
|
it('should return exactly the data input', function () {
|
||||||
return invoke(fn, [seriesList]).then(function (result) {
|
return invoke(fn, [seriesList]).then(function (result) {
|
||||||
expect(result.input[0]).to.eql(result.output);
|
expect(result.input[0]).to.eql(result.output);
|
||||||
|
|
|
@ -17,15 +17,14 @@
|
||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
const filename = require('path').basename(__filename);
|
const fn = require(`../fit`);
|
||||||
const fn = require(`../${filename}`);
|
|
||||||
import moment from 'moment';
|
import moment from 'moment';
|
||||||
const expect = require('chai').expect;
|
const expect = require('chai').expect;
|
||||||
import invoke from './helpers/invoke_series_fn.js';
|
import invoke from './helpers/invoke_series_fn.js';
|
||||||
import getSeriesList from './helpers/get_single_series_list';
|
import getSeriesList from './helpers/get_single_series_list';
|
||||||
import _ from 'lodash';
|
import _ from 'lodash';
|
||||||
|
|
||||||
describe(filename, function () {
|
describe('fit.js', function () {
|
||||||
|
|
||||||
describe('should not filter out zeros', function () {
|
describe('should not filter out zeros', function () {
|
||||||
it('all zeros', function () {
|
it('all zeros', function () {
|
||||||
|
|
|
@ -17,14 +17,13 @@
|
||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
const filename = require('path').basename(__filename);
|
const fn = require(`../hide`);
|
||||||
const fn = require(`../${filename}`);
|
|
||||||
|
|
||||||
import _ from 'lodash';
|
import _ from 'lodash';
|
||||||
const expect = require('chai').expect;
|
const expect = require('chai').expect;
|
||||||
import invoke from './helpers/invoke_series_fn.js';
|
import invoke from './helpers/invoke_series_fn.js';
|
||||||
|
|
||||||
describe(filename, () => {
|
describe('hide.js', () => {
|
||||||
|
|
||||||
let seriesList;
|
let seriesList;
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
|
|
|
@ -17,14 +17,13 @@
|
||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
const filename = require('path').basename(__filename);
|
const fn = require(`../label`);
|
||||||
const fn = require(`../${filename}`);
|
|
||||||
|
|
||||||
import _ from 'lodash';
|
import _ from 'lodash';
|
||||||
const expect = require('chai').expect;
|
const expect = require('chai').expect;
|
||||||
import invoke from './helpers/invoke_series_fn.js';
|
import invoke from './helpers/invoke_series_fn.js';
|
||||||
|
|
||||||
describe(filename, () => {
|
describe('label.js', () => {
|
||||||
|
|
||||||
let seriesList;
|
let seriesList;
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
|
|
|
@ -17,13 +17,12 @@
|
||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
const filename = require('path').basename(__filename);
|
const fn = require(`../legend`);
|
||||||
const fn = require(`../${filename}`);
|
|
||||||
|
|
||||||
const expect = require('chai').expect;
|
const expect = require('chai').expect;
|
||||||
import invoke from './helpers/invoke_series_fn.js';
|
import invoke from './helpers/invoke_series_fn.js';
|
||||||
|
|
||||||
describe(filename, () => {
|
describe('legend.js', () => {
|
||||||
|
|
||||||
let seriesList;
|
let seriesList;
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
|
|
|
@ -17,13 +17,12 @@
|
||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
const filename = require('path').basename(__filename);
|
const fn = require(`../lines`);
|
||||||
const fn = require(`../${filename}`);
|
|
||||||
|
|
||||||
const expect = require('chai').expect;
|
const expect = require('chai').expect;
|
||||||
import invoke from './helpers/invoke_series_fn.js';
|
import invoke from './helpers/invoke_series_fn.js';
|
||||||
|
|
||||||
describe(filename, () => {
|
describe('lines.js', () => {
|
||||||
|
|
||||||
let seriesList;
|
let seriesList;
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
|
|
|
@ -17,14 +17,13 @@
|
||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
const filename = require('path').basename(__filename);
|
const fn = require(`../log`);
|
||||||
const fn = require(`../${filename}`);
|
|
||||||
|
|
||||||
import _ from 'lodash';
|
import _ from 'lodash';
|
||||||
const expect = require('chai').expect;
|
const expect = require('chai').expect;
|
||||||
import invoke from './helpers/invoke_series_fn.js';
|
import invoke from './helpers/invoke_series_fn.js';
|
||||||
|
|
||||||
describe(filename, () => {
|
describe('log.js', () => {
|
||||||
|
|
||||||
let seriesList;
|
let seriesList;
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
|
|
|
@ -17,14 +17,13 @@
|
||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
const filename = require('path').basename(__filename);
|
const fn = require(`../max`);
|
||||||
const fn = require(`../${filename}`);
|
|
||||||
|
|
||||||
import _ from 'lodash';
|
import _ from 'lodash';
|
||||||
const expect = require('chai').expect;
|
const expect = require('chai').expect;
|
||||||
import invoke from './helpers/invoke_series_fn.js';
|
import invoke from './helpers/invoke_series_fn.js';
|
||||||
|
|
||||||
describe(filename, () => {
|
describe('max.js', () => {
|
||||||
|
|
||||||
let seriesList;
|
let seriesList;
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
|
|
|
@ -17,14 +17,13 @@
|
||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
const filename = require('path').basename(__filename);
|
const fn = require(`../min`);
|
||||||
const fn = require(`../${filename}`);
|
|
||||||
|
|
||||||
import _ from 'lodash';
|
import _ from 'lodash';
|
||||||
const expect = require('chai').expect;
|
const expect = require('chai').expect;
|
||||||
import invoke from './helpers/invoke_series_fn.js';
|
import invoke from './helpers/invoke_series_fn.js';
|
||||||
|
|
||||||
describe(filename, () => {
|
describe('min.js', () => {
|
||||||
|
|
||||||
let seriesList;
|
let seriesList;
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
|
|
|
@ -17,8 +17,7 @@
|
||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
const filename = require('path').basename(__filename);
|
const fn = require(`../movingaverage`);
|
||||||
const fn = require(`../${filename}`);
|
|
||||||
const expect = require('chai').expect;
|
const expect = require('chai').expect;
|
||||||
|
|
||||||
import moment from 'moment';
|
import moment from 'moment';
|
||||||
|
@ -34,7 +33,7 @@ function getFivePointSeries() {
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
describe(filename, () => {
|
describe('movingaverage.js', () => {
|
||||||
|
|
||||||
let seriesList;
|
let seriesList;
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
|
|
|
@ -17,8 +17,7 @@
|
||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
const filename = require('path').basename(__filename);
|
const fn = require(`../movingstd`);
|
||||||
const fn = require(`../${filename}`);
|
|
||||||
|
|
||||||
import moment from 'moment';
|
import moment from 'moment';
|
||||||
const expect = require('chai').expect;
|
const expect = require('chai').expect;
|
||||||
|
@ -26,7 +25,7 @@ import invoke from './helpers/invoke_series_fn.js';
|
||||||
import getSeries from './helpers/get_series';
|
import getSeries from './helpers/get_series';
|
||||||
import getSeriesList from './helpers/get_series_list';
|
import getSeriesList from './helpers/get_series_list';
|
||||||
|
|
||||||
describe(filename, () => {
|
describe('movingstd.js', () => {
|
||||||
|
|
||||||
it('computes the moving standard deviation of a list', async () => {
|
it('computes the moving standard deviation of a list', async () => {
|
||||||
const points = [
|
const points = [
|
||||||
|
|
|
@ -17,14 +17,13 @@
|
||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
const filename = require('path').basename(__filename);
|
const fn = require(`../multiply`);
|
||||||
const fn = require(`../${filename}`);
|
|
||||||
|
|
||||||
import _ from 'lodash';
|
import _ from 'lodash';
|
||||||
const expect = require('chai').expect;
|
const expect = require('chai').expect;
|
||||||
import invoke from './helpers/invoke_series_fn.js';
|
import invoke from './helpers/invoke_series_fn.js';
|
||||||
|
|
||||||
describe(filename, () => {
|
describe('multiply.js', () => {
|
||||||
|
|
||||||
let seriesList;
|
let seriesList;
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
|
|
|
@ -17,15 +17,14 @@
|
||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
const filename = require('path').basename(__filename);
|
const fn = require(`../points`);
|
||||||
const fn = require(`../${filename}`);
|
|
||||||
|
|
||||||
import _ from 'lodash';
|
import _ from 'lodash';
|
||||||
import assert from 'chai';
|
import assert from 'chai';
|
||||||
const expect = assert.expect;
|
const expect = assert.expect;
|
||||||
import invoke from './helpers/invoke_series_fn.js';
|
import invoke from './helpers/invoke_series_fn.js';
|
||||||
|
|
||||||
describe(filename, () => {
|
describe('points.js', () => {
|
||||||
|
|
||||||
let seriesList;
|
let seriesList;
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
|
|
|
@ -17,14 +17,13 @@
|
||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
const filename = require('path').basename(__filename);
|
const fn = require(`../precision`);
|
||||||
const fn = require(`../${filename}`);
|
|
||||||
|
|
||||||
import _ from 'lodash';
|
import _ from 'lodash';
|
||||||
const expect = require('chai').expect;
|
const expect = require('chai').expect;
|
||||||
import invoke from './helpers/invoke_series_fn.js';
|
import invoke from './helpers/invoke_series_fn.js';
|
||||||
|
|
||||||
describe(filename, () => {
|
describe('precision.js', () => {
|
||||||
|
|
||||||
let seriesList;
|
let seriesList;
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
|
|
|
@ -17,14 +17,13 @@
|
||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
const filename = require('path').basename(__filename);
|
const fn = require(`../range`);
|
||||||
const fn = require(`../${filename}`);
|
|
||||||
|
|
||||||
import _ from 'lodash';
|
import _ from 'lodash';
|
||||||
const expect = require('chai').expect;
|
const expect = require('chai').expect;
|
||||||
import invoke from './helpers/invoke_series_fn.js';
|
import invoke from './helpers/invoke_series_fn.js';
|
||||||
|
|
||||||
describe(filename, () => {
|
describe('range.js', () => {
|
||||||
|
|
||||||
let seriesList;
|
let seriesList;
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
|
|
|
@ -17,14 +17,13 @@
|
||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
const filename = require('path').basename(__filename);
|
const fn = require(`../scale_interval`);
|
||||||
const fn = require(`../${filename}`);
|
|
||||||
|
|
||||||
import _ from 'lodash';
|
import _ from 'lodash';
|
||||||
const expect = require('chai').expect;
|
const expect = require('chai').expect;
|
||||||
import invoke from './helpers/invoke_series_fn.js';
|
import invoke from './helpers/invoke_series_fn.js';
|
||||||
|
|
||||||
describe(filename, () => {
|
describe('scale_interval.js', () => {
|
||||||
|
|
||||||
let seriesList;
|
let seriesList;
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
|
|
|
@ -17,14 +17,13 @@
|
||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
const filename = require('path').basename(__filename);
|
const fn = require(`../static`);
|
||||||
const fn = require(`../${filename}`);
|
|
||||||
|
|
||||||
import _ from 'lodash';
|
import _ from 'lodash';
|
||||||
const expect = require('chai').expect;
|
const expect = require('chai').expect;
|
||||||
import invoke from './helpers/invoke_series_fn.js';
|
import invoke from './helpers/invoke_series_fn.js';
|
||||||
|
|
||||||
describe(filename, () => {
|
describe('static.js', () => {
|
||||||
it('returns a series in which all numbers are the same', () => {
|
it('returns a series in which all numbers are the same', () => {
|
||||||
return invoke(fn, [5]).then((r) => {
|
return invoke(fn, [5]).then((r) => {
|
||||||
expect(_.unique(_.map(r.output.list[0].data, 1))).to.eql([5]);
|
expect(_.unique(_.map(r.output.list[0].data, 1))).to.eql([5]);
|
||||||
|
|
|
@ -17,14 +17,13 @@
|
||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
const filename = require('path').basename(__filename);
|
const fn = require(`../subtract`);
|
||||||
const fn = require(`../${filename}`);
|
|
||||||
|
|
||||||
import _ from 'lodash';
|
import _ from 'lodash';
|
||||||
const expect = require('chai').expect;
|
const expect = require('chai').expect;
|
||||||
import invoke from './helpers/invoke_series_fn.js';
|
import invoke from './helpers/invoke_series_fn.js';
|
||||||
|
|
||||||
describe(filename, () => {
|
describe('subtract.js', () => {
|
||||||
|
|
||||||
let seriesList;
|
let seriesList;
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
|
|
|
@ -17,14 +17,13 @@
|
||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
const filename = require('path').basename(__filename);
|
const fn = require(`../sum`);
|
||||||
const fn = require(`../${filename}`);
|
|
||||||
|
|
||||||
import _ from 'lodash';
|
import _ from 'lodash';
|
||||||
const expect = require('chai').expect;
|
const expect = require('chai').expect;
|
||||||
import invoke from './helpers/invoke_series_fn.js';
|
import invoke from './helpers/invoke_series_fn.js';
|
||||||
|
|
||||||
describe(filename, () => {
|
describe('sum.js', () => {
|
||||||
|
|
||||||
let seriesList;
|
let seriesList;
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
|
|
|
@ -17,14 +17,13 @@
|
||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
const filename = require('path').basename(__filename);
|
const fn = require(`../title`);
|
||||||
const fn = require(`../${filename}`);
|
|
||||||
|
|
||||||
import _ from 'lodash';
|
import _ from 'lodash';
|
||||||
const expect = require('chai').expect;
|
const expect = require('chai').expect;
|
||||||
import invoke from './helpers/invoke_series_fn.js';
|
import invoke from './helpers/invoke_series_fn.js';
|
||||||
|
|
||||||
describe(filename, () => {
|
describe('title.js', () => {
|
||||||
|
|
||||||
let seriesList;
|
let seriesList;
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
|
|
|
@ -17,14 +17,13 @@
|
||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
const filename = require('path').basename(__filename);
|
const fn = require(`../trim`);
|
||||||
const fn = require(`../${filename}`);
|
|
||||||
|
|
||||||
import _ from 'lodash';
|
import _ from 'lodash';
|
||||||
const expect = require('chai').expect;
|
const expect = require('chai').expect;
|
||||||
import invoke from './helpers/invoke_series_fn.js';
|
import invoke from './helpers/invoke_series_fn.js';
|
||||||
|
|
||||||
describe(filename, () => {
|
describe('trim.js', () => {
|
||||||
|
|
||||||
let seriesList;
|
let seriesList;
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
|
|
|
@ -17,13 +17,12 @@
|
||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
const filename = require('path').basename(__filename);
|
const fn = require(`../yaxis`);
|
||||||
const fn = require(`../${filename}`);
|
|
||||||
import Promise from 'bluebird';
|
import Promise from 'bluebird';
|
||||||
const expect = require('chai').expect;
|
const expect = require('chai').expect;
|
||||||
import invoke from './helpers/invoke_series_fn.js';
|
import invoke from './helpers/invoke_series_fn.js';
|
||||||
|
|
||||||
describe(filename, () => {
|
describe('yaxis.js', () => {
|
||||||
let seriesList;
|
let seriesList;
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
seriesList = require('./fixtures/seriesList.js')();
|
seriesList = require('./fixtures/seriesList.js')();
|
||||||
|
|
|
@ -22,7 +22,7 @@ import { map, catchError } from 'rxjs/operators';
|
||||||
import { createInvalidPackError } from '../errors';
|
import { createInvalidPackError } from '../errors';
|
||||||
|
|
||||||
function createPack(packageJson) {
|
function createPack(packageJson) {
|
||||||
let provider = require(packageJson.directoryPath);
|
let provider = require(packageJson.directoryPath); // eslint-disable-line import/no-dynamic-require
|
||||||
if (provider.__esModule) {
|
if (provider.__esModule) {
|
||||||
provider = provider.default;
|
provider = provider.default;
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,7 +23,7 @@ import * as kbnTestServer from '../../../test_utils/kbn_server';
|
||||||
const src = resolve.bind(null, __dirname, '../../../../src');
|
const src = resolve.bind(null, __dirname, '../../../../src');
|
||||||
|
|
||||||
const versionHeader = 'kbn-version';
|
const versionHeader = 'kbn-version';
|
||||||
const version = require(src('../package.json')).version;
|
const version = require(src('../package.json')).version; // eslint-disable-line import/no-dynamic-require
|
||||||
|
|
||||||
describe('version_check request filter', function () {
|
describe('version_check request filter', function () {
|
||||||
let root;
|
let root;
|
||||||
|
|
|
@ -27,7 +27,7 @@ const xsrfHeader = 'kbn-xsrf';
|
||||||
const versionHeader = 'kbn-version';
|
const versionHeader = 'kbn-version';
|
||||||
const testPath = '/xsrf/test/route';
|
const testPath = '/xsrf/test/route';
|
||||||
const whitelistedTestPath = '/xsrf/test/route/whitelisted';
|
const whitelistedTestPath = '/xsrf/test/route/whitelisted';
|
||||||
const actualVersion = require(src('../package.json')).version;
|
const actualVersion = require(src('../package.json')).version; // eslint-disable-line import/no-dynamic-require
|
||||||
|
|
||||||
describe('xsrf request filter', () => {
|
describe('xsrf request filter', () => {
|
||||||
let root;
|
let root;
|
||||||
|
|
|
@ -20,7 +20,7 @@ async function listFiles() {
|
||||||
const pattern = resolve(__dirname, './apis/*/index.js');
|
const pattern = resolve(__dirname, './apis/*/index.js');
|
||||||
const files = await scan(pattern);
|
const files = await scan(pattern);
|
||||||
files.forEach(file => {
|
files.forEach(file => {
|
||||||
const { name, description } = require(file);
|
const { name, description } = require(file); // eslint-disable-line import/no-dynamic-require
|
||||||
console.log(' ' + bold(`node ${argv.$0} ${name}`));
|
console.log(' ' + bold(`node ${argv.$0} ${name}`));
|
||||||
console.log(` ${description}`);
|
console.log(` ${description}`);
|
||||||
});
|
});
|
||||||
|
|
|
@ -56,7 +56,7 @@ function prettyPrintJson(json) {
|
||||||
|
|
||||||
export async function requestFromApi(argv, requestType) {
|
export async function requestFromApi(argv, requestType) {
|
||||||
const pattern = resolve(__dirname, `./apis/${requestType}/index.js`);
|
const pattern = resolve(__dirname, `./apis/${requestType}/index.js`);
|
||||||
const { method, path, body } = require(pattern);
|
const { method, path, body } = require(pattern); // eslint-disable-line import/no-dynamic-require
|
||||||
const { host, auth, basePath } = getRequestParams(argv);
|
const { host, auth, basePath } = getRequestParams(argv);
|
||||||
if (argv.k || !argv.ssl) {
|
if (argv.k || !argv.ssl) {
|
||||||
setIgnoreSSLErrors();
|
setIgnoreSSLErrors();
|
||||||
|
|
|
@ -15,5 +15,5 @@ exports.runGulpTask = function(name) {
|
||||||
exports.runKibanaScript = function(name, args = []) {
|
exports.runKibanaScript = function(name, args = []) {
|
||||||
process.chdir(resolve(__dirname, '../../../..'));
|
process.chdir(resolve(__dirname, '../../../..'));
|
||||||
process.argv.splice(2, 0, ...args);
|
process.argv.splice(2, 0, ...args);
|
||||||
require('../../../../scripts/' + name);
|
require('../../../../scripts/' + name); // eslint-disable-line import/no-dynamic-require
|
||||||
};
|
};
|
||||||
|
|
|
@ -28,7 +28,7 @@ async function exportTypesRegistryFn(server) {
|
||||||
files.forEach(file => {
|
files.forEach(file => {
|
||||||
server.log(['reporting', 'debug', 'exportTypes'], `Found exportType at ${file}`);
|
server.log(['reporting', 'debug', 'exportTypes'], `Found exportType at ${file}`);
|
||||||
|
|
||||||
const { register } = require(file);
|
const { register } = require(file); // eslint-disable-line import/no-dynamic-require
|
||||||
register(exportTypesRegistry);
|
register(exportTypesRegistry);
|
||||||
});
|
});
|
||||||
return exportTypesRegistry;
|
return exportTypesRegistry;
|
||||||
|
|
Loading…
Reference in a new issue