Skip to content

Commit b27a45a

Browse files
authored
Merge pull request #26 from dash14/remove/legacy-rule-support
Remove deprecated legacy rule support
2 parents f05d522 + 63be298 commit b27a45a

File tree

7 files changed

+8
-225
lines changed

7 files changed

+8
-225
lines changed

Makefile

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -67,11 +67,7 @@ test_audit_mode: ## Run audit mode tests
6767
@$(MAKE) clean
6868

6969
.PHONY: test_unit
70-
test_unit: test_legacy test_report test_qjs ## Run unit tests
71-
72-
.PHONY: test_legacy
73-
test_legacy: ## Run legacy rules unit tests
74-
@node --test setup/lib/legacy-rules.test.mjs
70+
test_unit: test_report test_qjs ## Run unit tests
7571

7672
.PHONY: test_report
7773
test_report: ## Run report unit tests

docs/development.md

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -94,10 +94,7 @@ Fields: `[timestamp] buildcage [status] "domain:port" reason`
9494
│ ├── action.yml # GitHub Action: dash14/buildcage/setup@v1
9595
│ ├── compose.yml # Compose config for GitHub Actions (with image tag)
9696
│ ├── main.mjs # Setup entrypoint (rule generation, compose up)
97-
│ ├── post.mjs # Post-action cleanup
98-
│ └── lib/
99-
│ ├── legacy-rules.mjs # Legacy domain/port → wildcard conversion
100-
│ └── legacy-rules.test.mjs
97+
│ └── post.mjs # Post-action cleanup
10198
├── report/ # GitHub Actions report
10299
│ ├── action.yml # GitHub Action: dash14/buildcage/report@v1
103100
│ └── main.mjs # Log analysis and Job Summary output

docs/rules.md

Lines changed: 0 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -94,39 +94,3 @@ allowed_https_rules: >-
9494
~^registry\.npmjs\.org:\d+$
9595
~^.*\.githubusercontent\.com:443$
9696
```
97-
98-
## Deprecated Parameters
99-
100-
The following parameters are deprecated and will be removed in a future version:
101-
102-
| Deprecated | Replacement |
103-
|------------|-------------|
104-
| `allowed_https_domains` | `allowed_https_rules` |
105-
| `allowed_http_domains` | `allowed_http_rules` |
106-
| `https_ports` | Port specification in rules (e.g., `example.com:8443`) |
107-
| `http_ports` | Port specification in rules (e.g., `example.com:8080`) |
108-
109-
### Migration
110-
111-
```yaml
112-
# Before (deprecated)
113-
allowed_https_domains: "registry.npmjs.org, fonts.googleapis.com"
114-
https_ports: "443,8443"
115-
116-
# After
117-
allowed_https_rules: >-
118-
registry.npmjs.org:443
119-
registry.npmjs.org:8443
120-
fonts.googleapis.com:443
121-
fonts.googleapis.com:8443
122-
```
123-
124-
If you only use the default ports (80 for HTTP, 443 for HTTPS), migration is simpler — just rename the parameter and add the port:
125-
126-
```yaml
127-
# Before (deprecated)
128-
allowed_https_domains: "registry.npmjs.org, fonts.googleapis.com"
129-
130-
# After
131-
allowed_https_rules: "registry.npmjs.org:443 fonts.googleapis.com:443"
132-
```

setup/action.yml

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -28,23 +28,7 @@ inputs:
2828
description: "IP address allow rules (wildcard or ~regex), separated by whitespace. Port required. e.g., '192.168.1.1:443 10.0.0.1:8080'"
2929
required: false
3030
default: ''
31-
# Deprecated
32-
allowed_http_domains:
33-
description: "Deprecated: use allowed_http_rules instead"
34-
required: false
35-
default: ''
36-
allowed_https_domains:
37-
description: "Deprecated: use allowed_https_rules instead"
38-
required: false
39-
default: ''
40-
http_ports:
41-
description: "Deprecated: specify port per rule in allowed_http_rules (e.g., 'example.com:8080')"
42-
required: false
43-
default: '80'
44-
https_ports:
45-
description: "Deprecated: specify port per rule in allowed_https_rules (e.g., 'example.com:8443')"
46-
required: false
47-
default: '443'
31+
4832

4933
runs:
5034
using: node24

setup/lib/legacy-rules.mjs

Lines changed: 0 additions & 39 deletions
This file was deleted.

setup/lib/legacy-rules.test.mjs

Lines changed: 0 additions & 96 deletions
This file was deleted.

setup/main.mjs

Lines changed: 5 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { execFileSync } from "node:child_process";
22
import { join, dirname } from "node:path";
33
import { fileURLToPath } from "node:url";
4-
import { buildLegacyRules } from "./lib/legacy-rules.mjs";
4+
55
import { buildRules } from "../docker/files/tools/lib/rules.mjs";
66

77
const __dirname = dirname(fileURLToPath(import.meta.url));
@@ -24,10 +24,6 @@ function main() {
2424
httpsRulesInput: env.INPUT_ALLOWED_HTTPS_RULES,
2525
httpRulesInput: env.INPUT_ALLOWED_HTTP_RULES,
2626
ipRulesInput: env.INPUT_ALLOWED_IP_RULES,
27-
httpsDomainsInput: env.INPUT_ALLOWED_HTTPS_DOMAINS,
28-
httpDomainsInput: env.INPUT_ALLOWED_HTTP_DOMAINS,
29-
httpsPortsInput: env.INPUT_HTTPS_PORTS,
30-
httpPortsInput: env.INPUT_HTTP_PORTS,
3127
});
3228
} catch (e) {
3329
console.log(`::error::${e.message}`);
@@ -113,39 +109,20 @@ function resolveImageTag(repository, { versionInput, actionRef }) {
113109
}
114110

115111
/**
116-
* Build ACL rules by merging new-style rules and legacy rules.
117-
* New-style rules are passed through as-is (wildcard format).
118-
* Legacy rules are converted to wildcard format.
112+
* Build ACL rules from input strings.
113+
* Rules are passed through as-is (wildcard format), validated by converting to regex.
119114
*
120115
* @returns {{ httpsRules: string[], httpRules: string[], ipRules: string[] }}
121116
*/
122-
function buildACLRules({ httpsRulesInput, httpRulesInput, ipRulesInput, httpsDomainsInput, httpDomainsInput, httpsPortsInput, httpPortsInput }) {
123-
// New-style rules: pass through as-is (wildcard format), validate by converting to regex
117+
function buildACLRules({ httpsRulesInput, httpRulesInput, ipRulesInput }) {
124118
const httpsRules = httpsRulesInput?.trim().split(/\s+/).filter(Boolean) ?? [];
125119
const httpRules = httpRulesInput?.trim().split(/\s+/).filter(Boolean) ?? [];
126120
const ipRules = ipRulesInput?.trim().split(/\s+/).filter(Boolean) ?? [];
127121
buildRules(httpsRulesInput);
128122
buildRules(httpRulesInput);
129123
buildRules(ipRulesInput);
130124

131-
// Legacy rules (converted to wildcard format)
132-
const httpsLegacy = buildLegacyRules({
133-
domainsInput: httpsDomainsInput,
134-
portsInput: httpsPortsInput,
135-
defaultPort: 443,
136-
protocol: "HTTPS",
137-
});
138-
const httpLegacy = buildLegacyRules({
139-
domainsInput: httpDomainsInput,
140-
portsInput: httpPortsInput,
141-
defaultPort: 80,
142-
protocol: "HTTP",
143-
});
144-
return {
145-
httpsRules: [...httpsRules, ...httpsLegacy],
146-
httpRules: [...httpRules, ...httpLegacy],
147-
ipRules,
148-
};
125+
return { httpsRules, httpRules, ipRules };
149126
}
150127

151128
function logRules(label, rules) {

0 commit comments

Comments
 (0)