fix: repair malformed SOA and expand release verification
This commit is contained in:
1 parent
5d7da681e7
commit
3623006f25
11 files changed
+106
-4
No files matched your search
@@ -45,6 +45,13 @@ jobs:
|
||||
printf 'image_id=%s\n' "$(docker image inspect --format '{{.Id}}' "$CI_IMAGE")" >> "$GITHUB_OUTPUT"
|
||||
scripts/test-image.sh "$CI_IMAGE" "$VERSION" "$commit"
|
||||
scripts/test-e2e.sh "$CI_IMAGE"
|
||||
- name: Save accessibility screenshots
|
||||
if: always()
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: accessibility-screenshots
|
||||
path: e2e/reports/**/screenshots/*.png
|
||||
if-no-files-found: warn
|
||||
- name: Publish image
|
||||
env:
|
||||
GIT_HOST: ${{ vars.GIT_HOST }}
|
||||
|
||||
@@ -40,3 +40,10 @@ jobs:
|
||||
trap 'docker image rm "$image" >/dev/null' EXIT
|
||||
scripts/test-image.sh "$image" "$version" "$commit"
|
||||
scripts/test-e2e.sh "$image"
|
||||
- name: Save accessibility screenshots
|
||||
if: always()
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: accessibility-screenshots
|
||||
path: e2e/reports/**/screenshots/*.png
|
||||
if-no-files-found: warn
|
||||
@@ -336,7 +336,7 @@ Errors refuse the write with HTTP 422. Warnings let the write through and are re
|
||||
|
||||
Errors:
|
||||
|
||||
- A zone has exactly one SOA, at the apex. The SOA cannot be created when one exists and cannot be deleted on its own; it goes away only with the zone.
|
||||
- A zone has exactly one SOA, at the apex. The SOA cannot be created when one exists and the last SOA can only be deleted with the zone. Repair may move a misplaced SOA, correct its content, or remove an extra SOA.
|
||||
- The last NS at the apex cannot be deleted.
|
||||
- A name with a CNAME has no other record, and has only one CNAME.
|
||||
- No two records with the same name, type and canonical content.
|
||||
@@ -444,6 +444,7 @@ Operations:
|
||||
| Delegation | `delegation_list` | `delegation_grant`, `delegation_revoke` |
|
||||
| Users | `user_list`, `user_read` | `user_create`, `user_role`, `user_password`, `user_delete` |
|
||||
| Audit | `audit_read` | |
|
||||
| Unknown API request | `api_unknown` | |
|
||||
|
||||
Each API route maps to exactly one operation (section 11). CLI rows use `user_create`, `user_password`, `user_role` and `user_delete`.
|
||||
|
||||
|
||||
@@ -81,7 +81,7 @@ After field validation every record is converted to the `miekg/dns` RR the plugi
|
||||
|
||||
Errors refuse a write with HTTP `422`: a zone has exactly one SOA, at the apex, which cannot be created twice or deleted on its own; the last apex NS cannot be deleted; a name with a CNAME has no other record and only one CNAME; no two records share name, type and canonical content. Warnings let the write through and are returned with the response: records of one name and type with different TTLs, `NS`, `MX` or `SRV` targets that are CNAME owners or have no address record in the zone, names below a zone cut, `TXT` text longer than 255 bytes (served as several strings).
|
||||
|
||||
The zone page can repair an existing broken SOA set by editing a misplaced SOA or deleting an extra SOA. If a conflicting CNAME blocks the repair, delete that CNAME first. To restore a missing SOA, use a merge import containing an apex SOA.
|
||||
The zone page can repair an existing broken SOA set by editing a misplaced SOA or deleting an extra SOA. If a conflicting CNAME blocks a structural repair, delete that CNAME first. If the sole SOA has malformed content and conflicts with a CNAME, correct the SOA content first, then remove the CNAME. To restore a missing SOA, use a merge import containing an apex SOA.
|
||||
|
||||
The zone check (API, UI and `check` command) reports every row the plugin cannot serve correctly.
|
||||
|
||||
|
||||
+1
-1
@@ -267,4 +267,4 @@ services:
|
||||
E2E_FUZZ_RECORDS: ${E2E_FUZZ_RECORDS:-}
|
||||
E2E_OPERATOR_ACTIONS: ${E2E_OPERATOR_ACTIONS:-}
|
||||
E2E_ARGS: ${E2E_ARGS:-}
|
||||
command: ["sh", "-c", "npx tsc --noEmit && exec npx playwright test $$E2E_ARGS"]
|
||||
command: ["sh", "-c", "node --test unit/*.test.mjs && npx tsc --noEmit && exec npx playwright test $$E2E_ARGS"]
|
||||
@@ -18,4 +18,5 @@ ENV CI=1 NODE_ENV=test
|
||||
COPY package.json package-lock.json ./
|
||||
RUN npm ci --no-audit --no-fund
|
||||
COPY . .
|
||||
COPY --from=app-static /js /static/js
|
||||
CMD ["npx", "playwright", "test"]
|
||||
@@ -35,6 +35,8 @@ test('a power user operates a large installation, with restart and edit conflict
|
||||
await first.page.goto('/');
|
||||
await expect(first.page.getByRole('link', { name: large, exact: true })).toBeVisible();
|
||||
const zonesMs = performance.now() - startZones;
|
||||
await first.page.locator('#zone-search').fill(large);
|
||||
await expect(first.page.getByRole('link', { name: zones[1], exact: true })).toHaveCount(0);
|
||||
const startZone = performance.now();
|
||||
await first.page.getByRole('link', { name: large, exact: true }).click();
|
||||
await expect(first.page.getByRole('rowheader', { name: 'seed-0000', exact: true })).toBeVisible();
|
||||
@@ -48,6 +50,24 @@ test('a power user operates a large installation, with restart and edit conflict
|
||||
});
|
||||
expect(zonesMs, 'zones page renders its links within 2 seconds').toBeLessThan(2000);
|
||||
expect(editMs, '10,000-record zone is interactive within 2 seconds').toBeLessThan(2000);
|
||||
const dialog = first.page.locator('#record-dialog');
|
||||
const close = dialog.getByRole('button', { name: 'Close' });
|
||||
const save = dialog.locator('#rec-submit');
|
||||
await save.focus();
|
||||
await first.page.keyboard.press('Tab');
|
||||
await expect(close).toBeFocused();
|
||||
await first.page.keyboard.press('Shift+Tab');
|
||||
await expect(save).toBeFocused();
|
||||
await first.page.keyboard.press('Escape');
|
||||
await first.page.locator('#filter-type').selectOption('A');
|
||||
await first.page.locator('#page-next').click();
|
||||
await expect(first.page.getByRole('rowheader', { name: 'seed-0000', exact: true })).toHaveCount(0);
|
||||
await first.page.locator('#filter-text').fill('seed-9997');
|
||||
await expect(first.page.getByRole('rowheader', { name: 'seed-9997', exact: true })).toBeVisible();
|
||||
await first.page.locator('#filter-type').selectOption('SOA');
|
||||
await expect(first.page.getByRole('rowheader', { name: 'seed-9997', exact: true })).toHaveCount(0);
|
||||
await first.openZone(large);
|
||||
await first.openEdit({ name: 'seed-0000', type: 'A' });
|
||||
await second.openZone(large);
|
||||
await second.openEdit({ name: 'seed-0000', type: 'A' });
|
||||
await restartWithSessions(world, first, second);
|
||||
|
||||
@@ -733,3 +733,37 @@ func TestIntegrationDelegationZoneLock(t *testing.T) {
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestIntegrationConcurrentWritesInDistinctZones(t *testing.T) {
|
||||
it := newITZoneAPI(t)
|
||||
zones := []string{zoneAPITestName, "other.example."}
|
||||
for _, zone := range zones {
|
||||
body := strings.Replace(zoneAPITestCreate, "Example.ORG", strings.TrimSuffix(zone, "."), 1)
|
||||
zoneAPITestStatus(t, t.Context(), zoneAPITestRequest(it.server, it.admin, "zone_create", "", "", "", body), 201)
|
||||
}
|
||||
ctx, cancel := context.WithTimeout(t.Context(), 10*time.Second)
|
||||
defer cancel()
|
||||
start := make(chan struct{})
|
||||
results := make(chan itZoneResult, len(zones))
|
||||
for _, zone := range zones {
|
||||
request := zoneAPITestRequest(it.server, it.admin, "record_create", zone, "", "", zoneAPITestRecord)
|
||||
go func() {
|
||||
<-start
|
||||
response, err := zoneAPITestCall(ctx, request)
|
||||
results <- itZoneResult{response, err}
|
||||
}()
|
||||
}
|
||||
close(start)
|
||||
for range zones {
|
||||
if result := <-results; result.err != nil || result.response.Status != 201 {
|
||||
t.Fatalf("concurrent write failed: %+v", result)
|
||||
}
|
||||
}
|
||||
it.audit(t, "record_create", len(zones))
|
||||
for _, zone := range zones {
|
||||
rows, err := it.records.ZoneRows(ctx, zone)
|
||||
if err != nil || len(rows) != 4 {
|
||||
t.Fatalf("zone %s: found %d rows, error %v", zone, len(rows), err)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -197,7 +197,10 @@ func validateZoneChanges(zone string, current []recordRow, changes zoneChanges)
|
||||
after := summarizeZone(result)
|
||||
problems, warnings = zoneRuleProblems(zone, result, after, true)
|
||||
soaRepair := len(after.soa) != 0 && soaDefects(after.soa) < soaDefects(before.soa)
|
||||
soaOnlyRepair := soaRepair && slices.Equal(nonSOARows(current), nonSOARows(result))
|
||||
soaContentRepair := len(before.soa) == 1 && len(after.soa) == 1 &&
|
||||
before.soa[0].ID == after.soa[0].ID &&
|
||||
!validSOAContent(before.soa[0]) && validSOAContent(after.soa[0])
|
||||
soaOnlyRepair := (soaRepair || soaContentRepair) && slices.Equal(nonSOARows(current), nonSOARows(result))
|
||||
cnameRepair := soaDefects(after.soa) != 0 && changes.deletesOnly()
|
||||
if len(problems) != 0 && (soaOnlyRepair || cnameRepair) {
|
||||
beforeProblems, _ := zoneRuleProblems(zone, current, before, true)
|
||||
@@ -260,6 +263,14 @@ func deletesOnlyConflictingCNAMEs(ids []int64, problems []zoneProblem) bool {
|
||||
return true
|
||||
}
|
||||
|
||||
func validSOAContent(row recordRow) bool {
|
||||
if !row.Content.Valid {
|
||||
return false
|
||||
}
|
||||
_, err := decodeRecord("SOA", row.Content.String)
|
||||
return err == nil
|
||||
}
|
||||
|
||||
func soaDefects(soa []recordRow) int {
|
||||
defects := len(soa) - 1
|
||||
for _, row := range soa {
|
||||
|
||||
@@ -227,3 +227,23 @@ func TestValidateZoneChangePairs(t *testing.T) {
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestRepairMalformedSOAWithConflictingCNAME(t *testing.T) {
|
||||
base := modelBaseZone()
|
||||
broken := base[0]
|
||||
broken.Content.String = strings.Replace(broken.Content.String, `"refresh":3600`, `"refresh":"invalid"`, 1)
|
||||
if validSOAContent(broken) {
|
||||
t.Fatal("test SOA must have invalid content")
|
||||
}
|
||||
cname := modelRawRow(3, "", "CNAME", 3600, `{"host":"target.example."}`)
|
||||
current := []recordRow{broken, base[1], cname}
|
||||
repair := zoneChanges{SOAUpdate: &base[0]}
|
||||
if problems, _ := validateZoneChanges(base[0].Zone, current, repair); len(problems) != 0 {
|
||||
t.Fatalf("SOA repair rejected: %+v", problems)
|
||||
}
|
||||
current = repair.finalRows(current)
|
||||
remove := zoneChanges{Deletes: []int64{cname.ID}}
|
||||
if problems, _ := validateZoneChanges(base[0].Zone, current, remove); len(problems) != 0 {
|
||||
t.Fatalf("CNAME removal rejected after SOA repair: %+v", problems)
|
||||
}
|
||||
}
|
||||
@@ -121,6 +121,7 @@ done
|
||||
echo "test-e2e: run ${project} against ${image}"
|
||||
docker build --quiet \
|
||||
--build-arg "PLAYWRIGHT_IMAGE=${playwright_image}" \
|
||||
--build-context app-static=static \
|
||||
--label "cdwu.e2e.run=${project}" \
|
||||
--file e2e/dockerfile \
|
||||
--tag "$runner_image" \
|
||||
|
||||
Reference in new issue
Block a user