mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 17:59:23 -04:00
# Backport This will backport the following commits from `main` to `7.17`: - [Add test to ensure security related eslint rules are applied (#151434)](https://github.com/elastic/kibana/pull/151434) <!--- Backport version: 8.9.7 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sqren/backport) <!--BACKPORT [{"author":{"name":"Thomas Watson","email":"watson@elastic.co"},"sourceCommit":{"committedDate":"2023-02-24T15:48:11Z","message":"Add test to ensure security related eslint rules are applied (#151434)","sha":"e3dd7227e1cd48d420de849397f6ebed5e05bb6d","branchLabelMapping":{"^v8.8.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","backport:all-open","v8.8.0"],"number":151434,"url":"https://github.com/elastic/kibana/pull/151434","mergeCommit":{"message":"Add test to ensure security related eslint rules are applied (#151434)","sha":"e3dd7227e1cd48d420de849397f6ebed5e05bb6d"}},"sourceBranch":"main","suggestedTargetBranches":[],"targetPullRequestStates":[{"branch":"main","label":"v8.8.0","labelRegex":"^v8.8.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/151434","number":151434,"mergeCommit":{"message":"Add test to ensure security related eslint rules are applied (#151434)","sha":"e3dd7227e1cd48d420de849397f6ebed5e05bb6d"}}]}] BACKPORT-->
This commit is contained in:
parent
7e2c1dc2a1
commit
73983f0ed2
3 changed files with 79 additions and 0 deletions
|
@ -821,6 +821,11 @@ module.exports = {
|
|||
name: 'lodash/fp/assocPath',
|
||||
message: 'Please use @elastic/safer-lodash-set/fp/assocPath instead',
|
||||
},
|
||||
{
|
||||
name: 'lodash/fp/template',
|
||||
message:
|
||||
'lodash.template is unsafe, and not compatible with our content security policy.',
|
||||
},
|
||||
{
|
||||
name: 'lodash/template',
|
||||
message:
|
||||
|
|
73
src/dev/eslint/security_eslint_rule_tests.ts
Normal file
73
src/dev/eslint/security_eslint_rule_tests.ts
Normal file
|
@ -0,0 +1,73 @@
|
|||
/*
|
||||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
||||
* or more contributor license agreements. Licensed under the Elastic License
|
||||
* 2.0 and the Server Side Public License, v 1; you may not use this file except
|
||||
* in compliance with, at your election, the Elastic License 2.0 or the Server
|
||||
* Side Public License, v 1.
|
||||
*/
|
||||
|
||||
import * as a from 'lodash'; // eslint-disable-line no-restricted-imports
|
||||
import * as b from 'lodash/fp'; // eslint-disable-line no-restricted-imports
|
||||
|
||||
import { set as c } from 'lodash'; // eslint-disable-line no-restricted-imports
|
||||
import { setWith as d } from 'lodash'; // eslint-disable-line no-restricted-imports
|
||||
import { template as e } from 'lodash'; // eslint-disable-line no-restricted-imports
|
||||
|
||||
// The following import statements can't be tested because they are not in our package.json
|
||||
// import 'lodash.set'; // eslint-disable-line no-restricted-imports
|
||||
// import 'lodash.setWith'; // eslint-disable-line no-restricted-imports
|
||||
// import 'lodash.template'; // eslint-disable-line no-restricted-imports
|
||||
|
||||
import 'lodash/set'; // eslint-disable-line no-restricted-imports
|
||||
import 'lodash/setWith'; // eslint-disable-line no-restricted-imports
|
||||
import 'lodash/template'; // eslint-disable-line no-restricted-imports
|
||||
|
||||
import { set as f } from 'lodash/fp'; // eslint-disable-line no-restricted-imports
|
||||
import { setWith as g } from 'lodash/fp'; // eslint-disable-line no-restricted-imports
|
||||
import { assoc as h } from 'lodash/fp'; // eslint-disable-line no-restricted-imports
|
||||
import { assocPath as i } from 'lodash/fp'; // eslint-disable-line no-restricted-imports
|
||||
import { template as j } from 'lodash/fp'; // eslint-disable-line no-restricted-imports
|
||||
|
||||
import 'lodash/fp/set'; // eslint-disable-line no-restricted-imports
|
||||
import 'lodash/fp/setWith'; // eslint-disable-line no-restricted-imports
|
||||
import 'lodash/fp/assoc'; // eslint-disable-line no-restricted-imports
|
||||
import 'lodash/fp/assocPath'; // eslint-disable-line no-restricted-imports
|
||||
import 'lodash/fp/template'; // eslint-disable-line no-restricted-imports
|
||||
|
||||
// The following require statements can't be tested because they are not in our package.json
|
||||
// require('lodash.set'); // eslint-disable-line no-restricted-modules
|
||||
// require('lodash.setWith'); // eslint-disable-line no-restricted-modules
|
||||
// require('lodash.template'); // eslint-disable-line no-restricted-modules
|
||||
|
||||
require('lodash/set'); // eslint-disable-line no-restricted-modules
|
||||
require('lodash/setWith'); // eslint-disable-line no-restricted-modules
|
||||
require('lodash/template'); // eslint-disable-line no-restricted-modules
|
||||
|
||||
require('lodash/fp/set'); // eslint-disable-line no-restricted-modules
|
||||
require('lodash/fp/setWith'); // eslint-disable-line no-restricted-modules
|
||||
require('lodash/fp/assoc'); // eslint-disable-line no-restricted-modules
|
||||
require('lodash/fp/assocPath'); // eslint-disable-line no-restricted-modules
|
||||
require('lodash/fp/template'); // eslint-disable-line no-restricted-modules
|
||||
|
||||
const lodash = {
|
||||
set() {},
|
||||
setWith() {},
|
||||
assoc() {},
|
||||
assocPath() {},
|
||||
template() {},
|
||||
};
|
||||
lodash.set(); // eslint-disable-line no-restricted-properties
|
||||
lodash.setWith(); // eslint-disable-line no-restricted-properties
|
||||
lodash.assoc(); // eslint-disable-line no-restricted-properties
|
||||
lodash.assocPath(); // eslint-disable-line no-restricted-properties
|
||||
lodash.template(); // eslint-disable-line no-restricted-properties
|
||||
|
||||
const _ = lodash;
|
||||
_.set(); // eslint-disable-line no-restricted-properties
|
||||
_.setWith(); // eslint-disable-line no-restricted-properties
|
||||
_.assoc(); // eslint-disable-line no-restricted-properties
|
||||
_.assocPath(); // eslint-disable-line no-restricted-properties
|
||||
_.template(); // eslint-disable-line no-restricted-properties
|
||||
|
||||
// hack to ensure all imported variables are used
|
||||
module.exports = [a, b, c, d, e, f, g, h, i, j];
|
|
@ -11,6 +11,7 @@ const _ = require('lodash');
|
|||
// eslint-disable-next-line no-restricted-modules
|
||||
const template = require('lodash/template');
|
||||
const fp = require('lodash/fp');
|
||||
// eslint-disable-next-line no-restricted-modules
|
||||
const fpTemplate = require('lodash/fp/template');
|
||||
const test = require('tape');
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue