Security News
pnpm 10.0.0 Blocks Lifecycle Scripts by Default
pnpm 10 blocks lifecycle scripts by default to improve security, addressing supply chain attack risks but sparking debate over compatibility and workflow changes.
@bbitgmbh/bbit.rdsdata.postgres
Advanced tools
WARNING - WORK IN PROGRESS
The goal of this project is to provide a node-postgres compatible client that connects to the AWS Aurora Postgres database over the AWS RDS Data HTTP API. This way we can connect node-postgres supporting libraries like ORMs to an AWS RDS database without the need for a proper VPC setup. It just uses HTTP with AWS IAM authentication, as we know it from AWS-SDK, S3, DynamoDB, etc.
NOTE: see test files under src/*.spec.ts for more examples.
npm i @bbitgmbh/bbit.rdsdata.postgres aws-sdk luxon --save
import { Client } from '@bbitgmbh/bbit.rdsdata.postgres';
// we introduced a special connection string url for this wrapper to be compatible with existing libraries:
const client = new Client(`awsrds://${encodeURIComponent(databaseName)}:${encodeURIComponent(awsSecretName)}@${awsRegion}.${awsAccount}.aws/${encodeURIComponent(awsRdsClustername)}`);
await client.connect();
const res = await client.query('select table_name from information_schema.tables where table_name = :name ', { name: 'pg_tables' });
/*
res = {
rows: [{ table_name: 'pg_tables' }]
}
*/
await client.end();
import pg = require('@bbitgmbh/bbit.rdsdata.postgres');
const connectionParams = (new pg.Client(`awsrds://${encodeURIComponent(databaseName)}:${encodeURIComponent(awsSecretName)}@${awsRegion}.${awsAccount}.aws/${encodeURIComponent(awsRdsClustername)}`)).dataApiRetrievePostgresDataApiClientConfig();
/*
connectionParams = {
user: 'aws:eu-central-1',
password: 'arn:aws:secretsmanager:eu-central-1:xxxxx:secret:rds-db-credentials/cluster-xxxxxx/postgres-xxxxx',
host: 'arn:aws:rds:eu-central-1:xxxxxx:cluster:xxxxxx',
port: 443,
database: 'xxxxxx'
}
*/
const sequelize = new Sequelize({
...(connectionParams as any),
dialect: 'postgres',
dialectModule: pg,
});
User.init(
{
id: {
type: DataTypes.INTEGER.UNSIGNED,
autoIncrement: true,
primaryKey: true,
},
name: {
type: new DataTypes.STRING(128),
allowNull: false,
},
preferredName: {
type: new DataTypes.STRING(128),
allowNull: true,
},
},
{
tableName: 'users',
sequelize, // passing the `sequelize` instance is required
},
);
await sequelize.sync();
const newUser = await User.create({
name: 'Johnny',
preferredName: 'John',
});
const foundUser = await User.findOne({ where: { name: 'Johnny' } });
console.log(foundUser.name); // Johnny
await sequelize.close();
When we started to go serverless with API Gateway and AWS Lambda, we soon recognized that RDS Database connection handling is hard. There are many great blog posts on the internet about, to summarize those:
If you wanna go around all those challenges, there is the AWS RDS Data API, which lets you execute SQL statements over HTTP with the usual AWS IAM authentication. But this introduces other challenges:
This project tries to solve those challenges by providing the missing piece of software to combine classic node-postgres with RDS Data HTTP API.
We are in the process to find and fix them. If you find an issue, please provide detailed info. Pull requests are very welcome.
While postgres is supporting chars like double point, it looks like AWS RDS Data API does not properly escape those. Same issue exists when trying to connect by AWS Console.
Due to the request/response nature of the http protocol asynchronous database notifications can not be transmitted back to the client.
Workaround: Cast them in your sql statement to something else, for instance a varchar(255). Example:
-- following statements selects all tables with their column names
-- field attname of table pg_class as has name datatype, therefore we cast this with cast(a.attname as varchar(512)) to a string
SELECT i.relname AS tablename, array_agg(cast(a.attname as varchar(512))) AS column_names
FROM pg_class t, pg_class i, pg_index ix, pg_attribute a WHERE t.oid = ix.indrelid AND i.oid = ix.indexrelid AND a.attrelid = t.oid AND t.relkind = 'r'
GROUP BY i.relname ORDER BY i.relname
some manual comparisons showed that executing statements over Data API has little overhead (middle two digit milliseconds).
See https://github.com/jeremydaly/data-api-client#enabling-data-api
MIT
FAQs
***WARNING - WORK IN PROGRESS***
We found that @bbitgmbh/bbit.rdsdata.postgres demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers 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.
Security News
pnpm 10 blocks lifecycle scripts by default to improve security, addressing supply chain attack risks but sparking debate over compatibility and workflow changes.
Product
Socket now supports uv.lock files to ensure consistent, secure dependency resolution for Python projects and enhance supply chain security.
Research
Security News
Socket researchers have discovered multiple malicious npm packages targeting Solana private keys, abusing Gmail to exfiltrate the data and drain Solana wallets.