mozilla/eslint-plugin-no-unsanitized
소개
Custom ESLint rule to disallows unsafe innerHTML, outerHTML, insertAdjacentHTML and alike
보안 및 개인정보 보호측정된 스타 증가
- in 24h
- 0
- in 7 days
- 0
- in 15 days
- 0
- in 1 month
- 기록 수집 중
서로 겹치는 기간의 순증가량이며 일별 합계가 아닙니다. 측정값이 없으면 비워 둡니다. 스타는 관심도를 나타내며 품질을 보장하지 않습니다.
README.md
OriginalDisallow unsanitized code (no-unsanitized)
These rules disallow unsafe coding practices that may result into security
vulnerabilities. We will disallow assignments (e.g., to innerHTML) as well as
calls (e.g., to insertAdjacentHTML) without the use of a pre-defined escaping
function. The escaping functions must be called with a template string.
The function names are hardcoded as Sanitizer.escapeHTML and escapeHTML.
The plugin also supports the
Sanitizer API
and calls to .setHTML() are also allowed by default.
This plugin is built for and used within Mozilla to maintain and improve the security of our products and services.
Rule Details
method
The method rule disallows certain function calls.
E.g., document.write() or insertAdjacentHTML().
See docs/rules/method.md for more.
property
The property rule disallows certain assignment expressions, e.g., to innerHTML.
See docs/rules/property.md for more.
Examples
Here are a few examples of code that we do not want to allow:
foo.innerHTML = input.value;
bar.innerHTML = "<a href='" + url + "'>About</a>";
A few examples of allowed practices:
foo.innerHTML = 5;
bar.innerHTML = "<a href='/about.html'>About</a>";
bar.innerHTML = escapeHTML`<a href='${url}'>About</a>`;
Install
With yarn or npm:
$ yarn add -D eslint-plugin-no-unsanitized
$ npm install --save-dev eslint-plugin-no-unsanitized
Usage
import nounsanitized from "eslint-plugin-no-unsanitized";
export default config = [nounsanitized.configs.recommended];
or
import nounsanitized from "eslint-plugin-no-unsanitized";
export default config = [
{
files: ["**/*.js"],
plugins: { nounsanitized },
rules: {
"nounsanitized/method": "error",
"nounsanitized/property": "error",
},
},
];
Documentation
See docs/.
관련 프로젝트 살펴보기
불러오는 중…