Socket
Socket
Sign inDemoInstall

@microsoft/eslint-plugin-sdl

Package Overview
Dependencies
3
Maintainers
3
Versions
13
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @microsoft/eslint-plugin-sdl

ESLint plugin focused on common security issues and misconfigurations discoverable during static testing as part of Microsoft Security Development Lifecycle (SDL)


Version published
Weekly downloads
328K
decreased by-2.94%
Maintainers
3
Install size
6.32 MB
Created
Weekly downloads
 

Readme

Source

eslint-plugin-sdl

Node CI E2E integration

ESLint Plugin focused on common security issues and misconfigurations.

Plugin is intended as a baseline for projects that follow Microsoft Security Development Lifecycle (SDL) and use ESLint to perform Static Analysis Security Testing (SAST).

Installation

npm install microsoft/eslint-plugin-sdl

or

yarn add microsoft/eslint-plugin-sdl

Usage

When you run npm install within your project's root folder, the plugin will be added automatically to your package.json and package-lock.json files. You can also add the plugin to your package.json file manually by specifying the name and version number in the dependencies section like so:

"dependencies": {
    "@microsoft/eslint-plugin-sdl": "^0.1.9"
}

Run npm install within your root folder to install everything listed in the dependencies section of package.json. If the plugin is listed in your package.json dependencies, eslint will enforce all plugin rules using default settings.

Configs

Including an eslint configuration file in your project allows you to customize how eslint applies rules to your project. If you are using an .eslintrc file, you can include the plugin by adding:

plugins: ["@microsoft/eslint-plugin-sdl"]

Eslint will then only enforce rules you specify in the rules section of your .eslintrc file at the severity level you designate. The severity level options are 0 (no error), 1 (warning), and 2 (error). For example:

rules: {
  "no-eval": 2,
  "@microsoft/sdl/no-inner-html": 2
}

You can also used the below Shareable config files as guidelines depending on the type of project.

Plugin is shipped with following Shareable Configs:

  • angular - Set of rules for Angular applications
  • angularjs - Set of rules for AngularJS applications
  • common - Set of rules for common JavaScript applications
  • electron - Set of rules for Electron applications
  • node - Set of rules for Node applications
  • react - Set of rules for ReactJS applications
  • recommended - SDL Recommended rules for all applications
  • required - SDL Required rules for all applications
  • typescript - Set of rules for TypeScript applications

Rules

Where possible, we leverage existing rules from ESLint and community plugins such as react, typescript-eslint or security.

We also implemented several custom rules where we did not find sufficient alternative in the community.

NameDescription
no-callerBans usage of deprecated functions arguments.caller() and arguments.callee that could potentially allow access to call stack.
no-delete-varBans usage of operator delete on variables as it can lead to unexpected behavior.
no-evalBans usage of eval() that allows code execution from string argument.
no-implied-evalBans usage of setTimeout(), setInterval() and execScript(). These functions are similar to eval() and prone to code execution.
no-new-funcBans calling new Function() as it's similar to eval() and prone to code execution.
node/no-deprecated-apiBans usage of deprecated APIs in Node.
@microsoft/sdl/no-angular-bypass-sanitizerCalls to bypassSecurityTrustHtml, bypassSecurityTrustScript and similar methods bypass DomSanitizer in Angular and need to be reviewed.
@microsoft/sdl/no-angularjs-bypass-sceCalls to $sceProvider.enabled(false), $sceDelegate.trustAs(), $sce.trustAs() and relevant shorthand methods (e.g. trustAsHtml or trustAsJs) bypass Strict Contextual Escaping (SCE) in AngularJS and need to be reviewed.
@microsoft/sdl/no-angularjs-enable-svgCalls to $sanitizeProvider.enableSvg(true) increase attack surface of the application by enabling SVG support in AngularJS sanitizer and need to be reviewed.
@microsoft/sdl/no-angularjs-sanitization-whitelistCalls to $compileProvider.aHrefSanitizationWhitelist or $compileProvider.imgSrcSanitizationWhitelist configure whitelists in AngularJS sanitizer and need to be reviewed.
@microsoft/sdl/no-cookiesHTTP cookies are an old client-side storage mechanism with inherent risks and limitations. Use Web Storage, IndexedDB or other modern methods instead.
@microsoft/sdl/no-document-domainWrites to document.domain property must be reviewed to avoid bypass of same-origin checks. Usage of top level domains such as azurewebsites.net is strictly prohibited.
@microsoft/sdl/no-document-writeCalls to document.write or document.writeln manipulate DOM directly without any sanitization and should be avoided. Use document.createElement() or similar methods instead.
@microsoft/sdl/no-electron-node-integrationNode.js Integration must not be enabled in any renderer that loads remote content to avoid remote code execution attacks.
@microsoft/sdl/no-html-methodDirect calls to method html() often (e.g. in jQuery framework) manipulate DOM without any sanitization and should be avoided. Use document.createElement() or similar methods instead.
@microsoft/sdl/no-inner-htmlAssignments to innerHTML or outerHTML properties manipulate DOM directly without any sanitization and should be avoided. Use document.createElement() or similar methods instead.
@microsoft/sdl/no-insecure-urlInsecure protocols such as HTTP or FTP should be replaced by their encrypted counterparts (HTTPS, FTPS) to avoid sending potentially sensitive data over untrusted networks in plaintext.
@microsoft/sdl/no-msapp-exec-unsafeCalls to MSApp.execUnsafeLocalFunction() bypass script injection validation and should be avoided.
@microsoft/sdl/no-postmessage-star-originAlways provide specific target origin, not * when sending data to other windows using postMessage to avoid data leakage outside of trust boundary.
@microsoft/sdl/no-unsafe-allocWhen calling Buffer.allocUnsafe and Buffer.allocUnsafeSlow, the allocated memory is not wiped-out and can contain old, potentially sensitive data.
@microsoft/sdl/no-winjs-html-unsafeCalls to WinJS.Utilities.setInnerHTMLUnsafe() and similar methods do not perform any input validation and should be avoided. Use WinJS.Utilities.setInnerHTML() instead.
@microsoft/sdl/react-iframe-missing-sandboxThe sandbox attribute enables an extra set of restrictions for the content in the iframe and should always be specified.
react/no-dangerBans usage of dangerouslySetInnerHTML property in React as it allows passing unsanitized HTML in DOM.
@typescript-eslint/no-implied-evalSimilar to built-in ESLint rule no-implied-eval. Bans usage of setTimeout(), setInterval(), setImmediate(), execScript() or new Function() as they are similar to eval() and allow code execution from string arguments.

Contributing

This project welcomes contributions and suggestions. Most contributions require you to agree to a Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us the rights to use your contribution. For details, visit https://cla.opensource.microsoft.com.

When you submit a pull request, a CLA bot will automatically determine whether you need to provide a CLA and decorate the PR appropriately (e.g., status check, comment). Simply follow the instructions provided by the bot. You will only need to do this once across all repos using our CLA.

This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact opencode@microsoft.com with any additional questions or comments.

Keywords

FAQs

Last updated on 13 Nov 2023

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc