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.
Automation Framework for Testing (AFT) package supporting JavaScript unit, integration and functional testing
the base AFT library providing support for Plugins and some test configuration and helper classes and functions
> npm i aft-core
the aft-core
package contains classes for reading in configuration from a .json file and performing automatic environment variable replacements on values read in from configuration.
"%your_env_var%"
will instruct aftconfigMgr
to read in the value of your_env_var
from the environment variables and return this value when you request the field from your configuration{
"config-section-name": {
"config-field1": "%your_env_var%",
"config-field2": "some-value"
}
}
the aft-core
package contains several helper and utility classes, interfaces and functions to make functional testing and test development easier. These include:
dispose
function of a class that implements the IDisposable
interface when doneobject
with fallback to the aftconfig.json
file which enables specifying environment variables for valuesT
and returning void
T
and returning a specified type Tr
T
accepting 0 or more arguments on the constructorto create your own simple logging plugin that stores all logs until the dispose
function is called you would implement the code below.
NOTE: configuration for the below can be added in a object in the
aftconfig.json
namedondisposeconsolelogger
based on thekey
passed to theAbstractLoggingPlugin
constructor
export class OnDisposeConsoleLogger extends AbstractLoggingPlugin {
private _logs: string[];
constructor(options?: ILoggingPluginOptions) {
super('ondisposeconsolelogger', options);
this._logs = [];
}
async onLoad(): Promise<void> {
/* do nothing */
}
async log(level: LoggingLevel, message: string): Promise<void> {
if (await this.enabled()) {
let l: LoggingLevel = await this.level();
if (level.value >= l.value && level != LoggingLevel.none) {
this._logs.push(`${level.logString} - ${message}`);
}
}
}
async logResult(result: ITestResult): Promise<void> {
if (result.status.Passed) {
this.log(LoggingLevel.pass, JSON.stringify(result));
} else {
this.log(LogginLevel.fail, JSON.stringify(result));
}
}
async dispose(error?: Error): Promise<void> {
console.log(`[${await this.name()}]`);
this._logs.forEach((message) => {
console.log(message);
});
if (error) {
console.error(`ERROR: ${error.message}`);
}
console.log('OnDisposeConsoleLogger is now disposed!');
}
}
export class TestRailTestCasePlugin extends AbstractTestCasePlugin {
private _client: TestRailClient;
constructor(options?: ITestCasePluginOptions) {
super('testrailtestcaseplugin', options);
this._client = new TestRailClient();
}
async onLoad(): Promise<void> { /* perform some action if needed */ }
async getTestCase(testId: string): Promise<ITestCase> {
return await this._client.getTestCase(testId);
}
async findTestCases(searchTerm: string): Promise<ITestCase[]> {
return await this._client.findTestCases(searchTerm);
}
async shouldRun(testId: string): Promise<ProcessingResult> {
return await this._client.shouldRun(testId);
}
async dispose(error?: Error) { /* perform some action if needed */ }
}
export class BugzillaDefectPlugin extends AbstractDefectPlugin {
private _client: BugzillaClient;
constructor(options?: IDefectPluginOptions) {
super('bugzilladefectplugin', options)
this._client = new BugzillaClient();
}
async onLoad(): Promise<void> { /* perform some action if needed */ }
async getDefect(defectId: string): Promise<IDefect> {
return await this._client.getDefect(defectId);
}
async findDefects(searchTerm: string): Promise<IDefect[]> {
return await this._client.findDefects(searchTerm);
}
async dispose(error?: Error) { /* perform some action if needed */ }
}
the TestWrapper
and should
functions of aft-core
enable testing with pre-execution filtering based on integration with external test case and defect managers via plugin packages supporting each (see examples above).
TestWrapperOptions
object that simplifies usage of a TestWrapper
within your Jasmine or Mocha testsdescribe('Sample Test', () => {
it('can perform a demonstration of AFT', async () => {
let feature: FeatureObj = new FeatureObj();
/**
* the `should(options)` function
* checks any specified `AbstractTestCasePlugin`
* and `AbstractDefectPlugin` implementations
* to ensure the test should be run. It will then
* report to any `AbstractLoggingPlugin` implementations
* with an `ITestResult` indicating the success,
* failure or skipped status
*/
await should({expect: () => expect(feature.performAction()).toEqual('result of action'),
testCases: ['C1234'],
description: 'expect that performAction will return \'result of action\''
});
});
});
FAQs
Automation Framework for Testing (AFT) package supporting JavaScript unit, integration and functional testing
The npm package aft-core receives a total of 348 weekly downloads. As such, aft-core popularity was classified as not popular.
We found that aft-core 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.