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.
pgsql-deparser
Advanced tools
pgsql-deparser
is a streamlined tool designed to convert PostgreSQL Abstract Syntax Trees (AST) back into SQL queries. It is a companion module to pgsql-parser
, which is capable of both parsing SQL queries into ASTs and deparsing these ASTs back into SQL. However, unlike pgsql-parser
, which incorporates the full PostgreSQL parser, pgsql-deparser
focuses solely on the deparser functionality. This makes it an excellent choice for scenarios where only AST-to-SQL conversion is needed, avoiding the extra overhead associated with the full parsing capabilities.
npm install pgsql-deparser
pgsql-deparser
is lightweight and doesn't rely on native dependencies, facilitating easier integration and deployment across various environments.pgsql-deparser
offers a specialized, efficient solution for those who need to generate SQL statements from ASTs without the full parsing mechanism.The pgsql-deparser
module serializes ASTs to SQL in pure TypeScript, avoiding the full parser's native dependencies. It's useful when only SQL string conversion from ASTs is needed, and is written in pure TypeScript for easy cross-environment deployment.
Here's how you can use the deparser in your TypeScript code, using @pgsql/utils
to create an AST for deparse
:
import ast, { SelectStmt } from '@pgsql/utils';
import { deparse } from 'pgsql-deparser';
// This could have been obtained from any JSON or AST, not necessarily @pgsql/utils
const stmt: SelectStmt = ast.selectStmt({
targetList: [
ast.resTarget({
val: ast.columnRef({
fields: [ast.aStar()]
})
})
],
fromClause: [
ast.rangeVar({
relname: 'some_table',
inh: true,
relpersistence: 'p'
})
],
limitOption: 'LIMIT_OPTION_DEFAULT',
op: 'SETOP_NONE'
});
// Modify the AST if needed
stmt.SelectStmt.fromClause[0].RangeVar.relname = 'another_table';
// Deparse the modified AST back to a SQL string
console.log(deparse(stmts));
// Output: SELECT * FROM another_table
pgsql-deparser
?pgsql-deparser
is particularly useful in development environments where native dependencies are problematic or in applications where only the deparser functionality is required. Its independence from the full pgsql-parser
package allows for more focused and lightweight SQL generation tasks.
As of PG 13, PG majors versions maintained will have a matching dedicated major npm version. Only the latest Postgres stable release receives active updates.
Our latest is built with 13-latest
branch from libpg_query
PostgreSQL Major Version | libpg_query | Status | npm |
---|---|---|---|
13 | 13-latest | Active development | latest |
12 | (n/a) | Not supported | |
11 | (n/a) | Not supported | |
10 | 10-latest | Not supported | @1.3.1 (tree) |
pgsql-parser
.pgsql-parser
pgsql-parser
for parsing and deparsing SQL queries.Thanks @lfittl for building the core libpg_query
suite:
Thanks to @zhm for the OG parser that started it all:
AS DESCRIBED IN THE LICENSES, THE SOFTWARE IS PROVIDED “AS IS”, AT YOUR OWN RISK, AND WITHOUT WARRANTIES OF ANY KIND.
No developer or entity involved in creating Software will be liable for any claims or damages whatsoever associated with your use, inability to use, or your interaction with other users of the Software code or Software CLI, including any direct, indirect, incidental, special, exemplary, punitive or consequential damages, or loss of profits, cryptocurrencies, tokens, or anything else of value.
FAQs
PostgreSQL AST Deparser
The npm package pgsql-deparser receives a total of 22,932 weekly downloads. As such, pgsql-deparser popularity was classified as popular.
We found that pgsql-deparser demonstrated a healthy version release cadence and project activity because the last version was released less than 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.