ssrf-agent-guard 0.1.9 → 0.1.10
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.
- package/.github/workflows/ci.yml +79 -0
- package/.github/workflows/publish.yml +36 -0
- package/dist/index.cjs.js +2 -2
- package/dist/index.esm.js +2 -2
- package/package.json +4 -1
|
@@ -0,0 +1,79 @@
|
|
|
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@v4
|
|
52
|
+
with:
|
|
53
|
+
file: ./coverage/lcov.info
|
|
54
|
+
fail_ci_if_error: false
|
|
55
|
+
|
|
56
|
+
build:
|
|
57
|
+
name: Build
|
|
58
|
+
runs-on: ubuntu-latest
|
|
59
|
+
needs: [lint, test]
|
|
60
|
+
steps:
|
|
61
|
+
- uses: actions/checkout@v4
|
|
62
|
+
|
|
63
|
+
- name: Setup Node.js
|
|
64
|
+
uses: actions/setup-node@v4
|
|
65
|
+
with:
|
|
66
|
+
node-version: '20'
|
|
67
|
+
cache: 'npm'
|
|
68
|
+
|
|
69
|
+
- name: Install dependencies
|
|
70
|
+
run: npm ci
|
|
71
|
+
|
|
72
|
+
- name: Build
|
|
73
|
+
run: npm run build
|
|
74
|
+
|
|
75
|
+
- name: Upload build artifacts
|
|
76
|
+
uses: actions/upload-artifact@v4
|
|
77
|
+
with:
|
|
78
|
+
name: dist
|
|
79
|
+
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/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.
|
|
3
|
+
"version": "0.1.10",
|
|
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",
|