Commit 867f047
PR26.7: Plesk adapter via conf.d/panel_loader (panelfw) (#534)
* PR26.7: Plesk adapter via conf.d/panel_loader (panelfw)
Second adapter under the PR26.2 panelfw contract, mirroring the
PR26.3+PR26.4 DirectAdmin shape. Plesk-first sequence (cPanel
deferred to PR26.8 because the cPanel host is currently down /
incident-tied; clean Plesk path is available).
ADAPTER
internal/installer/panelfw/adapters/plesk/plesk.go
Detection (4 signals → strong/weak/absent):
E1 /usr/local/psa (canonical install dir)
E2 /usr/local/psa/admin/bin/httpdmng (panel binary marker —
from conf.d MARKER_BIN)
E3 plesk.service active (systemd-managed run)
E4 TCP 8443 in LISTEN state (control plane serving)
Required ports:
RequiredPorts() loads the canonical conf.d-declared TCP_IN / UDP_IN
surface via internal/ports/panel_loader.LoadPanelConfig("plesk").
Conf.d is the single source of truth; the adapter does NOT invent
port lists. Fail-closed on missing/empty/nil.
Validate reachability:
ValidateReachability() probes TCP 8443 ONLY (the Plesk HTTPS
control plane). 8447 (Plesk Updater) is in the conf.d full surface
but is NOT control-plane and may be closed on a healthy host.
Differences from DirectAdmin:
- No per-host control-port override. Plesk has no canonical config
file analogous to /usr/local/directadmin/conf/directadmin.conf
`port=N`. The adapter returns the constant default 8443. If a
future Plesk version exposes an override, the seam to add it is
here (mirror DA's readConfiguredPort).
- 8447 is intentionally part of the conf.d surface but not the
control plane. A dedicated test guards against the adapter
"passing" a Plesk host where only 8447 listens.
TESTS
internal/installer/panelfw/adapters/plesk/plesk_test.go
- 5 Detect tests (incl. negative-coupling guard: a DirectAdmin-shape
mock must NOT trigger Plesk detection)
- 11 RequiredPorts tests: stub-loader pass-through, fail-closed
branches (missing/empty/nil), defensive copy, real-loader against
shipped conf.d (no hardcoded port lists; structural assertions
only — control-port presence, SSH absence, surface size floor).
FUTURE-AUDITOR DIRECTIVE block included.
- 6 ValidateReachability tests including the 8447-not-8443 guard.
- 5 framework-integration tests (detected+reachable, detected+blocked,
error-message scope discipline, absent host, --no-panel override).
- init() registration verified.
- Read-only discipline verified (no WrittenFiles, only ss + systemctl
is-active commands recorded).
REGISTRATION
cmd/nftban-installer/main.go
Blank-import alongside DirectAdmin so init() registers the adapter
before phaseValidate runs.
LAB PROOF (lab2, Ubuntu 24.04, go1.22.2):
- go vet ./internal/installer/panelfw/... ./cmd/nftban-installer/...:
clean
- go test -count=1 -v ./internal/installer/panelfw/adapters/plesk/...:
25 / 25 PASS
- go test ./internal/installer/... ./cmd/nftban-installer/...:
18 / 18 packages PASS (no regression in DirectAdmin or framework)
- go build ./cmd/nftban-installer: builds clean with both adapters
OUT OF SCOPE
- cPanel adapter (PR26.8 — gated on Plesk evidence + clean cPanel host)
- DirectAdmin changes
- Shell decommission of nftban_panel_plesk.sh
- Plesk Firewall extension conflict detection (informational warn —
future PR like PANEL-ENABLE-LEGACY-WARNING-001)
- Plesk takeover lifecycle (no equivalent of `da build set csf no`
yet wired here; Plesk uses systemd mask + Plesk-internal config)
- Restore redesign
- Real-host Plesk install evidence — gated on PR26.7 merge + green
CI + Tier 1 rebuild + clean non-build Plesk host (lab2 is the
build host; using it destructively would weaken isolation)
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
* PR26.7: rephrase 4 error strings to clear staticcheck ST1005
Auditor CONDITIONAL-GO blocker: error strings should not be capitalized
(staticcheck ST1005). Four error strings in plesk.go led with the
proper noun "Plesk", which staticcheck flags despite the capitalization
being correct English.
Behavior unchanged. Strings rephrased to keep "Plesk" capitalized
inside the message, just not at the leading position:
- "Plesk conf.d load failed: ..."
→ "conf.d load failed for Plesk panel: ..."
- "Plesk conf.d load returned nil PanelConfig"
→ "conf.d load returned nil PanelConfig for Plesk panel"
- "Plesk conf.d declares no TCP_IN ports ..."
→ "conf.d for Plesk panel declares no TCP_IN ports ..."
- "Plesk control-plane port %d not in LISTEN state ..."
→ "control-plane port %d (Plesk) not in LISTEN state ..."
One test (TestRequiredPorts_MissingConfD_FailsClosed) asserted
strings.Contains(err, "Plesk conf.d") — that exact substring no
longer appears. Adjusted to assert the error references both
"Plesk" and "conf.d" independently, preserving the test's intent
without weakening it.
Lab proof on lab2 (Ubuntu 24.04, go1.22.2):
- go vet ./internal/installer/panelfw/adapters/plesk/... ./cmd/nftban-installer/...: clean
- go test -v ./internal/installer/panelfw/adapters/plesk/...: 25/25 PASS
- go test ./internal/installer/... ./cmd/nftban-installer/...: 18/18 packages PASS
- staticcheck ./internal/installer/panelfw/adapters/plesk/...: exit 0 (ST1005 cleared)
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>1 parent 1e48b79 commit 867f047
3 files changed
Lines changed: 1107 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
37 | 37 | | |
38 | 38 | | |
39 | 39 | | |
| 40 | + | |
| 41 | + | |
40 | 42 | | |
41 | 43 | | |
42 | 44 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
0 commit comments