
Research
Security News
Lazarus Strikes npm Again with New Wave of Malicious Packages
The Socket Research Team has discovered six new malicious npm packages linked to North Korea’s Lazarus Group, designed to steal credentials and deploy backdoors.
PostgreSQL migration tool on Node.js.
This SQL migration tool is designed to facilitate seamless database schema evolution. It operates based on a directory containing migration scripts and a defined order of execution. Here’s an overview of its core principles:
{name}.do.sql
for applying the migration and {name}.undo.sql
for reverting it.order
file explicitly lists the names of the migrations in the sequence they should be applied. This ensures controlled and predictable migration execution.order
file, the tool automatically executes the corresponding .do.sql
file to apply the migration..do.sql
file.Crucially, the tool maintains a table within the database that records the history of applied migrations along with their corresponding undo scripts. This facilitates efficient tracking of changes and enables precise rollback capabilities, ensuring the database schema can be accurately reverted to any previous state as defined by the migration history.
Columns:
Example order
file:
migration1
migration2
migration3
Example migrations dir list:
migration1.do.sql
migration1.undo.sql
migration2.do.sql
migration2.undo.sql
migration3.do.sql
migration3.undo.sql
order
Clone repo and run npm install do-migrate
or use Docker.
View action plan:
npx do-migrate [options]
Execute:
npx do-migrate --exec [options]
Options:
Env variables:
MIGRATOR_DB_HOST
— Database host (default: localhost)MIGRATOR_DB_PORT
— Database port (default: 5432)MIGRATOR_DB_USER
— Database user (default: postgres)MIGRATOR_DB_PASSWORD
Database password (default empty)MIGRATOR_DB_DATABASE
— Database name (default: postgres)MIGRATOR_DB_SCHEMA_NAME
— Database schema name (default: public)MIGRATOR_DB_SSL_REQUIRED
— SSL required flag (user true/false, default: false)MIGRATOR_DB_SSL_CA
— SSL CA (pem string)MITRATOR_FILES_PATH
— Path to migration dir (default: ./migrations)MITRATOR_ORDER_FILE
— Order file name (default: order)MIGRATOR_TABLE_NAME
— Sync table name (default: schema_versions)import Migrator, { Config } from 'do-migrate';
const config: Config = {
db: {
host: get('MIGRATOR_DB_HOST', 'localhost'),
port: get('MIGRATOR_DB_PORT', 5432),
user: get('MIGRATOR_DB_USER', 'postgres'),
...
},
migrations: {
path: path.resolve(__dirname, './migrations'),
...
}
};
const migrator = new Migrator(config);
// actions list without execution
console.log(
await migrator.inspect();
);
// execute migrations
await migrator.migrate((action) => console.log(action));
Types:
type Config = {
db?: {
host?: string;
port?: number;
user?: string;
password?: string;
database?: string;
... // pg.PoolConfig
};
migrations?: {
path?: string;
order_file?: string;
schema?: string;
table?: string;
};
};
enum Action {
Skip = 'skip',
Shrink = 'shrink',
Remove = 'remove',
Change = 'change',
Add = 'add',
}
interface Migrator {
constructor(config: Config): void
inspect(): Promise<{ name: string; action: Action; }[]>
migrate(
notify?: (action: { name: string; action: Action, success: boolean }) => void,
userActions?: { name: string; action: Action }[]
): Promise<void>
}
Inspect:
docker run --name migrator -e MIGRATOR_DB_HOST=localhost -e ... --volume ./migrations:/migrator/migrations nim579/do-migrate
Execute:
docker run --name migrator -e MIGRATOR_DB_HOST=localhost -e ... --volume ./migrations:/migrator/migrations nim579/do-migrate --exec
Docker Compose:
version: "2"
services:
migrator:
image: nim579/do-migrate:2
command:
- "--exec"
environment:
- MIGRATOR_DB_HOST
- MIGRATOR_DB_PORT
- MIGRATOR_DB_USER
- MIGRATOR_DB_PASSWORD
- MIGRATOR_DB_DATABASE
volume:
- ./migrations:/migrator/migrations
FAQs
PostgreSQL migrator
The npm package do-migrate receives a total of 0 weekly downloads. As such, do-migrate popularity was classified as not popular.
We found that do-migrate 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
The Socket Research Team has discovered six new malicious npm packages linked to North Korea’s Lazarus Group, designed to steal credentials and deploy backdoors.
Security News
Socket CEO Feross Aboukhadijeh discusses the open web, open source security, and how Socket tackles software supply chain attacks on The Pair Program podcast.
Security News
Opengrep continues building momentum with the alpha release of its Playground tool, demonstrating the project's rapid evolution just two months after its initial launch.