Gathering detailed insights and metrics for sql-fmt
Gathering detailed insights and metrics for sql-fmt
Gathering detailed insights and metrics for sql-fmt
Gathering detailed insights and metrics for sql-fmt
Simple SQL escape and format for MySQL \ Postgres and easy create Ojbect to SQL
npm install sql-fmt
Typescript
Module System
Node Version
NPM Version
72.7
Supply Chain
98.9
Quality
75.8
Maintenance
100
Vulnerability
100
License
JavaScript (53.17%)
TypeScript (46.83%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
MIT License
1 Stars
22 Commits
1 Watchers
2 Branches
1 Contributors
Updated on Feb 19, 2021
Latest Version
2.1.0
Package Id
sql-fmt@2.1.0
Unpacked Size
30.84 kB
Size
10.16 kB
File Count
29
NPM Version
6.14.8
Node Version
15.3.0
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
Base by sqlstring
Simple SQL escape and format for MySQL easy create Ojbect to SQL, support typescript.
sqlstring
escape SQL string['dog', 20]
to SQL ('dog', 20
{ key : value }
to SQL (key1, key2) VALUES (value1, value2)
{ key : value }
to SQL (key1='value1' AND key2='value2')
{ key : value }
to SQL key1='value1', key2='value2'
1$ npm install sql-fmt
1const sql = require("sql-fmt");
1console.log(sql`SELECT * FROM users WHERE name=${"hello"};`); 2//out: SELECT * FROM users WHERE name='hello' 3 4console.log(sql`SELECT * FROM users WHERE name=${"'hello' and 1=1"};`); 5//out: SELECT * FROM users WHERE name='\'hello\' and 1=1'
Ignore escape Single word, add #:
1console.log(sql`SELECT * FROM users WHERE name=#${"hello"};`); 2//out: SELECT * FROM users WHERE name='hello'
1console.log(sql`SELECT * FROM users WHERE ${{ name: "hello", age: [20, 30] }}`); 2//out: SELECT * FROM users WHERE (name='hello' AND (age=20 OR age=30))
1console.log(sql`INSERT INTO users ${{ dog: "ff", age: 20 }};`);
2//out: INSERT INTO users (dog,age) VALUES ('ff',20);
1console.log( 2 sql`UPDATE users SET ${{ dog: "ff", age: 20 }} where ${{ 3 name: "apple", 4 }};` 5); 6//out: UPDATE users SET dog='ff',age=20 where (name='apple');
No escape insert string, but need alert to SQL injection:
use #
start string, sql-fmt can remove #
before insert.
1console.log(sql`SELECT * FROM users ${"#where name = '20' and 1=1"}`); 2//out: SELECT * FROM users where name = '20' and 1=1
Auto use sql template insert where
\ set
\ values
\ escape
in string template
1console.log(`SELECT * FROM users WHERE name=${sql.escape("hello")};`); 2//out: SELECT * FROM users WHERE name='hello'; 3 4console.log(`SELECT * FROM users WHERE name=${sql.escape("'hello' OR 1=1")}`); 5//out: SELECT * FROM users WHERE name='\'hello\' OR 1=1';
1console.log(`SELECT * FROM users WHERE ${sql.escapeId("name")}='hello';`); 2//out: SELECT * FROM users WHERE `name`='hello';
1console.log(`INSERT INTO users (dog, age) values (${sql.insert(['ff', 20]);`);
2//out: INSERT INTO users (dog, age) VALUES ('ff',20);
1console.log(`INSERT INTO users ${sql.insert({ dog: "ff", age: 20 })};`);
2//out: INSERT INTO users (dog,age) VALUES ('ff',20);
3
4console.log(
5 `INSERT INTO users ${sql.insert([
6 { dog: "aa", age: 10 },
7 { dog: "bb", age: 20 },
8 ])};`
9);
10//out: INSERT INTO users (dog,age) VALUES ('aa',10),('bb',20);
1console.log(`SELECT * FROM users WHERE ${sql.where({ dog: "ff", age: 20 })};`); 2//out: SELECT * FROM users WHERE (dog='ff' AND age=20); 3 4console.log( 5 `SELECT * FROM users WHERE ${sql.where({ dog: ["aa", "bb"], age: 20 })};` 6); 7//out: SELECT * FROM users WHERE ((dog='aa' OR dog='bb') AND age=20);
1console.log( 2 `UPDATE users SET ${sql.set({ dog: "ff", age: 20 })} where ${sql.where({ 3 name: "apple", 4 })};` 5); 6//out: UPDATE users SET dog='ff',age=20 where (name='apple');
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
license file detected
Details
Reason
Found 0/22 approved changesets -- score normalized to 0
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
no SAST tool detected
Details
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
33 existing vulnerabilities detected
Details
Score
Last Scanned on 2025-05-05
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More