
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
dbay-sql-macros
Advanced tools
Table of Contents generated with DocToc
Because User-Defined Functions have several shortcomings in
SQLite, below), an
alternative mechanism named dbay-sql-macros has been conceived to work around some of those issues.
dbay-sql-macros has been integrated into DBay such that when
one constructs the db instance as db = new DBay { macros: true, }, all statements will be subjected to
macro expansion implicitly before SQLite gets to see them. That said, dbay-sql-macros can be used
independently from DBay as all it is concerned with is really interpolation of values into a given string,
according to the definition of macros it has recorded.
Instances of dbay-sql-macros hav two public methods, declare() and
resolve() to define and use macros. An example:
{ DBay_sqlx } = require 'dbay-sql-macros'
m = new DBay_sqlx()
m.declare "@secret_power( @a, @b ) = power( @a, @b ) / @b;"
result = m.resolve "select @secret_power( 3, 2 ) as p;"
In the above, we have declared a function-like macro named @secret_power() that accepts two arguments,
@a and @b. To the right of the equals sign we see power( @a, @b ) / @b; which is, except for the
trailing semicolon, the 'body' of the macro, which is what the macro, when used in an SQL query, will
'resolve' or 'expand' to, with values interpolated to replace the parameters in the body. Schematically and
step by step:
select @secret_power( 3, 2 ) as p; -- original query w/ macro
-- |-------------------| -- only this stretch of the query is affected
select power( @a, @b ) / @b as p; -- the query with the macro body inserted
select power( 3, @b ) / @b as p; -- the query with the macro body inserted
select power( 3, 2 ) / 2 as p; -- the query with the macro body inserted
-- |-------------------|
Notes:
@ (at-sign) in the above is purely a convention to avoid name clashes with existing
SQLite keywords and identifiers (@ is not allowed by SQLite in identifiers, so should be safe).select @secret_power( foo( x ), @bar( y, z, ')' ) ). However the
dbay-sql-lexer is still in its incipient stage so
hiccups can not be ruled out.m.declare SQL"""@add( @a, @b ) = ( @a + @b );"""
m.declare SQL"""@mul( @a, @b ) = ( @a * @b );"""
#.........................................................................................................
do ->
probe = SQL"""select @add( @mul( @add( 1, 2 ), 3 ), @add( 4, @mul( 5, 6 ) ) ) as p;"""
matcher = 'select ( ( ( 1 + 2 ) * 3 ) + ( 4 + ( 5 * 6 ) ) ) as p;'
FAQs
Unknown package
We found that dbay-sql-macros 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.

Security News
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.