An Express.js middleware that detects and blocks SQL injection attacks by inspecting query strings, route parameters, and request bodies for common SQL injection patterns. Version 1.0.0 is the initial release with no further updates, limited to basic blacklist-based detection, and provides no configuration options, making it unsuitable for production without additional validation. Compared to more robust alternatives like knex or parameterized queries, this package offers minimal protection and is considered a last-resort or learning tool.
npm install sql-sanitizerNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Shows basic usage of sql-sanitizer middleware in Express to block SQL injection patterns before handling requests.
Use parameterized queries (e.g., with knex or prepared statements) instead of relying on this middleware for security.
Audit the source code manually or consider alternatives like 'sql-injection' or 'mariadb' with proper escaping.
Use 'import sqlSanitizer from 'sql-sanitizer'' in modern Node.js.
Use: import sqlSanitizer from 'sql-sanitizer'; or const sqlSanitizer = require('sql-sanitizer');Run: npm install sql-sanitizer
Ensure express.json() is used before sqlSanitizer: app.use(express.json()); also consider using parameterized queries as a stronger defense.