
Security News
The Hidden Blast Radius of the Axios Compromise
The Axios compromise shows how time-dependent dependency resolution makes exposure harder to detect and contain.
aspects-js
Use aspect in node js
Just install by npm
$ npm install --save aspects-js
You need require aspects-js at first of entry js file
require('aspects-js');
Add a js file to write an aspect.
First, you should require class Aspect from aspects-js.
//file: testAspect.js
const { Aspect } = require('aspects-js');
Secondly, you should declare a class extends Aspect and implements property pointcut and functions for join point.
//file: testAspect.js
class TestAspect extends Aspect {
get pointcut() { return '*.do*()' },
before() { console.log('this is for before join point') },
after() { console.log('this is for after join point') }
}
Then, you should exports an instance of your class which is extends Aspect
//file: testAspect.js
module.exports = new TestAspect();
At last, require your aspects at entry.js file
//file: entry.js
require('./testAspect.js');
Now, all classes when you required will be cut by all your aspects.
Aspectinterface Aspect {
readonly pointcut: Pointcut | string | ((joinPoint: JoinPoint) => boolean);
readonly order: number;
after(joinPoint: JoinPoint, result: any, error: Error);
afterReturn(joinPoint: JoinPoint, result: any): any;
afterThrow(joinPoint: JoinPoint, error: Error): void;
before(joinPoint: JoinPoint):void;
around(joinPoint: JoinPoint): any;
}
JoinPointclass JoinPoint {
readonly type: Class;
readonly fun: Function;
readonly thisArg: any;
readonly target: any;
readonly args: any[];
proceed(...args: any[]): any;
}
Pointcutclass Pointcut {
constructor(pointcut: string);
matches(joinPoint: JoinPoint): boolean;
}
"ClassName.FunctionName()"
execution"execution(ClassName.FunctionName())"
within"within(ClassName)"
"FunctionName(..)"
"FunctionName(Type1,Type2)"
"FunctionName(Type1,..,Type2)"
* Match all word wildcards"*Service.do*()"
Match all methods which's a name is start with do and in classes which's a name is end with Service
? Match one word wildcards"you?.do?()"
+ Or operate for name"within(Test1+Test2)"
Just match all methods in classes which's a name is Test1 or Test2
|,|| Or operate for condition"within(Test1)|within(Test2)"
Just match all methods in classes which's a name is Test1 or Test2
&,&& And operator for condition"within(Test1)&abc"
Just match method abc in class Test1
! Not operate for condition"!within(Test)"
match all methods except the methods in class Test
() Brackets operator for conditionIncrease the priority of expressions
() Call operator for function"abc()"
"abc(..)"
Match all methods which's a name is abc
"abc(Type1)"
Match all methods which's a name is abc and has one argument that instance of class Type1
, Split operator for arguments"*(Type1,Type2)"
Match all methods which has two arguments that then first one is instance of class Type1 and the second one is instance of class Type2
. Property operator for search methods of classes"Test.abc()"
Match the method abc of class Test
.. Multiple arguments operator for argumentsMatch none or multiple arguments
order property of interface AspectsThe Higher precedence when the value is lower
support function for pointcut
add property order for class Aspects
use AST for pointcut
FAQs
use aop in nodejs
We found that aspects-js 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
The Axios compromise shows how time-dependent dependency resolution makes exposure harder to detect and contain.

Research
A supply chain attack on Axios introduced a malicious dependency, plain-crypto-js@4.2.1, published minutes earlier and absent from the project’s GitHub releases.

Research
Malicious versions of the Telnyx Python SDK on PyPI delivered credential-stealing malware via a multi-stage supply chain attack.