
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.
Utility for HTTP validation. Implementation is based on the Chrome debugging protocol.
Utility for HTTP validation. Implementation is based on the Chrome debugging protocol.
While Selenium and other end-to-end solutions provide a good set of tools to check UI feedback and states, they lack tools for HTTP validation. HTTP Probe tries to solve an issue with HTTP testing by providing API to work and analyze Performance (in particular Network) logs in the modern browsers like Chromium.
Create an instance of the HTTP Probe. Don't forget to teardown an instance, otherwise http-probe will accumulate HTTP requests from every consecutive getRequest or getResponse invocation.
HttpProbeconstructor(provider)provider <Function> should return an array of performance logsExample:
const {HttpProbe} = require('http-probe');
let httpProbe = new HttpProbe(() => myMethodToExtractPerformanceLogs());
Extended example for WebdriverIO.
First of all you should activate performance logs for Google Chrome.
{
"loggingPrefs": {
"browser": "ALL",
"performance": "ALL"
}
}
Now in before hook you can create an instance of HTTP Probe:
before(() => {
httpProbe = new HttpProbe(() => {
return browser.log('performance').value;
});
});
You should use single test case per spec if you don't want fight with cache.
getRequest(search)search <String|RegExp> a pattern which will be executed against an URLReturns a Request entity with several properties:
length <Number>, - total number of matched requestsexecuted <Boolean>, - if request was executed at least onceexecutedOnce <Boolean>, - if request was executed exactly onceexecutedTwice <Boolean>, - if request was executed exactly twiceexecuteThrice <Boolean>, - if request was executed exactly thricefirst <RequestResult>, - a result object for the first requestsecond <RequestResult>, - a result object for the second requestthird <RequestResult>, - a result object for the third requestlast <RequestResult>, - a result object for the last requestRequestResultheaders <Object>, - request's headersmethod <String>, - HTTP method, 'GET', 'POST', etc.postData <Object>, - request's POST parametersurl <String>, - request's fully qualified URLExample:
expect(httpProbe.getRequest('accounts/8').executed).to.be.true;
getResponse(search)search <String|RegExp> a pattern which will be executed against an URLReturns a Response entity with several properties:
length <Number>, - total number of matched responsesreceived <Boolean>, - if response was delivered at least oncereceivedOnce <Boolean>, - if response was delivered exactly oncereceivedTwice <Boolean>, - if response was delivered exactly twicereceivedThrice <Boolean>, - if response was delivered exactly thricefirst <ResponseResult>, - a result object for the first responsesecond <ResponseResult>, - a result object for the second responsethird <ResponseResult>, - a result object for the third responselast <ResponseResult>, - a result object for the last responseResponseResultencodedDataLength <Number>, - Total number of bytes received for this request so far.fromDiskCache <Boolean>, - Specifies that the request was served from the disk cache.fromServiceWorker <Boolean>, - Specifies that the request was served from the ServiceWorker.headers <Object>, - HTTP response headers.requestHeaders <Object>, - (Optional) Refined HTTP request headers that were actually transmitted over the network.status <Number>, - HTTP response status code.statusText <String>, - HTTP response status text.url <String>, - Response URL. This URL can be different from CachedResource.url in case of redirect.Example:
expect(httpProbe.getResponse('total/cart').last.status).to.be.equal(200);
NetworkInspectorCaptures network events through the Chrome debugging protocol for the later use in HttpProbe for analysis. Specifically designed for the solutions that can not provide performance logs or it's more convenient to use listener abstraction for network logs.
constructor(eventTarget)eventTarget <EventEmitter> entity that satisfies EventEmitter interface at least for ability to subscribe (on) and unsubscribe (removeListener) for the eventsExample:
const {NetworkInspector} = require('http-probe');
let inspector = new NetworkInspector(myEmitter);
console.log(inspector.getLogs());
inspector.dispose();
Extended example for WebdriverIO with the use of before and after hooks.
const {HttpProbe, NetworkInspector} = require('http-probe');
let inspector;
before(() => {
browser.cdp('Network', 'enable');
inspector = new NetworkInspector(browser);
httpProbe = new HttpProbe(() => inspector.getLogs());
});
after(() => {
inspector.dispose();
});
dispose()Resets internal resources and listeners. After this point, the instance of Network Inspector is not usable.
Example:
networkInspector.dispose();
getLogs(deplete)deplete <Boolean> an optional parameter, by default it's always true. If the parameter is false logs will be preserved before the next getLogs invocation.Returns a list of messages formatted to comply with Chrome debugging protocol.
Example:
let myLogs = networkInspector.getLogs();
console.log(myLogs);
Tests are working with snapshots. Snapshots are picked randomly and recorded for 30 seconds. To create a snapshot, instance of the Chrome should be active, if yor are using Mac, it could be done via:
/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome --remote-debugging-port=9222
or run Chrome Browser in the container:
$ docker pull justinribeiro/chrome-headless
$ docker run -it --rm -p 9222:9222 justinribeiro/chrome-headless
Now it's possible to make a snapshot:
URL=http://some-domain.com node create-snapshot.js
// or visit multiple websites
URL="http://domain1.com http://domain2.com" node create-snapshot.js
FAQs
Utility for HTTP validation. Implementation is based on the Chrome debugging protocol.
We found that http-probe 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.