Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
RDSDB is a simple database using node.js and promise-mysql that allows you to 'build' your own sql statements.
$ npm i -g rdsdb
First, we will just connect our db. You can use all the connection options as promise-mysql.
const { RDSDB } = require("../rdsdb.js")
require('dotenv').config() // only used for process.env, not strictly required.
const exampleDB = new RDSDB.Builder({
host: process.env.DB_HOST,
port: 3306,
database: process.env.TEST_DB,
user: process.env.TEST_DB_USERNAME,
password: process.env.TEST_DB_PASSWORD,
table: process.env.TEST_TABLE,
supportBigNumbers: true,
reconnect: true
});
The builder contains 7 different functions to build a query.
insertInto()
adds INSERT INTO ${table}
to the statement.update()
adds UPDATE ${table}
to the statement.listWithParenthesis(any[])
adds a list, for ex. (one, two, three)
valuesList(any[])
adds a string list, for ex. (`one`, `two`, `three`)
setValue(key, value)
adds a key with a value, for ex. one = `1`
where(key, value)
is the same assetValue()
, but use this for where clauses insteadaddStatement(string)
adds whatever you put in on to the end of the statement.At the very end, just call .exec()
to run your query.
This does return a Promise
Some examples of simple queries are:
exampleDB.insertInto().valuesList([`test`, `wow`])
test
and test2
given preset id
and secondid
testDB.update().setValue(`test`, 1).setValue(`test2`, true).where(`id`, 47283).where(`secondid`, 582356763)
A full file could look like:
const { RDSDB } = require("rdsdb")
require('dotenv').config()
const testDB = new RDSDB.Builder({
host: process.env.TEST_HOST,
port: 3306,
database: process.env.TEST_DB,
user: process.env.TEST_DB_USERNAME,
password: process.env.TEST_DB_PASSWORD,
table: process.env.TEST_TABLE,
supportBigNumbers: true,
reconnect: true
});
async function test() {
await testDB.ensureConnection();
// testDB.insertInto().valuesList([`test`, `wow`])
testDB.update().setValue(`test`, 1).setValue(`test2`, true).where(`id`, 47283).where(`secondid`, 582356763)
await testDB.exec().catch((err) => {
console.error(err)
})
}
test();
FAQs
Lightweight API to use in conjunction with MySQL. Built on promise-mysql
We found that rdsdb demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
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.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.