ssrf-agent-guard 0.1.9 → 0.1.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,80 @@
1
+ name: CI
2
+
3
+ on:
4
+ push:
5
+ branches: [main]
6
+ pull_request:
7
+ branches: [main]
8
+
9
+ jobs:
10
+ lint:
11
+ name: Lint
12
+ runs-on: ubuntu-latest
13
+ steps:
14
+ - uses: actions/checkout@v4
15
+
16
+ - name: Setup Node.js
17
+ uses: actions/setup-node@v4
18
+ with:
19
+ node-version: '20'
20
+ cache: 'npm'
21
+
22
+ - name: Install dependencies
23
+ run: npm ci
24
+
25
+ - name: Run ESLint
26
+ run: npm run lint
27
+
28
+ test:
29
+ name: Test (Node ${{ matrix.node-version }})
30
+ runs-on: ubuntu-latest
31
+ strategy:
32
+ matrix:
33
+ node-version: ['18', '20', '22']
34
+ steps:
35
+ - uses: actions/checkout@v4
36
+
37
+ - name: Setup Node.js ${{ matrix.node-version }}
38
+ uses: actions/setup-node@v4
39
+ with:
40
+ node-version: ${{ matrix.node-version }}
41
+ cache: 'npm'
42
+
43
+ - name: Install dependencies
44
+ run: npm ci
45
+
46
+ - name: Run tests
47
+ run: npm test
48
+
49
+ - name: Upload coverage reports
50
+ if: matrix.node-version == '20'
51
+ uses: codecov/codecov-action@v5
52
+ with:
53
+ token: ${{ secrets.CODECOV_TOKEN }}
54
+ file: ./coverage/lcov.info
55
+ fail_ci_if_error: false
56
+
57
+ build:
58
+ name: Build
59
+ runs-on: ubuntu-latest
60
+ needs: [lint, test]
61
+ steps:
62
+ - uses: actions/checkout@v4
63
+
64
+ - name: Setup Node.js
65
+ uses: actions/setup-node@v4
66
+ with:
67
+ node-version: '20'
68
+ cache: 'npm'
69
+
70
+ - name: Install dependencies
71
+ run: npm ci
72
+
73
+ - name: Build
74
+ run: npm run build
75
+
76
+ - name: Upload build artifacts
77
+ uses: actions/upload-artifact@v4
78
+ with:
79
+ name: dist
80
+ path: dist/
@@ -0,0 +1,36 @@
1
+ name: Publish to npm
2
+
3
+ on:
4
+ release:
5
+ types: [published]
6
+
7
+ jobs:
8
+ publish:
9
+ name: Publish
10
+ runs-on: ubuntu-latest
11
+ permissions:
12
+ contents: read
13
+ id-token: write
14
+ steps:
15
+ - uses: actions/checkout@v4
16
+
17
+ - name: Setup Node.js
18
+ uses: actions/setup-node@v4
19
+ with:
20
+ node-version: '20'
21
+ cache: 'npm'
22
+ registry-url: 'https://registry.npmjs.org'
23
+
24
+ - name: Install dependencies
25
+ run: npm ci
26
+
27
+ - name: Run tests
28
+ run: npm test
29
+
30
+ - name: Build
31
+ run: npm run build
32
+
33
+ - name: Publish to npm
34
+ run: npm publish --provenance --access public
35
+ env:
36
+ NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
package/README.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # ssrf-agent-guard
2
2
 
3
+ [![npm version](https://img.shields.io/npm/v/ssrf-agent-guard.svg)](https://www.npmjs.com/package/ssrf-agent-guard)
4
+ [![npm downloads](https://img.shields.io/npm/dm/ssrf-agent-guard.svg)](https://www.npmjs.com/package/ssrf-agent-guard)
5
+ [![codecov](https://codecov.io/gh/swapniluneva/ssrf-agent-guard/branch/main/graph/badge.svg)](https://codecov.io/gh/swapniluneva/ssrf-agent-guard)
6
+
3
7
  #### `ssrf-agent-guard` is a Node.js module for protecting your HTTP/HTTPS requests against SSRF (Server-Side Request Forgery) attacks. It wraps http.Agent and https.Agent to enforce pre and post DNS host/IP checks, block access to cloud metadata endpoints, private IPs, and unsafe domains.
4
8
  ---
5
9
 
package/dist/index.cjs.js CHANGED
@@ -85,7 +85,7 @@ function matchesDomain(hostname, pattern) {
85
85
  * Checks if a hostname matches any domain in a list.
86
86
  */
87
87
  function matchesAnyDomain(hostname, domains) {
88
- return domains.some(domain => matchesDomain(hostname, domain));
88
+ return domains.some((domain) => matchesDomain(hostname, domain));
89
89
  }
90
90
  /**
91
91
  * Validates a host against policy options.
@@ -114,7 +114,7 @@ function validatePolicy(hostname, policy) {
114
114
  // Check denyTLD
115
115
  if (policy.denyTLD && policy.denyTLD.length > 0) {
116
116
  const tld = getTLD(hostname);
117
- if (policy.denyTLD.map(t => t.toLowerCase()).includes(tld)) {
117
+ if (policy.denyTLD.map((t) => t.toLowerCase()).includes(tld)) {
118
118
  return { safe: false, reason: 'denied_tld' };
119
119
  }
120
120
  }
package/dist/index.esm.js CHANGED
@@ -81,7 +81,7 @@ function matchesDomain(hostname, pattern) {
81
81
  * Checks if a hostname matches any domain in a list.
82
82
  */
83
83
  function matchesAnyDomain(hostname, domains) {
84
- return domains.some(domain => matchesDomain(hostname, domain));
84
+ return domains.some((domain) => matchesDomain(hostname, domain));
85
85
  }
86
86
  /**
87
87
  * Validates a host against policy options.
@@ -110,7 +110,7 @@ function validatePolicy(hostname, policy) {
110
110
  // Check denyTLD
111
111
  if (policy.denyTLD && policy.denyTLD.length > 0) {
112
112
  const tld = getTLD(hostname);
113
- if (policy.denyTLD.map(t => t.toLowerCase()).includes(tld)) {
113
+ if (policy.denyTLD.map((t) => t.toLowerCase()).includes(tld)) {
114
114
  return { safe: false, reason: 'denied_tld' };
115
115
  }
116
116
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ssrf-agent-guard",
3
- "version": "0.1.9",
3
+ "version": "0.1.11",
4
4
  "description": "A TypeScript SSRF protection library for Node.js (express/axios) with advanced policies, DNS rebinding detection and cloud metadata protection.",
5
5
  "main": "dist/index.cjs.js",
6
6
  "module": "dist/index.esm.js",
@@ -42,7 +42,10 @@
42
42
  "@typescript-eslint/eslint-plugin": "^6.3.0",
43
43
  "@typescript-eslint/parser": "^6.3.0",
44
44
  "eslint": "^8.50.0",
45
+ "eslint-config-prettier": "^9.1.0",
46
+ "eslint-plugin-prettier": "^5.2.1",
45
47
  "jest": "^29.6.1",
48
+ "prettier": "^3.4.2",
46
49
  "rollup": "^4.53.3",
47
50
  "rollup-plugin-typescript2": "^0.36.0",
48
51
  "ts-jest": "^29.1.1",