# sql-inject-reject

> HTTP server middleware for detecting and rejecting SQL injection attempts

Latest version **0.1.0** (published 2018-06-20) · MIT license · 0 weekly downloads

## Install

```sh
npm install sql-inject-reject
pnpm add sql-inject-reject
yarn add sql-inject-reject
bun add sql-inject-reject
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.0 |
| Published | 2018-06-20 |
| First published | 2018-06-20 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Unpacked size | 76.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 2 |
| Author | Phil Sautter |
| Maintainers | redeux |
| Keywords | SQL, SQL Injection, Middleware, HTTP, Server, Express, Inject, Security |

## Links

- npm: https://www.npmjs.com/package/sql-inject-reject
- Repository: https://github.com/Redeux/sql-inject-reject
- Homepage: https://github.com/Redeux/sql-inject-reject#readme
- Issues: https://github.com/Redeux/sql-inject-reject/issues
- npm.io page: https://npm.io/package/sql-inject-reject

## Dependencies (2)

- [xregexp](https://npm.io/package/xregexp.md) 4.2.0
- [raw-body](https://npm.io/package/raw-body.md) 2.3.3

## Alternatives

- [@sindresorhus/slugify](https://npm.io/package/@sindresorhus/slugify.md) — 3.7M weekly downloads
- [solid-js](https://npm.io/package/solid-js.md) — 2.7M weekly downloads
- [expo-glass-effect](https://npm.io/package/expo-glass-effect.md) — 2.5M weekly downloads
- [nanoassert](https://npm.io/package/nanoassert.md) — 780.8K weekly downloads
- [@ffmpeg/ffmpeg](https://npm.io/package/@ffmpeg/ffmpeg.md) — 529.5K weekly downloads

## Recent versions

- 0.1.0 (latest) — 2018-06-20

## README

# SQL-Inject-Reject [![Build Status](https://travis-ci.org/Redeux/sql-inject-reject.svg?branch=master)](https://travis-ci.org/Redeux/sql-inject-reject) [![Coverage Status](https://coveralls.io/repos/github/Redeux/sql-inject-reject/badge.svg?branch=master)](https://coveralls.io/github/Redeux/sql-inject-reject?branch=master) [![Packagist](https://img.shields.io/packagist/l/doctrine/orm.svg)](https://github.com/Redeux/sql-inject-reject/blob/master/LICENSE) 

  Detect and reject SQL injection attempts before processing them.

## About

  Analyzes HTTP a request's URL and body as they're received and if a SQL statement is detected responds with 403 Forbidden.  Intended to be part of a layered security approach.

## Getting Started
  
  Install sql-inject-reject as an npm module and save it to your package.json file as a dependency:

  ```
npm install sql-inject-reject
  ```

  Once it's installed you can reference it by calling ```require('sql-inject-reject');```

## Usage

  The middleware allows for configuration of the security level and SQL keywords to reject.

  The security levels are `paranoid` `elevated` `typical` and `silent`.  The security level is set to `typical` if no level is specified. Security levels may be specified on load:

  ```js
app.use(sqlInjectReject({ level: 'elevated' }))
  ```

  By default any security level `typical` or above looks for the `OR` SQL keyword.  
  
  Additional keywords can be specified with or without specifying a security level.  Keywords are validated regardless of their case and their hex equivalents.
  
  Keywords must be specified as an array:

  ```js
app.use(sqlInjectReject({ keywords: ['UNION','SELECT'] }))
  ```
  You may pass the middleware to your http server with `app.use()`:
  ```js
const sqlInjectReject = require('sql-inject-reject');
const express = require('express');

const app = express();

app.use(sqlInjectReject());
  ```

Or you may pass the middleware to a specific route or routes:
  ```js
const sqlInjectReject = require('sql-inject-reject');
const express = require('express');

const app = express();

app.post('/login', sqlInjectReject(), function(req, res) {
    // some code here
});
  ```

## Security Levels

By default security levels are hierarchical, which means higher security levels perform the validations of the security levels below them as well as their own.  The security level hierarchy is as follows: `paranoid` > `elevated` > `typical` > `silent`

* Paranoid: Checks for any of `'` `--` `#` and their hex equivalents. It is likely to produce a lot of false positives.
* Elevated: Checks for `=` followed by any `'` `--` `;` and their hex equivalents.
* Typical: Checks for `'OR` is any case and its hex equivalents.
* Silent: Performs no SQL checks but can still be used with specific keywords.

## Notes

  This package is not intended to be a substitute for SQL query validation.

## License
  
  MIT

---
_Source: https://npm.io/package/sql-inject-reject · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
