Gathering detailed insights and metrics for request-filtering-agent
Gathering detailed insights and metrics for request-filtering-agent
Gathering detailed insights and metrics for request-filtering-agent
Gathering detailed insights and metrics for request-filtering-agent
agent-base
Turn a function into an `http.Agent` instance
tunnel-agent
HTTP proxy tunneling agent. Formerly part of mikeal/request, now a standalone module.
forever-agent
HTTP Agent that keeps socket connections alive between keep-alive requests. Formerly part of mikeal/request, now a standalone module.
http-proxy-agent
An HTTP(s) proxy `http.Agent` implementation for HTTP
npm install request-filtering-agent
95.5
Supply Chain
100
Quality
75.9
Maintenance
100
Vulnerability
100
License
Module System
Min. Node Version
Typescript Support
Node Version
NPM Version
21 Stars
98 Commits
7 Forks
4 Watching
2 Branches
4 Contributors
Updated on 19 Oct 2023
Minified
Minified + Gzipped
TypeScript (99.8%)
Shell (0.2%)
Cumulative downloads
Total Downloads
Last day
15.9%
14,705
Compared to previous day
Last week
-3%
74,158
Compared to previous week
Last month
16.1%
327,279
Compared to previous month
Last year
318.7%
2,559,006
Compared to previous year
An http(s).Agent class block the request to Private IP addresses and Reserved IP addresses.
It helps to prevent server-side request forgery (SSRF) attack.
This library depends on ipaddr.js definitions. This library blocks the request to these IP addresses by default.
So, This library block the request to non-unicast
IP addresses.
:warning: Node.js's built-in fetch
does not support http.Agent
.
http.Agent
librariesThis library provides Node.js's http.Agent implementation. http.Agent is supported by popular library.
http
and https
request-filtering-agent
works with these libraries!
Install with npm:
npm install request-filtering-agent
Version | Node.js 12 | Node.js 14 | Node.js 16 | Node.js 18 | Node.js 20 |
---|---|---|---|---|---|
v1.x.x | Support | Support | Support | Support | Not Support |
v2.0.0 | No Support | No Support | No Support | Support | Support |
useAgent(url, options)
return an agent for the url.
The agent blocks the request to Private network and Reserved IP addresses by default.
1const fetch = require("node-fetch"); 2const { useAgent } = require("request-filtering-agent"); 3const url = 'http://127.0.0.1:8080/'; 4fetch(url, { 5 // use http or https agent for url 6 agent: useAgent(url) 7}).catch(err => { 8 console.err(err); // DNS lookup 127.0.0.1(family:4, host:127.0.0.1.nip.io) is not allowed. Because, It is private IP address. 9});
request-filtering-agent
support loopback domain like nip.io.
This library detects the IP address that is dns lookup-ed.
$ dig 127.0.0.1.nip.io
;127.0.0.1.nip.io. IN A
;; ANSWER SECTION:
127.0.0.1.nip.io. 300 IN A 127.0.0.1
Example code:
1const fetch = require("node-fetch"); 2const { useAgent } = require("request-filtering-agent"); 3const url = 'http://127.0.0.1.nip.io:8080/'; 4fetch(url, { 5 agent: useAgent(url) // use http or https agent for url 6}).catch(err => { 7 console.err(err); // DNS lookup 127.0.0.1(family:4, host:127.0.0.1.nip.io) is not allowed. Because, It is private IP address. 8});
It will prevent DNS rebinding
1export interface RequestFilteringAgentOptions { 2 // Allow to connect private IP address 3 // This includes Private IP addresses and Reserved IP addresses. 4 // https://en.wikipedia.org/wiki/Private_network 5 // https://en.wikipedia.org/wiki/Reserved_IP_addresses 6 // Example, http://127.0.0.1/, http://localhost/, https://169.254.169.254/ 7 // Default: false 8 allowPrivateIPAddress?: boolean; 9 // Allow to connect meta address 0.0.0.0 10 // 0.0.0.0 (IPv4) and :: (IPv6) a meta address that routing another address 11 // https://en.wikipedia.org/wiki/Reserved_IP_addresses 12 // https://tools.ietf.org/html/rfc6890 13 // Default: false 14 allowMetaIPAddress?: boolean; 15 // Allow address list 16 // This values are preferred than denyAddressList 17 // Default: [] 18 allowIPAddressList?: string[]; 19 // Deny address list 20 // Default: [] 21 denyIPAddressList?: string[]; 22} 23/** 24 * A subclass of http.Agent with request filtering 25 */ 26export declare class RequestFilteringHttpAgent extends http.Agent { 27 constructor(options?: http.AgentOptions & RequestFilteringAgentOptions); 28} 29/** 30 * A subclass of https.Agent with request filtering 31 */ 32export declare class RequestFilteringHttpsAgent extends https.Agent { 33 constructor(options?: https.AgentOptions & RequestFilteringAgentOptions); 34} 35export declare const globalHttpAgent: RequestFilteringHttpAgent; 36export declare const globalHttpsAgent: RequestFilteringHttpsAgent; 37/** 38 * Get an agent for the url 39 * return http or https agent 40 * @param url 41 */ 42export declare const useAgent: (url: string, options?: https.AgentOptions & RequestFilteringAgentOptions) => RequestFilteringHttpAgent | RequestFilteringHttpsAgent;
An agent that allow requesting 127.0.0.1
, but it disallows other Private IP.
1const fetch = require("node-fetch"); 2const { RequestFilteringHttpAgent } = require("request-filtering-agent"); 3 4// Create http agent that allow 127.0.0.1, but it disallow other private ip 5const agent = new RequestFilteringHttpAgent({ 6 allowIPAddressList: ["127.0.0.1"], // it is preferred than allowPrivateIPAddress option 7 allowPrivateIPAddress: false, // Default: false 8}); 9// 127.0.0.1 is private ip address, but it is allowed 10const url = 'http://127.0.0.1:8080/'; 11fetch(url, { 12 agent: agent 13}).then(res => { 14 console.log(res); // OK 15});
0.0.0.0
See Releases page.
Install devDependencies and Run yarn test
:
yarn test
:memo: This testing require IPv6 supports:
Pull requests and stars are always welcome.
For bugs and feature requests, please create an issue.
For security issue, please see SECURITY.md
git checkout -b my-new-feature
git commit -am 'Add some feature'
git push origin my-new-feature
MIT © azu
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
no dangerous workflow patterns detected
Reason
GitHub workflow tokens follow principle of least privilege
Details
Reason
license file detected
Details
Reason
security policy file detected
Details
Reason
6 existing vulnerabilities detected
Details
Reason
Found 4/29 approved changesets -- score normalized to 1
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
dependency not pinned by hash detected -- score normalized to 0
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Score
Last Scanned on 2024-11-25
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More