diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 556ee5ec..b9d82acc 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -61,6 +61,12 @@ jobs: - name: Type check run: npx tsc --noEmit + - name: Install Vector 0.54.0 + run: | + curl -fsSL "https://github.com/vectordotdev/vector/releases/download/v0.54.0/vector-0.54.0-x86_64-unknown-linux-musl.tar.gz" \ + | sudo tar -xz -C /usr/local/bin --strip-components=2 "vector-x86_64-unknown-linux-musl/bin/vector" + vector --version + - name: Test run: pnpm test diff --git a/src/server/services/__tests__/dlp-vrl-integration.test.ts b/src/server/services/__tests__/dlp-vrl-integration.test.ts index dfe1fb91..1068cb43 100644 --- a/src/server/services/__tests__/dlp-vrl-integration.test.ts +++ b/src/server/services/__tests__/dlp-vrl-integration.test.ts @@ -18,32 +18,6 @@ async function vectorAvailable(): Promise { } } -/** - * Check whether the installed Vector binary supports the VRL `repeat()` function. - * `repeat()` was added after Vector 0.54; older binaries emit "call to undefined function". - * TODO: Remove this guard once CI is pinned to a Vector release that includes repeat(). - */ -async function vectorSupportsRepeat(): Promise { - const tmpDir = await mkdtemp(join(tmpdir(), "dlp-test-cap-")); - const programPath = join(tmpDir, "program.vrl"); - const inputPath = join(tmpDir, "input.json"); - try { - await writeFile(programPath, '. = { "r": repeat("*", 3) }'); - await writeFile(inputPath, "{}"); - await execFileAsync( - "vector", - ["vrl", "--input", inputPath, "--program", programPath, "--print-object"], - { timeout: 5000, env: { ...process.env, VECTOR_LOG: "error" } } - ); - return true; - } catch { - return false; - } finally { - await unlink(programPath).catch(() => {}); - await unlink(inputPath).catch(() => {}); - } -} - async function runVrl( source: string, input: Record @@ -69,35 +43,22 @@ async function runVrl( } } -// Templates whose VRL source uses functions not available in all Vector versions. -// repeat() is not present in Vector <=0.54; skip those fixtures until CI is updated. -const REQUIRES_REPEAT = new Set(["dlp-credit-card-masking"]); - describe("DLP VRL integration tests", async () => { const hasVector = await vectorAvailable(); - const hasRepeat = hasVector && (await vectorSupportsRepeat()); describe.skipIf(!hasVector)("execute VRL templates against fixtures", () => { for (const template of ALL_DLP_TEMPLATES) { // Skip custom regex — it requires user-configured pattern if (template.id === "dlp-custom-regex-masking") continue; - const needsRepeat = REQUIRES_REPEAT.has(template.id); - - describe.skipIf(needsRepeat && !hasRepeat)( - // Append a note when skipped so the reason is visible in test output - needsRepeat && !hasRepeat - ? `${template.name} [skipped: Vector repeat() not available]` - : template.name, - () => { - for (const fixture of template.testFixtures) { - it(fixture.description, async () => { - const result = await runVrl(template.vrlSource, fixture.input); - expect(result).toEqual(fixture.expectedOutput); - }); - } + describe(template.name, () => { + for (const fixture of template.testFixtures) { + it(fixture.description, async () => { + const result = await runVrl(template.vrlSource, fixture.input); + expect(result).toEqual(fixture.expectedOutput); + }); } - ); + }); } }); });